Browse Source

test: cy views suite local storage & tab handling corrections

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/3667/head
Raju Udava 2 years ago
parent
commit
2b3949928c
  1. 10
      scripts/cypress/integration/common/00_pre_configurations.js
  2. 22
      scripts/cypress/integration/common/4a_table_view_grid_gallery_form.js
  3. 38
      scripts/cypress/integration/common/4b_table_view_share.js
  4. 47
      scripts/cypress/integration/common/4c_form_view_detailed.js
  5. 13
      scripts/cypress/integration/common/4d_table_view_grid_locked.js
  6. 31
      scripts/cypress/integration/common/4e_form_view_share.js
  7. 96
      scripts/cypress/integration/common/4f_grid_view_share.js
  8. 20
      scripts/cypress/support/commands.js

10
scripts/cypress/integration/common/00_pre_configurations.js

@ -164,7 +164,6 @@ export const genTest = (apiType, dbType) => {
it("Admin SignUp", () => {
cy.task("log", "This will be output to the terminal");
cy.saveLocalStorage();
loginPage.signUp(roles.owner.credentials);
});
@ -250,6 +249,15 @@ export const genTest = (apiType, dbType) => {
else {
cy_createProjectBlock(proj, apiType, dbType);
}
// kludge: wait for page load to finish
cy.wait(2000);
// close team & auth tab
cy.get('button.ant-tabs-tab-remove').should('exist').click();
cy.wait(1000);
// first instance of updating local storage information
cy.saveLocalStorage();
});
};

22
scripts/cypress/integration/common/4a_table_view_grid_gallery_form.js

