Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress - add/edit part2 #2175

Merged
merged 5 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 89 additions & 2 deletions cypress/e2e/Display/datasets.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,95 @@ describe('Datasets', function() {
});
});

it('copy an existing dataset', function() {
it('add row/column to an existing dataset', function() {
// Create a new dataset and then search for it and delete it
cy.createDataset('Cypress Test Dataset ' + testRun).then((id) => {
cy.intercept({
url: '/dataset?*',
query: {dataSet: 'Cypress Test Dataset ' + testRun},
}).as('loadGridAfterSearch');

// Intercept the PUT request
cy.intercept({
method: 'POST',
url: /\/dataset\/\d+\/column$/,
}).as('postRequestAddColumn');

cy.intercept({
method: 'POST',
url: /\/dataset\/data\/\d+/,
}).as('postRequestAddRow');

cy.visit('/dataset/view');

// Filter for the created dataset
cy.get('#Filter input[name="dataSet"]')
.type('Cypress Test Dataset ' + testRun);

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#datasets tbody tr').should('have.length', 1);

// Click on the first row element to open the View data
cy.get('#datasets tr:first-child .dropdown-toggle').click();
cy.get('#datasets tr:first-child .dataset_button_viewcolumns').click();

cy.get('#datasets').contains('No data available in table');

// Add data row to dataset
cy.contains('Add Column').click();
cy.get('.modal input#heading').type('Col1');

// Save
cy.get('.bootbox .save-button').click();

// Wait for the intercepted PUT request and check the form data
cy.wait('@postRequestAddColumn').then((interception) => {
// Get the request body (form data)
const response = interception.response;
const responseData = response.body.data;

// assertion on the "dataset" value
expect(responseData.heading).to.eq('Col1');

cy.contains('View Data').click();
cy.get('#datasets').contains('No data available in table');

// Add data row to dataset
cy.contains('Add Row').click();
cy.get('#dataSetDataAdd').within(() => {
cy.get('input:first').type('Your text goes here');
});

// Save
cy.get('.bootbox .save-button').click();

// Wait for the intercepted request and check data
cy.wait('@postRequestAddRow').then((interception) => {
cy.contains('Added Row');
});
});

// Now try to delete the dataset
cy.visit('/dataset/view');

// Filter for the created dataset
cy.get('#Filter input[name="dataSet"]')
.type('Cypress Test Dataset ' + testRun);

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#datasets tbody tr').should('have.length', 1);

// Click on the first row element to open the View data
cy.get('#datasets tr:first-child .dropdown-toggle').click();
cy.get('#datasets tr:first-child .dataset_button_delete').click();
});
});


it('copy an existing dataset', function() {
// Create a new dataset and then search for it and copy it
cy.createDataset('Cypress Test Dataset ' + testRun).then((res) => {
cy.intercept({
url: '/dataset?*',
Expand All @@ -124,7 +211,7 @@ describe('Datasets', function() {
cy.get('#datasets tr:first-child .dropdown-toggle').click();
cy.get('#datasets tr:first-child .dataset_button_copy').click();

// Delete test dataset
// save
cy.get('.bootbox .save-button').click();

// Wait for the intercepted POST request and check the form data
Expand Down
115 changes: 107 additions & 8 deletions cypress/e2e/Display/dayparts.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,64 @@ describe('Dayparts', function() {
cy.contains('Added Cypress Test Daypart ' + testRun + '_1');
});

// TODO filter needed
it.skip('searches and delete existing daypart', function() {
it('searches and edit existing daypart', function() {
// Create a new daypart and then search for it and edit it
cy.createDayPart('Cypress Test Daypart ' + testRun).then((id) => {
cy.intercept({
url: '/daypart?*',
query: {name: 'Cypress Test Daypart ' + testRun},
}).as('loadGridAfterSearch');

// Intercept the PUT request
cy.intercept({
method: 'PUT',
url: '/daypart/*',
}).as('putRequest');

cy.visit('/daypart/view');

// Filter for the created daypart
cy.get('#Filter input[name="name"]')
.type('Cypress Test Daypart ' + testRun);

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#dayparts tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#dayparts tr:first-child .dropdown-toggle').click();
cy.get('#dayparts tr:first-child .daypart_button_edit').click();

cy.get('.modal input#name').clear()
.type('Cypress Test Daypart Edited ' + testRun);

// edit test daypart
cy.get('.bootbox .save-button').click();

// Wait for the intercepted PUT request and check the form data
cy.wait('@putRequest').then((interception) => {
// Get the request body (form data)
const response = interception.response;
const responseData = response.body.data;

// assertion on the "daypart" value
expect(responseData.name).to.eq('Cypress Test Daypart Edited ' + testRun);
});

// Delete the daypart and assert success
cy.deleteDayPart(id).then((res) => {
expect(res.status).to.equal(204);
});
});
});

it('searches and delete existing daypart', function() {
// Create a new daypart and then search for it and delete it
cy.createDayPart('Cypress Test Daypart ' + testRun).then((res) => {
cy.server();
cy.route('/daypart?draw=2&*').as('daypartGridLoad');
cy.intercept({
url: '/daypart?*',
query: {name: 'Cypress Test Daypart ' + testRun},
}).as('loadGridAfterSearch');

cy.visit('/daypart/view');

Expand All @@ -64,7 +116,8 @@ describe('Dayparts', function() {
.type('Cypress Test Daypart ' + testRun);

// Wait for the grid reload
cy.wait('@daypartGridLoad');
cy.wait('@loadGridAfterSearch');
cy.get('#dayparts tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#dayparts tr:first-child .dropdown-toggle').click();
Expand All @@ -78,14 +131,61 @@ describe('Dayparts', function() {
});
});

it.skip('selects multiple dayparts and delete them', function() {
// Create a new daypart and then search for it and delete it
it('searches and share existing daypart', function() {
// Create a new daypart and then search for it and share it
cy.createDayPart('Cypress Test Daypart ' + testRun).then((res) => {
cy.intercept({
url: '/daypart?*',
query: {name: 'Cypress Test Daypart ' + testRun},
}).as('loadGridAfterSearch');

cy.intercept({
url: '/user/permissions/DayPart/*',
query: {name: 'Everyone'},
}).as('loadPermissionDayPartAfterSearch');

cy.visit('/daypart/view');

// Filter for the created daypart
cy.get('#Filter input[name="name"]')
.type('Cypress Test Daypart ' + testRun);

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#dayparts tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#dayparts tr:first-child .dropdown-toggle').click();
cy.get('#dayparts tr:first-child .daypart_button_permissions').click();

cy.get('.modal #name').type('Everyone');
cy.wait('@loadPermissionDayPartAfterSearch');

cy.get('#permissionsTable').within(() => {
cy.get('tbody').find('tr').should('have.length', 1);

cy.get('input[type="checkbox"][data-permission="view"]').should('be.visible').check().should('be.checked');

cy.wait(1000); // without this wait it does not work, so lets keep the 1s wait here
cy.get('input[type="checkbox"][data-permission="edit"]').check().should('be.checked');
});

// Save
cy.get('.bootbox .save-button').click();

// Check if daypart is deleted in toast message
cy.get('.toast').contains('Share option Updated');
});
});

it('selects multiple dayparts and delete them', function() {
// Create a new daypart and then search for it and delete it
cy.createDayPart('Cypress Test Daypart ' + testRun).then((res) => {
cy.intercept({
url: '/daypart?*',
query: {name: 'Cypress Test Daypart'},
}).as('loadGridAfterSearch');

// Delete all test dayparts
cy.visit('/daypart/view');

Expand All @@ -104,7 +204,6 @@ describe('Dayparts', function() {
cy.get('.dataTables_info button[data-toggle="dropdown"]').click();
cy.get('.dataTables_info a[data-button-id="daypart_button_delete"]').click();

cy.get('input#deleteData').check();
cy.get('button.save-button').click();

// Modal should contain one successful delete at least
Expand Down
4 changes: 4 additions & 0 deletions cypress/e2e/Display/displaygroups.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ describe('Display Groups', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#displaygroups tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#displaygroups tr:first-child .dropdown-toggle').click();
Expand Down Expand Up @@ -118,6 +119,7 @@ describe('Display Groups', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#displaygroups tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#displaygroups tr:first-child .dropdown-toggle').click();
Expand Down Expand Up @@ -159,6 +161,7 @@ describe('Display Groups', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#displaygroups tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#displaygroups tr:first-child .dropdown-toggle').click();
Expand Down Expand Up @@ -237,6 +240,7 @@ describe('Display Groups', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#displaygroups tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#displaygroups tr:first-child .dropdown-toggle').click();
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/Display/syncgroups.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('Sync Groups', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#syncgroups tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#syncgroups tr:first-child .dropdown-toggle').click();
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/Layout/displaysettings.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe('Display Settings', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#displayProfiles tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#displayProfiles tr:first-child .dropdown-toggle').click();
Expand Down Expand Up @@ -149,6 +150,7 @@ describe('Display Settings', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#displayProfiles tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#displayProfiles tr:first-child .dropdown-toggle').click();
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/Layout/tags.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('Tags', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#tags tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#tags tr:first-child .dropdown-toggle').click();
Expand Down Expand Up @@ -107,6 +108,7 @@ describe('Tags', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#tags tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#tags tr:first-child .dropdown-toggle').click();
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/Layout/transitions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ describe('Transitions', function() {
cy.login();
});

it('should add edit an transition', function() {
it('should edit an transition', function() {
// Intercept the PUT request
cy.intercept({
method: 'PUT',
url: '/transition/*',
}).as('putRequest');

cy.visit('/transition/view');
cy.get('#transitions tbody tr').should('have.length', 3);

// Click on the first row element to open the delete modal
cy.get('#transitions tr:first-child .dropdown-toggle').click();
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/Layout/usergroups.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('Usergroups', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#userGroups tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#userGroups tr:first-child .dropdown-toggle').click();
Expand Down Expand Up @@ -111,6 +112,7 @@ describe('Usergroups', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#userGroups tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#userGroups tr:first-child .dropdown-toggle').click();
Expand Down
3 changes: 3 additions & 0 deletions cypress/e2e/Layout/users.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('Users', function() {
.type('cypress');

cy.get('.select2-container--bootstrap').eq(1).click();
cy.log('Before waiting for Icon Dashboard element');
cy.wait('@loadHomepageAfterSearch');
cy.get('.select2-results__option')
.should('contain', 'Icon Dashboard')
Expand Down Expand Up @@ -84,6 +85,7 @@ describe('Users', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#users tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#users tr:first-child .dropdown-toggle').click();
Expand Down Expand Up @@ -128,6 +130,7 @@ describe('Users', function() {

// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#users tbody tr').should('have.length', 1);

// Click on the first row element to open the delete modal
cy.get('#users tr:first-child .dropdown-toggle').click();
Expand Down
Loading
Loading