Browse Source

Merge pull request #3797 from nocodb/test/cy-wait-cleanup

test(misc): wait clean up
pull/3802/head
Raju Udava 2 years ago committed by GitHub
parent
commit
6b44884cb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      packages/nc-gui/components/smartsheet-header/Menu.vue
  2. 25
      scripts/cypress/integration/common/5a_user_role.js
  3. 14
      scripts/cypress/integration/common/6f_attachments.js
  4. 5
      scripts/cypress/integration/common/6g_base_share.js
  5. 12
      scripts/cypress/integration/common/7a_create_project_from_excel.js
  6. 10
      scripts/cypress/integration/common/8a_webhook.js
  7. 7
      scripts/cypress/integration/common/9a_QuickTest.js
  8. 4
      scripts/cypress/integration/spec/roleValidation.spec.js
  9. 9
      scripts/cypress/support/commands.js
  10. 20
      scripts/cypress/support/page_objects/mainPage.js

1
packages/nc-gui/components/smartsheet-header/Menu.vue

@ -23,6 +23,7 @@ const { getMeta } = useMetas()
const deleteColumn = () => const deleteColumn = () =>
Modal.confirm({ Modal.confirm({
title: h('div', ['Do you want to delete ', h('span', { class: 'font-weight-bold' }, [column?.value?.title]), ' column ?']), title: h('div', ['Do you want to delete ', h('span', { class: 'font-weight-bold' }, [column?.value?.title]), ' column ?']),
wrapClassName: 'nc-modal-column-delete',
okText: t('general.delete'), okText: t('general.delete'),
okType: 'danger', okType: 'danger',
cancelText: t('general.cancel'), cancelText: t('general.cancel'),

25
scripts/cypress/integration/common/5a_user_role.js

@ -102,7 +102,7 @@ export const genTest = (apiType, dbType) => {
disableTableAccess("CustomerList", "commenter"); disableTableAccess("CustomerList", "commenter");
disableTableAccess("CustomerList", "viewer"); disableTableAccess("CustomerList", "viewer");
cy.get("button.nc-acl-save").click({ force: true }); cy.get("button.nc-acl-save").click();
cy.toastWait("Updated UI ACL for tables successfully"); cy.toastWait("Updated UI ACL for tables successfully");
mainPage.closeMetaTab(); mainPage.closeMetaTab();
@ -110,13 +110,15 @@ export const genTest = (apiType, dbType) => {
}); });
const roleValidation = (roleType) => { const roleValidation = (roleType) => {
let clear;
describe(`User role validation`, () => { describe(`User role validation`, () => {
before(() => { before(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.visit(mainPage.roleURL[roleType]); cy.visit(mainPage.roleURL[roleType]);
cy.wait(5000); // cy.wait(5000);
cy.get('button:contains("SIGN UP")').should("exist"); cy.get('button:contains("SIGN UP"):visible').should("exist");
cy.get('input[type="text"]', { timeout: 20000 }).type( cy.get('input[type="text"]', { timeout: 20000 }).type(
roles[roleType].credentials.username roles[roleType].credentials.username
); );
@ -125,11 +127,11 @@ export const genTest = (apiType, dbType) => {
); );
cy.get('button:contains("SIGN UP")').click(); cy.get('button:contains("SIGN UP")').click();
cy.wait(3000); // cy.wait(3000);
cy.get(".nc-project-page-title") cy.get(`.nc-project-page-title:contains("My Projects"):visible`).should(
.contains("My Projects") "exist"
.should("be.visible"); );
if (dbType === "xcdb") { if (dbType === "xcdb") {
if ("rest" == apiType) if ("rest" == apiType)
@ -149,12 +151,15 @@ export const genTest = (apiType, dbType) => {
if (roleType === "creator") { if (roleType === "creator") {
// kludge: wait for page load to finish // kludge: wait for page load to finish
// close team & auth tab // close team & auth tab
cy.wait(2000); cy.wait(500);
cy.get("button.ant-tabs-tab-remove").should("exist").click(); cy.get("button.ant-tabs-tab-remove").should("exist").click();
cy.wait(1000); cy.wait(500);
} }
cy.saveLocalStorage(); cy.saveLocalStorage();
clear = Cypress.LocalStorage.clear;
Cypress.LocalStorage.clear = () => {};
}); });
beforeEach(() => { beforeEach(() => {
@ -169,6 +174,8 @@ export const genTest = (apiType, dbType) => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.signOut(); cy.signOut();
cy.saveLocalStorage(); cy.saveLocalStorage();
Cypress.LocalStorage.clear = clear;
}); });
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////

14
scripts/cypress/integration/common/6f_attachments.js

@ -27,15 +27,12 @@ export const genTest = (apiType, dbType) => {
// clean up newly added rows into Country table operations // clean up newly added rows into Country table operations
// this auto verifies successfull addition of rows to table as well // this auto verifies successfull addition of rows to table as well
mainPage.getPagination(5).click(); mainPage.getPagination(5).click();
// kludge: flicker on load
cy.wait(3000);
// wait for page rendering to complete // wait for page rendering to complete
cy.get(".nc-grid-row").should("have.length", 10); cy.get(".nc-grid-row").should("have.length", 10);
// mainPage
// .getRow(10) // kludge: flicker on load
// .find(".mdi-checkbox-blank-outline") // cy.wait(3000);
// .click({ force: true });
mainPage.getCell("Country", 10).rightclick(); mainPage.getCell("Country", 10).rightclick();
cy.getActiveMenu(".nc-dropdown-grid-context-menu") cy.getActiveMenu(".nc-dropdown-grid-context-menu")
@ -129,12 +126,7 @@ export const genTest = (apiType, dbType) => {
it(`Filter column which contain only attachments, download CSV`, () => { it(`Filter column which contain only attachments, download CSV`, () => {
// come back to main window // come back to main window
loginPage.loginAndOpenProject(apiType, dbType); loginPage.loginAndOpenProject(apiType, dbType);
// cy.visit('/')
// cy.wait(5000)
// projectsPage.openConfiguredProject(apiType, dbType);
cy.openTableTab("Country", 25); cy.openTableTab("Country", 25);
// cy.wait(1000);
mainPage.filterField("testAttach", "is not null", null); mainPage.filterField("testAttach", "is not null", null);
mainPage.hideField("LastUpdate"); mainPage.hideField("LastUpdate");

5
scripts/cypress/integration/common/6g_base_share.js

@ -21,12 +21,15 @@ export const genTest = (apiType, dbType) => {
const permissionValidation = (roleType) => { const permissionValidation = (roleType) => {
it(`${roleType}: Visit base shared URL`, () => { it(`${roleType}: Visit base shared URL`, () => {
cy.log(linkText); cy.log(linkText);
// http://localhost:8080/api/v1/db/meta/projects/p_4ufoizgrorwyey/tables?includeM2M=false
cy.intercept("/api/v1/db/meta/projects/**").as("waitForPageLoad");
// visit URL & wait for page load to complete // visit URL & wait for page load to complete
cy.visit(linkText, { cy.visit(linkText, {
baseUrl: null, baseUrl: null,
}); });
cy.wait(5000); cy.wait(["@waitForPageLoad"]);
// cy.wait(5000);
}); });
it(`${roleType}: Validate access permissions: advance menu`, () => { it(`${roleType}: Validate access permissions: advance menu`, () => {

12
scripts/cypress/integration/common/7a_create_project_from_excel.js

@ -87,12 +87,12 @@ export const genTest = (apiType, dbType) => {
sheetData = rows; sheetData = rows;
}); });
cy.visit("/"); // cy.visit("/");
projectsPage.createProject( projectsPage.createProject(
{ dbType: "none", apiType: "REST", name: "importSample" }, { dbType: "none", apiType: "REST", name: "importSample" },
{} {}
); );
cy.wait(4000); // cy.wait(4000);
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
@ -122,6 +122,11 @@ export const genTest = (apiType, dbType) => {
}); });
it("File Upload: Verify pre-load template page", () => { it("File Upload: Verify pre-load template page", () => {
// http://localhost:8080/api/v1/db/meta/audits/comments/count?ids[]=1&ids[]=2&fk_model_id=md_fq1vxy2181bzp0
cy.intercept("/api/v1/db/meta/audits/comments/count*").as(
"waitForPageLoad"
);
cy.getActiveModal() cy.getActiveModal()
.find(".ant-collapse-item") .find(".ant-collapse-item")
.then((sheets) => { .then((sheets) => {
@ -171,7 +176,8 @@ export const genTest = (apiType, dbType) => {
cy.getActiveModal().find(".ant-btn-primary").click(); cy.getActiveModal().find(".ant-btn-primary").click();
// wait for page to get loaded (issue observed in CI-CD) // wait for page to get loaded (issue observed in CI-CD)
cy.wait(5000); // cy.wait(5000);
cy.wait("@waitForPageLoad");
}); });
it("File Upload: Verify loaded data", () => { it("File Upload: Verify loaded data", () => {

10
scripts/cypress/integration/common/8a_webhook.js

@ -116,7 +116,7 @@ function configureWebhook(hook, test) {
.contains(new RegExp("^" + hook.condition.column + "$", "g")) .contains(new RegExp("^" + hook.condition.column + "$", "g"))
.should("exist") .should("exist")
.click(); .click();
cy.wait(1000); // cy.wait(1000);
cy.get(".nc-filter-operation-select").should("exist").last().click(); cy.get(".nc-filter-operation-select").should("exist").last().click();
cy.get(".ant-select-dropdown:visible") cy.get(".ant-select-dropdown:visible")
@ -162,8 +162,11 @@ function clearServerData() {
function addNewRow(index, cellValue) { function addNewRow(index, cellValue) {
cy.get(".nc-add-new-row-btn:visible").should("exist"); cy.get(".nc-add-new-row-btn:visible").should("exist");
cy.get(".nc-add-new-row-btn").click(); cy.get(".nc-add-new-row-btn").click();
cy.wait(1000);
// cy.wait(1000);
cy.get(".nc-expand-col-Title") cy.get(".nc-expand-col-Title")
.should("exist")
.find(".nc-cell > input") .find(".nc-cell > input")
.first() .first()
.type(cellValue); .type(cellValue);
@ -185,6 +188,7 @@ function updateRow(index, cellValue) {
.click({ force: true }); .click({ force: true });
cy.get(".nc-expand-col-Title") cy.get(".nc-expand-col-Title")
.should("exist")
.find(".nc-cell > input") .find(".nc-cell > input")
.should("exist") .should("exist")
.first() .first()
@ -207,7 +211,7 @@ function updateRow(index, cellValue) {
function verifyHookTrigger(count, lastValue) { function verifyHookTrigger(count, lastValue) {
// allow message to be received // allow message to be received
cy.wait(500); cy.wait(100);
cy.request("http://localhost:9090/hook/count").then((msg) => { cy.request("http://localhost:9090/hook/count").then((msg) => {
cy.log(msg.body); cy.log(msg.body);

7
scripts/cypress/integration/common/9a_QuickTest.js

@ -89,6 +89,8 @@ function verifyWebhook(config) {
} }
export const genTest = (apiType, dbType, testMode) => { export const genTest = (apiType, dbType, testMode) => {
let clear;
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`Quick Tests`, () => { describe(`Quick Tests`, () => {
let cellIdx = 1; let cellIdx = 1;
@ -115,6 +117,9 @@ export const genTest = (apiType, dbType, testMode) => {
cy.openTableTab("Film", 3); cy.openTableTab("Film", 3);
cy.saveLocalStorage(); cy.saveLocalStorage();
clear = Cypress.LocalStorage.clear;
Cypress.LocalStorage.clear = () => {};
}); });
beforeEach(() => { beforeEach(() => {
@ -129,6 +134,8 @@ export const genTest = (apiType, dbType, testMode) => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.signOut(); cy.signOut();
cy.saveLocalStorage(); cy.saveLocalStorage();
Cypress.LocalStorage.clear = clear;
}); });
it("Verify Schema", () => { it("Verify Schema", () => {

4
scripts/cypress/integration/spec/roleValidation.spec.js

@ -203,7 +203,7 @@ export function _editComment(roleType, mode) {
cy.openTableTab(columnName, 25); cy.openTableTab(columnName, 25);
cy.wait(1000); // cy.wait(1000);
// click on comment icon & type comment // click on comment icon & type comment
// //
@ -214,7 +214,7 @@ export function _editComment(roleType, mode) {
// Everyone else: Comment added/read successfully // Everyone else: Comment added/read successfully
// //
cy.wait(3000); // cy.wait(3000);
if ("viewer" === roleType) { if ("viewer" === roleType) {
cy.getActiveDrawer(".nc-drawer-expanded-form") cy.getActiveDrawer(".nc-drawer-expanded-form")

9
scripts/cypress/support/commands.js

@ -173,7 +173,7 @@ Cypress.Commands.add("closeTableTab", (tn) => {
.click(); .click();
// subsequent tab open commands will fail if tab is not closed completely // subsequent tab open commands will fail if tab is not closed completely
cy.wait(1000); cy.wait(100);
}); });
Cypress.Commands.add("openOrCreateGqlProject", (_args) => { Cypress.Commands.add("openOrCreateGqlProject", (_args) => {
@ -486,6 +486,13 @@ Cypress.Commands.add("signOut", () => {
cy.get('button:contains("SIGN IN")').should("exist"); cy.get('button:contains("SIGN IN")').should("exist");
}); });
// Navigation
//
Cypress.Commands.add("gotoProjectsPage", () => {
cy.get(".nc-noco-brand-icon").should("exist").click();
cy.get(`.nc-project-page-title:contains("My Projects")`).should("exist");
});
// Drag n Drop // Drag n Drop
// refer: https://stackoverflow.com/a/55409853 // refer: https://stackoverflow.com/a/55409853
/* /*

20
scripts/cypress/support/page_objects/mainPage.js

@ -256,13 +256,21 @@ export class _mainPage {
.trigger("mouseover", { force: true }) .trigger("mouseover", { force: true })
.click({ force: true }); .click({ force: true });
cy.wait(500); // cy.wait(500);
// cy.get(".nc-column-delete").click();
cy.getActiveMenu(".nc-dropdown-column-operations")
.find(".nc-column-delete")
.click();
// cy.wait(500);
// cy.get(".nc-column-delete").should("not.be.visible");
// cy.get(".ant-btn-dangerous:visible").contains("Delete").click();
// cy.wait(500);
cy.get(".nc-column-delete").click(); cy.getActiveModal(".nc-modal-column-delete")
cy.wait(500); .find(".ant-btn-dangerous:visible")
cy.get(".nc-column-delete").should("not.be.visible"); .contains("Delete")
cy.get(".ant-btn-dangerous:visible").contains("Delete").click(); .click();
cy.wait(500);
cy.get(`th:contains(${colName})`).should("not.exist"); cy.get(`th:contains(${colName})`).should("not.exist");
}; };

Loading…
Cancel
Save