@ -15,25 +15,24 @@ export const genTest = (apiType, dbType) => {
//
before(() => {
cy.restoreLocalStorage();
cy.wait(1000);
mainPage.tabReset();
// open a table to work on views
//
cy.openTableTab("Country", 25);
// toggle right navbar (open)
// cy.get('.nc-toggle-right-navbar').should('exist').click();
});
beforeEach(() => {
cy.restoreLocalStorage();
cy.wait(1000);
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
cy.restoreLocalStorage();
cy.closeTableTab("Country");
cy.saveLocalStorage();
});
// Common routine to create/edit/delete GRID & GALLERY view
@ -48,9 +47,6 @@ export const genTest = (apiType, dbType) => {
cy.getActiveModal(".nc-modal-view-create").find(".ant-btn-primary").click();
cy.toastWait("View created successfully");
// kludge: right navbar closes abruptly. force it open again
// window.localStorage.setItem('nc-right-sidebar', '{"isOpen":true,"hasSidebar":true}')
// validate if view was created && contains default name 'Country1'
cy.get(`.nc-${viewType}-view-item`)
.contains(`${capitalizeFirstLetter(viewType)}-1`)
@ -67,9 +63,6 @@ export const genTest = (apiType, dbType) => {
.type(`${viewType}View-1{enter}`);
cy.toastWait("View renamed successfully");
// kludge: right navbar closes abruptly. force it open again
// window.localStorage.setItem('nc-right-sidebar', '{"isOpen":true,"hasSidebar":true}')
// validate
cy.get(`.nc-${viewType}-view-item`)
.contains(`${viewType}View-1`)
@ -86,9 +79,6 @@ export const genTest = (apiType, dbType) => {
cy.getActiveModal(".nc-modal-view-delete").find('.ant-btn-dangerous').click();
cy.toastWait("View deleted successfully");
// kludge: right navbar closes abruptly. force it open again
// window.localStorage.setItem('nc-right-sidebar', '{"isOpen":true,"hasSidebar":true}')
// confirm if the number of veiw entries is reduced by 1
cy.get(".nc-view-item").its("length").should("eq", 1);
});

38
scripts/cypress/integration/common/4b_table_view_share.js

@ -37,11 +37,24 @@ export const genTest = (apiType, dbType) => {
//
before(() => {
cy.restoreLocalStorage();
cy.wait(1000);
mainPage.tabReset();
cy.openTableTab("City", 25);
});
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
cy.restoreLocalStorage();
cy.closeTableTab("City");
cy.saveLocalStorage();
});
it("Generate link with password", () => {
// store base URL- to re-visit and delete form view later
cy.url().then((url) => {
storedURL = url;
@ -51,12 +64,6 @@ export const genTest = (apiType, dbType) => {
cy.signOut();
});
beforeEach(() => {
});
afterEach(() => {
});
it("Share view with incorrect password", () => {
cy.visit(linkText, {
baseUrl: null,
@ -99,24 +106,11 @@ export const genTest = (apiType, dbType) => {
it("Delete view", () => {
loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("City", 25);
cy.wait(500);
mainPage.toggleRightSidebar();
cy.wait(500);
cy.saveLocalStorage();
cy.wait(1000);
// wait for page load to complete
cy.get(".nc-grid-row").should("have.length", 25);
mainPage.deleteCreatedViews();
});
after(() => {
cy.restoreLocalStorage();
cy.wait(500);
cy.closeTableTab("City");
});
});
};

47
scripts/cypress/integration/common/4c_form_view_detailed.js

@ -58,37 +58,27 @@ export const genTest = (apiType, dbType) => {
// Run once before test- create project (rest/graphql)
//
before(() => {
mainPage.tabReset();
// standalone test
// loginPage.loginAndOpenProject(apiType, dbType);
// kludge: wait for page load to finish
cy.wait(2000);
// close team & auth tab
cy.get('button.ant-tabs-tab-remove').should('exist').click();
cy.wait(1000);
// open a table to work on views
//
cy.restoreLocalStorage();
cy.openTableTab("Country", 25);
mainPage.toggleRightSidebar();
cy.saveLocalStorage();
cy.wait(500);
});
beforeEach(() => {
cy.restoreLocalStorage();
cy.wait(500);
// fix me!
window.localStorage.setItem('nc-right-sidebar', '{"isOpen":true,"hasSidebar":true}')
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
cy.restoreLocalStorage();
cy.closeTableTab("Country");
cy.saveLocalStorage();
});
// Common routine to create/edit/delete GRID & GALLERY view
@ -96,6 +86,7 @@ export const genTest = (apiType, dbType) => {
//
const viewTest = (viewType) => {
it(`Create ${viewType} view`, () => {
// click on 'Grid/Gallery' button on Views bar
cy.get(`.nc-create-${viewType}-view`).click();
@ -385,35 +376,9 @@ export const genTest = (apiType, dbType) => {
// validate if form has appeared again
validateFormHeader();
// // verify URL & copy it for subsequent test
// cy.url().should("contain", `Country/Form-1`);
// cy.url().then((url) => {
// cy.log(url);
// formViewURL = url;
// });
//
// cy.wait(300);
});
// it.skip(`Validate ${viewType}: URL validation after re-access`, () => {
// // visit URL
// cy.log(formViewURL);
//
// cy.visit(formViewURL, {
// baseUrl: null,
// });
//
// // New form appeared? Header & description should exist
// validateFormHeader();
// });
it(`Delete ${viewType} view`, () => {
// cy.visit("/");
// cy.wait(5000);
// projectsPage.openConfiguredProject(apiType, dbType);
// cy.openTableTab("Country", 25);
// number of view entries should be 2 before we delete
cy.get(".nc-view-item").its("length").should("eq", 2);

13
scripts/cypress/integration/common/4d_table_view_grid_locked.js

@ -9,24 +9,21 @@ export const genTest = (apiType, dbType) => {
//
before(() => {
cy.restoreLocalStorage();
cy.wait(500);
mainPage.tabReset();
// open a table to work on views
//
cy.openTableTab("Country", 25);
});
beforeEach(() => {
cy.restoreLocalStorage();
cy.wait(500);
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
cy.restoreLocalStorage();
cy.wait(500)
cy.closeTableTab("Country");
cy.saveLocalStorage();
});
const lockViewTest = (enabled) => {

31
scripts/cypress/integration/common/4e_form_view_share.js

@ -14,30 +14,22 @@ export const genTest = (apiType, dbType) => {
//
before(() => {
// loginPage.loginAndOpenProject(apiType, dbType);
// cy.openTableTab("City", 25);
// cy.wait(500);
// mainPage.toggleRightSidebar();
// cy.wait(500);
// cy.saveLocalStorage();
// cy.wait(500);
cy.restoreLocalStorage();
cy.wait(500);
mainPage.tabReset();
// open a table to work on views
//
cy.openTableTab("City", 25);
});
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
cy.restoreLocalStorage();
cy.wait(500);
cy.closeTableTab("City");
cy.saveLocalStorage();
});
// Common routine to create/edit/delete GRID & GALLERY view
@ -46,9 +38,6 @@ export const genTest = (apiType, dbType) => {
const viewTest = (viewType) => {
it(`Create ${viewType} view`, () => {0
cy.restoreLocalStorage();
cy.wait(500);
// click on create grid view button
cy.get(`.nc-create-${viewType}-view`).click();
@ -97,9 +86,6 @@ export const genTest = (apiType, dbType) => {
it(`Share form view`, () => {
cy.restoreLocalStorage();
cy.wait(500);
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
@ -198,11 +184,6 @@ export const genTest = (apiType, dbType) => {
// go back to base page
loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("City", 25);
cy.wait(500);
mainPage.toggleRightSidebar();
cy.wait(500);
cy.saveLocalStorage();
cy.wait(500);
// number of view entries should be 2 before we delete
cy.get(".nc-view-item").its("length").should("eq", 2);

96
scripts/cypress/integration/common/4f_grid_view_share.js

@ -42,33 +42,23 @@ export const genTest = (apiType, dbType) => {
//
before(() => {
cy.restoreLocalStorage();
cy.wait(500);
mainPage.tabReset();
cy.openTableTab("Address", 25);
// loginPage.loginAndOpenProject(apiType, dbType);
//
// // open a table to work on views
// //
// cy.openTableTab("Address", 25);
// mainPage.toggleRightSidebar();
// //
// cy.saveLocalStorage();
});
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
// close table
// mainPage.deleteCreatedViews()
cy.restoreLocalStorage();
cy.wait(500);
cy.closeTableTab("Address");
cy.saveLocalStorage();
});
// Common routine to create/edit/delete GRID & GALLERY view
@ -77,9 +67,6 @@ export const genTest = (apiType, dbType) => {
const viewTest = (viewType) => {
it(`Create ${viewType.toUpperCase()} view`, () => {
cy.restoreLocalStorage();
cy.wait(500);
// create a normal public view
cy.get(`.nc-create-${viewType}-view`).click();
cy.getActiveModal(".nc-modal-view-create").find("button:contains(Submit)").click();
@ -93,9 +80,6 @@ export const genTest = (apiType, dbType) => {
it(`Share ${viewType.toUpperCase()} hide, sort, filter & verify`, () => {
cy.restoreLocalStorage();
cy.wait(500);
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Grid-1")
.click();
@ -108,9 +92,6 @@ export const genTest = (apiType, dbType) => {
it(`Share GRID view : ensure we have only one link even if shared multiple times`, () => {
cy.restoreLocalStorage();
cy.wait(500);
// generate view link multiple times
generateViewLink("combined");
generateViewLink("combined");
@ -364,11 +345,6 @@ export const genTest = (apiType, dbType) => {
loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("Address", 25);
mainPage.toggleRightSidebar();
cy.wait(500);
cy.saveLocalStorage();
cy.wait(500);
// number of view entries should be 2 before we delete
cy.get(".nc-view-item").its("length").should("eq", 2);
@ -387,9 +363,7 @@ export const genTest = (apiType, dbType) => {
describe(`${apiType.toUpperCase()} api - Grid view/ row-column update verification`, () => {
before(() => {
cy.restoreLocalStorage();
cy.wait(500);
// Address table has belongs to, has many & many-to-many
cy.openTableTab("Country", 25);
@ -401,47 +375,21 @@ export const genTest = (apiType, dbType) => {
});
});
after(() => {
// close table
// cy.visit(storedURL, {
// baseUrl: null,
// });
// cy.wait(5000);
beforeEach(() => {
cy.restoreLocalStorage();
});
loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("Country", 25)
cy.wait(500);
mainPage.toggleRightSidebar();
cy.wait(500);
afterEach(() => {
cy.saveLocalStorage();
cy.wait(500);
// delete row
mainPage.getPagination(5).click();
// kludge: flicker on load
cy.wait(3000)
// wait for page rendering to complete
cy.get(".nc-grid-row").should("have.length", 10);
mainPage.getCell("Country", 10).rightclick();
cy.getActiveMenu(".nc-dropdown-grid-context-menu")
.find('.ant-dropdown-menu-item:contains("Delete Row")')
.first()
.click();
// delete column
mainPage.deleteColumn("dummy");
mainPage.deleteCreatedViews();
});
// close table
after(() => {
cy.restoreLocalStorage();
cy.closeTableTab("Country");
cy.saveLocalStorage();
});
it(`Generate default Shared GRID view URL`, () => {
cy.restoreLocalStorage();
cy.wait(500);
// add row
cy.get(".nc-add-new-row-btn").click();
cy.get(".nc-expand-col-Country").find(".nc-cell > input")
@ -488,6 +436,28 @@ export const genTest = (apiType, dbType) => {
// verify column headers
cy.get('[data-title="dummy"]').should("exist");
});
it(`Clean up`, () => {
loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("Country", 25)
// delete row
mainPage.getPagination(5).click();
// kludge: flicker on load
cy.wait(3000)
// wait for page rendering to complete
cy.get(".nc-grid-row").should("have.length", 10);
mainPage.getCell("Country", 10).rightclick();
cy.getActiveMenu(".nc-dropdown-grid-context-menu")
.find('.ant-dropdown-menu-item:contains("Delete Row")')
.first()
.click();
// delete column
mainPage.deleteColumn("dummy");
mainPage.deleteCreatedViews();
});
});
};

20
scripts/cypress/support/commands.js

@ -235,40 +235,20 @@ let LOCAL_STORAGE_MEMORY = {};
let LOCAL_STORAGE_MEMORY_v2 = {};
Cypress.Commands.add('saveLocalStorage', (name) => {
if (name) {
cy.task('log', `[saveLocalStorage] ${name}`);
LOCAL_STORAGE_MEMORY_v2[name] = {};
Object.keys(localStorage).forEach((key) => {
LOCAL_STORAGE_MEMORY_v2[name][key] = localStorage[key];
});
return;
}
LOCAL_STORAGE_MEMORY = {};
Object.keys(localStorage).forEach((key) => {
LOCAL_STORAGE_MEMORY[key] = localStorage[key];
});
cy.printLocalStorage();
});
Cypress.Commands.add('restoreLocalStorage', (name) => {
if (name) {
cy.task('log', `[restoreLocalStorage] ${name}`);
Object.keys(LOCAL_STORAGE_MEMORY_v2[name]).forEach((key) => {
localStorage.setItem(key, LOCAL_STORAGE_MEMORY_v2[name][key]);
});
return;
}
cy.deleteLocalStorage().then(() => {
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {
localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
});
cy.printLocalStorage();
});
});
Cypress.Commands.add('deleteLocalStorage', () => {
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {

Loading…
Cancel
Save