|
|
@ -24,141 +24,125 @@ |
|
|
|
// -- This will overwrite an existing command --
|
|
|
|
// -- This will overwrite an existing command --
|
|
|
|
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
|
|
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
|
|
|
|
|
|
|
|
|
|
import 'cypress-file-upload'; |
|
|
|
import "cypress-file-upload"; |
|
|
|
import { isXcdb, isPostgres } from './page_objects/projectConstants'; |
|
|
|
import { isXcdb, isPostgres } from "./page_objects/projectConstants"; |
|
|
|
|
|
|
|
|
|
|
|
require('@4tw/cypress-drag-drop'); |
|
|
|
require("@4tw/cypress-drag-drop"); |
|
|
|
|
|
|
|
|
|
|
|
// for waiting until page load
|
|
|
|
// for waiting until page load
|
|
|
|
Cypress.Commands.add('waitForSpinners', () => { |
|
|
|
Cypress.Commands.add("waitForSpinners", () => { |
|
|
|
cy.visit('http://localhost:3000/signup', { |
|
|
|
cy.visit("http://localhost:3000/signup", { |
|
|
|
retryOnNetworkFailure: true, |
|
|
|
retryOnNetworkFailure: true, |
|
|
|
timeout: 1200000, |
|
|
|
timeout: 1200000, |
|
|
|
headers: { |
|
|
|
headers: { |
|
|
|
'Accept-Encoding': 'gzip, deflate', |
|
|
|
"Accept-Encoding": "gzip, deflate", |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
cy.get('.nc-form-signup').should('exist'); |
|
|
|
cy.get(".nc-form-signup").should("exist"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('signinOrSignup', (_args) => { |
|
|
|
Cypress.Commands.add("signinOrSignup", (_args) => { |
|
|
|
const args = Object.assign( |
|
|
|
const args = Object.assign( |
|
|
|
{ username: 'user@nocodb.com', password: 'Password123.' }, |
|
|
|
{ username: "user@nocodb.com", password: "Password123." }, |
|
|
|
_args |
|
|
|
_args |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
cy.wait(1000); |
|
|
|
cy.wait(1000); |
|
|
|
|
|
|
|
|
|
|
|
// signin/signup
|
|
|
|
// signin/signup
|
|
|
|
cy.get('body').then(($body) => { |
|
|
|
cy.get("body").then(($body) => { |
|
|
|
// cy.wait(1000)
|
|
|
|
// cy.wait(1000)
|
|
|
|
cy.url().then((url) => { |
|
|
|
cy.url().then((url) => { |
|
|
|
if (!url.includes('/projects')) { |
|
|
|
if (!url.includes("/projects")) { |
|
|
|
// handle initial load
|
|
|
|
// handle initial load
|
|
|
|
if ($body.find('.welcome-page').length > 0) { |
|
|
|
if ($body.find(".welcome-page").length > 0) { |
|
|
|
cy.wait(8000); |
|
|
|
cy.wait(8000); |
|
|
|
cy.get('body').trigger('mousemove'); |
|
|
|
cy.get("body").trigger("mousemove"); |
|
|
|
cy.snip('LetsBegin'); |
|
|
|
cy.snip("LetsBegin"); |
|
|
|
cy.contains('Let\'s Begin').click(); |
|
|
|
cy.contains("Let's Begin").click(); |
|
|
|
cy.get('input[type="text"]', { timeout: 12000 }).type( |
|
|
|
cy.get('input[type="text"]', { timeout: 12000 }).type(args.username); |
|
|
|
args.username |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
cy.get('input[type="password"]').type(args.password); |
|
|
|
cy.get('input[type="password"]').type(args.password); |
|
|
|
cy.snip('SignUp'); |
|
|
|
cy.snip("SignUp"); |
|
|
|
cy.get('button:contains("SIGN UP")').click(); |
|
|
|
cy.get('button:contains("SIGN UP")').click(); |
|
|
|
|
|
|
|
|
|
|
|
// handle signin
|
|
|
|
// handle signin
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
cy.get('input[type="text"]', { timeout: 12000 }).type( |
|
|
|
cy.get('input[type="text"]', { timeout: 12000 }).type(args.username); |
|
|
|
args.username |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
cy.get('input[type="password"]').type(args.password); |
|
|
|
cy.get('input[type="password"]').type(args.password); |
|
|
|
cy.snip('SignIn'); |
|
|
|
cy.snip("SignIn"); |
|
|
|
cy.get('button:contains("SIGN IN")').click(); |
|
|
|
cy.get('button:contains("SIGN IN")').click(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (url.includes('/signin')) { |
|
|
|
} else if (url.includes("/signin")) { |
|
|
|
cy.get('input[type="text"]', { timeout: 12000 }).type( |
|
|
|
cy.get('input[type="text"]', { timeout: 12000 }).type(args.username); |
|
|
|
args.username |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
cy.get('input[type="password"]').type(args.password); |
|
|
|
cy.get('input[type="password"]').type(args.password); |
|
|
|
cy.snip('SignIn'); |
|
|
|
cy.snip("SignIn"); |
|
|
|
cy.get('button:contains("SIGN IN")').click(); |
|
|
|
cy.get('button:contains("SIGN IN")').click(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// indicates page-load complete
|
|
|
|
// indicates page-load complete
|
|
|
|
cy.get('.nc-noco-brand-icon', { timeout: 12000 }).should('exist'); |
|
|
|
cy.get(".nc-noco-brand-icon", { timeout: 12000 }).should("exist"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// for opening/creating a rest project
|
|
|
|
// for opening/creating a rest project
|
|
|
|
Cypress.Commands.add('openOrCreateRestProject', (_args) => { |
|
|
|
Cypress.Commands.add("openOrCreateRestProject", (_args) => { |
|
|
|
const args = Object.assign({ new: false }, _args); |
|
|
|
const args = Object.assign({ new: false }, _args); |
|
|
|
|
|
|
|
|
|
|
|
// signin/signup
|
|
|
|
// signin/signup
|
|
|
|
cy.signinOrSignup(); |
|
|
|
cy.signinOrSignup(); |
|
|
|
cy.get('.nc-new-project-menu').should('exist'); |
|
|
|
cy.get(".nc-new-project-menu").should("exist"); |
|
|
|
cy.snip('ProjectPage'); |
|
|
|
cy.snip("ProjectPage"); |
|
|
|
cy.get('body').then(($body) => { |
|
|
|
cy.get("body").then(($body) => { |
|
|
|
const filter = args.meta |
|
|
|
const filter = args.meta |
|
|
|
? '.nc-meta-project-row' |
|
|
|
? ".nc-meta-project-row" |
|
|
|
: ':not(.nc-meta-project-row)'; |
|
|
|
: ":not(.nc-meta-project-row)"; |
|
|
|
// if project exist open
|
|
|
|
// if project exist open
|
|
|
|
if ( |
|
|
|
if ($body.find(".nc-rest-project-row").filter(filter).length && !args.new) { |
|
|
|
$body.find('.nc-rest-project-row').filter(filter).length && |
|
|
|
cy.get(".nc-rest-project-row").filter(filter).first().click(); |
|
|
|
!args.new |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
cy.get('.nc-rest-project-row').filter(filter).first().click(); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
cy.contains('New Project') |
|
|
|
cy.contains("New Project").trigger("onmouseover").trigger("mouseenter"); |
|
|
|
.trigger('onmouseover') |
|
|
|
|
|
|
|
.trigger('mouseenter'); |
|
|
|
|
|
|
|
if (args.meta) { |
|
|
|
if (args.meta) { |
|
|
|
cy.get('.nc-create-xc-db-project').click(); |
|
|
|
cy.get(".nc-create-xc-db-project").click(); |
|
|
|
cy.url({ timeout: 6000 }).should('contain', '#/project/xcdb'); |
|
|
|
cy.url({ timeout: 6000 }).should("contain", "#/project/xcdb"); |
|
|
|
cy.get('.nc-metadb-project-name').type( |
|
|
|
cy.get(".nc-metadb-project-name").type("test_proj" + Date.now()); |
|
|
|
'test_proj' + Date.now() |
|
|
|
cy.contains("button", "Create", { timeout: 3000 }).click(); |
|
|
|
); |
|
|
|
|
|
|
|
cy.contains('button', 'Create', { timeout: 3000 }).click(); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
cy.get('.nc-create-external-db-project').click(); |
|
|
|
cy.get(".nc-create-external-db-project").click(); |
|
|
|
cy.url({ timeout: 6000 }).should('contain', '#/project'); |
|
|
|
cy.url({ timeout: 6000 }).should("contain", "#/project"); |
|
|
|
cy.get('.database-field input').click().clear().type('sakila'); |
|
|
|
cy.get(".database-field input").click().clear().type("sakila"); |
|
|
|
cy.contains('Test Database Connection').click(); |
|
|
|
cy.contains("Test Database Connection").click(); |
|
|
|
cy.contains('Ok & Save Project', { timeout: 3000 }).click(); |
|
|
|
cy.contains("Ok & Save Project", { timeout: 3000 }).click(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
cy.url({ timeout: 20000 }).should('contain', '#/nc/'); |
|
|
|
cy.url({ timeout: 20000 }).should("contain", "#/nc/"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('refreshTableTab', () => { |
|
|
|
Cypress.Commands.add("refreshTableTab", () => { |
|
|
|
cy.task('log', `[refreshTableTab]`); |
|
|
|
cy.task("log", `[refreshTableTab]`); |
|
|
|
|
|
|
|
|
|
|
|
cy.get('.nc-project-tree') |
|
|
|
cy.get(".nc-project-tree") |
|
|
|
.find('.v-list-item__title:contains(Tables)', { timeout: 10000 }) |
|
|
|
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 }) |
|
|
|
.should('exist') |
|
|
|
.should("exist") |
|
|
|
.first() |
|
|
|
.first() |
|
|
|
.rightclick({ force: true }); |
|
|
|
.rightclick({ force: true }); |
|
|
|
|
|
|
|
|
|
|
|
cy.getActiveMenu('.nc-dropdown-tree-view-context-menu') |
|
|
|
cy.getActiveMenu(".nc-dropdown-tree-view-context-menu") |
|
|
|
.find('[role="menuitem"]') |
|
|
|
.find('[role="menuitem"]') |
|
|
|
.contains('Tables Refresh') |
|
|
|
.contains("Tables Refresh") |
|
|
|
.should('exist') |
|
|
|
.should("exist") |
|
|
|
.click({ force: true }); |
|
|
|
.click({ force: true }); |
|
|
|
|
|
|
|
|
|
|
|
cy.toastWait('Tables refreshed'); |
|
|
|
cy.toastWait("Tables refreshed"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// tn: table name
|
|
|
|
// tn: table name
|
|
|
|
// rc: row count. validate row count if rc!=0
|
|
|
|
// rc: row count. validate row count if rc!=0
|
|
|
|
Cypress.Commands.add('openTableTab', (tn, rc) => { |
|
|
|
Cypress.Commands.add("openTableTab", (tn, rc) => { |
|
|
|
cy.task('log', `[openTableTab] ${tn} ${rc}`); |
|
|
|
cy.task("log", `[openTableTab] ${tn} ${rc}`); |
|
|
|
|
|
|
|
|
|
|
|
cy.get(`.nc-project-tree-tbl-${tn}`) |
|
|
|
cy.get(`.nc-project-tree-tbl-${tn}`).should("exist").first().click(); |
|
|
|
.should('exist') |
|
|
|
|
|
|
|
.first() |
|
|
|
|
|
|
|
.click(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// kludge to make new tab active
|
|
|
|
// kludge to make new tab active
|
|
|
|
// cy.get('.ant-tabs-tab-btn')
|
|
|
|
// cy.get('.ant-tabs-tab-btn')
|
|
|
@ -167,74 +151,70 @@ Cypress.Commands.add('openTableTab', (tn, rc) => { |
|
|
|
// .click();
|
|
|
|
// .click();
|
|
|
|
cy.wait(3000); |
|
|
|
cy.wait(3000); |
|
|
|
|
|
|
|
|
|
|
|
cy.get('.xc-row-table.nc-grid').should('exist'); |
|
|
|
cy.get(".xc-row-table.nc-grid").should("exist"); |
|
|
|
|
|
|
|
|
|
|
|
// wait for page rendering to complete
|
|
|
|
// wait for page rendering to complete
|
|
|
|
if (rc != 0) { |
|
|
|
if (rc != 0) { |
|
|
|
cy.get('.nc-grid-row').should('have.length', rc); |
|
|
|
cy.get(".nc-grid-row").should("have.length", rc); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('closeTableTab', (tn) => { |
|
|
|
Cypress.Commands.add("closeTableTab", (tn) => { |
|
|
|
cy.task('log', `[closeTableTab] ${tn}`); |
|
|
|
cy.task("log", `[closeTableTab] ${tn}`); |
|
|
|
cy.get('.ant-tabs-tab-btn') |
|
|
|
cy.get(".ant-tabs-tab-btn") |
|
|
|
.contains(tn) |
|
|
|
.contains(tn) |
|
|
|
.should('exist') |
|
|
|
.should("exist") |
|
|
|
.parent() |
|
|
|
.parent() |
|
|
|
.parent() |
|
|
|
.parent() |
|
|
|
.parent() |
|
|
|
.parent() |
|
|
|
.find('button') |
|
|
|
.find("button") |
|
|
|
.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(1000); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('openOrCreateGqlProject', (_args) => { |
|
|
|
Cypress.Commands.add("openOrCreateGqlProject", (_args) => { |
|
|
|
const args = Object.assign({ new: false, meta: false }, _args); |
|
|
|
const args = Object.assign({ new: false, meta: false }, _args); |
|
|
|
|
|
|
|
|
|
|
|
cy.signinOrSignup(); |
|
|
|
cy.signinOrSignup(); |
|
|
|
|
|
|
|
|
|
|
|
cy.get('.nc-new-project-menu').should('exist'); |
|
|
|
cy.get(".nc-new-project-menu").should("exist"); |
|
|
|
cy.get('body').then(($body) => { |
|
|
|
cy.get("body").then(($body) => { |
|
|
|
const filter = args.meta |
|
|
|
const filter = args.meta |
|
|
|
? '.nc-meta-project-row' |
|
|
|
? ".nc-meta-project-row" |
|
|
|
: ':not(.nc-meta-project-row)'; |
|
|
|
: ":not(.nc-meta-project-row)"; |
|
|
|
// if project exist open
|
|
|
|
// if project exist open
|
|
|
|
if ( |
|
|
|
if ( |
|
|
|
$body.find('.nc-graphql-project-row').filter(filter).length && |
|
|
|
$body.find(".nc-graphql-project-row").filter(filter).length && |
|
|
|
!args.new |
|
|
|
!args.new |
|
|
|
) { |
|
|
|
) { |
|
|
|
cy.get('.nc-graphql-project-row').filter(filter).first().click(); |
|
|
|
cy.get(".nc-graphql-project-row").filter(filter).first().click(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
cy.contains('New Project') |
|
|
|
cy.contains("New Project").trigger("onmouseover").trigger("mouseenter"); |
|
|
|
.trigger('onmouseover') |
|
|
|
|
|
|
|
.trigger('mouseenter'); |
|
|
|
|
|
|
|
if (args.meta) { |
|
|
|
if (args.meta) { |
|
|
|
cy.get('.nc-create-xc-db-project').click(); |
|
|
|
cy.get(".nc-create-xc-db-project").click(); |
|
|
|
cy.url({ timeout: 6000 }).should('contain', '#/project/xcdb'); |
|
|
|
cy.url({ timeout: 6000 }).should("contain", "#/project/xcdb"); |
|
|
|
cy.contains('GRAPHQL APIs').closest('label').click(); |
|
|
|
cy.contains("GRAPHQL APIs").closest("label").click(); |
|
|
|
cy.get('.nc-metadb-project-name').type( |
|
|
|
cy.get(".nc-metadb-project-name").type("test_proj" + Date.now()); |
|
|
|
'test_proj' + Date.now() |
|
|
|
cy.contains("button", "Create", { timeout: 3000 }).click(); |
|
|
|
); |
|
|
|
|
|
|
|
cy.contains('button', 'Create', { timeout: 3000 }).click(); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
cy.get('.nc-create-external-db-project').click(); |
|
|
|
cy.get(".nc-create-external-db-project").click(); |
|
|
|
cy.url({ timeout: 6000 }).should('contain', '#/project'); |
|
|
|
cy.url({ timeout: 6000 }).should("contain", "#/project"); |
|
|
|
cy.contains('GRAPHQL APIs').closest('label').click(); |
|
|
|
cy.contains("GRAPHQL APIs").closest("label").click(); |
|
|
|
cy.get('.database-field input').click().clear().type('sakila'); |
|
|
|
cy.get(".database-field input").click().clear().type("sakila"); |
|
|
|
cy.contains('Test Database Connection').click(); |
|
|
|
cy.contains("Test Database Connection").click(); |
|
|
|
cy.contains('Ok & Save Project').should('exist').click(); |
|
|
|
cy.contains("Ok & Save Project").should("exist").click(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
cy.url({ timeout: 20000 }).should('contain', '#/nc/'); |
|
|
|
cy.url({ timeout: 20000 }).should("contain", "#/nc/"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
let LOCAL_STORAGE_MEMORY = {}; |
|
|
|
let LOCAL_STORAGE_MEMORY = {}; |
|
|
|
let LOCAL_STORAGE_MEMORY_v2 = {}; |
|
|
|
let LOCAL_STORAGE_MEMORY_v2 = {}; |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('saveLocalStorage', (name) => { |
|
|
|
Cypress.Commands.add("saveLocalStorage", (name) => { |
|
|
|
LOCAL_STORAGE_MEMORY = {}; |
|
|
|
LOCAL_STORAGE_MEMORY = {}; |
|
|
|
Object.keys(localStorage).forEach((key) => { |
|
|
|
Object.keys(localStorage).forEach((key) => { |
|
|
|
LOCAL_STORAGE_MEMORY[key] = localStorage[key]; |
|
|
|
LOCAL_STORAGE_MEMORY[key] = localStorage[key]; |
|
|
@ -250,109 +230,119 @@ const restoreLocalStorage = () => { |
|
|
|
cy.printLocalStorage(); |
|
|
|
cy.printLocalStorage(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('restoreLocalStorage', restoreLocalStorage); |
|
|
|
Cypress.Commands.add("restoreLocalStorage", restoreLocalStorage); |
|
|
|
Cypress.on('window:before:load', restoreLocalStorage); |
|
|
|
// Cypress.on("window:before:load", restoreLocalStorage);
|
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('deleteLocalStorage', () => { |
|
|
|
Cypress.Commands.add("deleteLocalStorage", () => { |
|
|
|
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => { |
|
|
|
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => { |
|
|
|
localStorage.removeItem(key); |
|
|
|
localStorage.removeItem(key); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('printLocalStorage', () => { |
|
|
|
Cypress.Commands.add("printLocalStorage", () => { |
|
|
|
cy.task('log', `[printLocalStorage]`); |
|
|
|
// cy.task('log', `[printLocalStorage]`);
|
|
|
|
cy.task('log', JSON.stringify(localStorage, null, 2)); |
|
|
|
// cy.task('log', JSON.stringify(localStorage, null, 2));
|
|
|
|
cy.task('log', JSON.stringify(LOCAL_STORAGE_MEMORY, null, 2)); |
|
|
|
// cy.task('log', JSON.stringify(LOCAL_STORAGE_MEMORY, null, 2));
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('getActiveModal', (wrapperSelector) => { |
|
|
|
Cypress.Commands.add("getActiveModal", (wrapperSelector) => { |
|
|
|
if (wrapperSelector) { |
|
|
|
if (wrapperSelector) { |
|
|
|
return cy.get(`${wrapperSelector} .ant-modal-content:visible`).last(); |
|
|
|
return cy.get(`${wrapperSelector} .ant-modal-content:visible`).last(); |
|
|
|
} |
|
|
|
} |
|
|
|
return cy.get('.ant-modal-content:visible').last(); |
|
|
|
return cy.get(".ant-modal-content:visible").last(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('getActiveMenu', (overlaySelector) => { |
|
|
|
Cypress.Commands.add("getActiveMenu", (overlaySelector) => { |
|
|
|
if (overlaySelector) { |
|
|
|
if (overlaySelector) { |
|
|
|
return cy.get(`${overlaySelector} .ant-dropdown-content:visible`); |
|
|
|
return cy.get(`${overlaySelector} .ant-dropdown-content:visible`); |
|
|
|
} |
|
|
|
} |
|
|
|
return cy.get('.ant-dropdown-content:visible').last(); |
|
|
|
return cy.get(".ant-dropdown-content:visible").last(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('getActivePopUp', () => { |
|
|
|
Cypress.Commands.add("getActivePopUp", () => { |
|
|
|
return cy.get('.ant-menu-submenu-popup:visible').last(); |
|
|
|
return cy.get(".ant-menu-submenu-popup:visible").last(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('getActiveSelection', (selector) => { |
|
|
|
Cypress.Commands.add("getActiveSelection", (selector) => { |
|
|
|
if (selector) { |
|
|
|
if (selector) { |
|
|
|
return cy.get(`${selector}.ant-select-dropdown:visible`).last(); |
|
|
|
return cy.get(`${selector}.ant-select-dropdown:visible`).last(); |
|
|
|
} |
|
|
|
} |
|
|
|
return cy.get('.ant-select-dropdown:visible').last(); |
|
|
|
return cy.get(".ant-select-dropdown:visible").last(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('getActiveDrawer', (selector) => { |
|
|
|
Cypress.Commands.add("getActiveDrawer", (selector) => { |
|
|
|
if (selector) { |
|
|
|
if (selector) { |
|
|
|
return cy.get(`${selector} .ant-drawer-content:visible`).last(); |
|
|
|
return cy.get(`${selector} .ant-drawer-content:visible`).last(); |
|
|
|
} |
|
|
|
} |
|
|
|
return cy.get('.ant-drawer-content:visible').last(); |
|
|
|
return cy.get(".ant-drawer-content:visible").last(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('getActivePicker', (dropdownSelector) => { |
|
|
|
Cypress.Commands.add("getActivePicker", (dropdownSelector) => { |
|
|
|
if (dropdownSelector) { |
|
|
|
if (dropdownSelector) { |
|
|
|
return cy.get(`${dropdownSelector}.ant-drawer-content:visible`).last(); |
|
|
|
return cy.get(`${dropdownSelector}.ant-drawer-content:visible`).last(); |
|
|
|
} |
|
|
|
} |
|
|
|
return cy.get('.ant-picker-dropdown :visible').last(); |
|
|
|
return cy.get(".ant-picker-dropdown :visible").last(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('createTable', (name) => { |
|
|
|
Cypress.Commands.add("createTable", (name) => { |
|
|
|
cy.task('log', `[createTableTab] ${name}`); |
|
|
|
cy.task("log", `[createTableTab] ${name}`); |
|
|
|
cy.wait(1000); |
|
|
|
cy.wait(1000); |
|
|
|
cy.get('.nc-add-new-table').should('exist').click(); |
|
|
|
cy.get(".nc-add-new-table").should("exist").click(); |
|
|
|
cy.wait(1000); |
|
|
|
cy.wait(1000); |
|
|
|
cy.getActiveModal('.nc-modal-table-create').find(`input[type="text"]:visible`) |
|
|
|
cy.getActiveModal(".nc-modal-table-create") |
|
|
|
|
|
|
|
.find(`input[type="text"]:visible`) |
|
|
|
.click() |
|
|
|
.click() |
|
|
|
.clear() |
|
|
|
.clear() |
|
|
|
.type(name); |
|
|
|
.type(name); |
|
|
|
// submit button
|
|
|
|
// submit button
|
|
|
|
cy.getActiveModal('.nc-modal-table-create').find('button.ant-btn-primary:visible').click(); |
|
|
|
cy.getActiveModal(".nc-modal-table-create") |
|
|
|
|
|
|
|
.find("button.ant-btn-primary:visible") |
|
|
|
|
|
|
|
.click(); |
|
|
|
cy.wait(1000); |
|
|
|
cy.wait(1000); |
|
|
|
cy.get('.xc-row-table.nc-grid').should('exist'); |
|
|
|
cy.get(".xc-row-table.nc-grid").should("exist"); |
|
|
|
// cy.get('.ant-tabs-tab-active > .ant-tabs-tab-btn').contains(name).should("exist");
|
|
|
|
// cy.get('.ant-tabs-tab-active > .ant-tabs-tab-btn').contains(name).should("exist");
|
|
|
|
cy.url().should('contain', `table/${name}`); |
|
|
|
cy.url().should("contain", `table/${name}`); |
|
|
|
cy.get(`.nc-project-tree-tbl-${name}`).should('exist'); |
|
|
|
cy.get(`.nc-project-tree-tbl-${name}`).should("exist"); |
|
|
|
cy.wait(1000); |
|
|
|
cy.wait(1000); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('deleteTable', (name, dbType) => { |
|
|
|
Cypress.Commands.add("deleteTable", (name, dbType) => { |
|
|
|
cy.get(`.nc-project-tree-tbl-${name}`).should('exist').rightclick(); |
|
|
|
cy.get(`.nc-project-tree-tbl-${name}`).should("exist").rightclick(); |
|
|
|
cy.getActiveMenu('.nc-dropdown-tree-view-context-menu').find('[role="menuitem"]').contains('Delete').click(); |
|
|
|
cy.getActiveMenu(".nc-dropdown-tree-view-context-menu") |
|
|
|
cy.getActiveModal().find('button').contains('Yes').click(); |
|
|
|
.find('[role="menuitem"]') |
|
|
|
|
|
|
|
.contains("Delete") |
|
|
|
|
|
|
|
.click(); |
|
|
|
|
|
|
|
cy.getActiveModal().find("button").contains("Yes").click(); |
|
|
|
|
|
|
|
|
|
|
|
cy.toastWait(`Deleted table successfully`); |
|
|
|
cy.toastWait(`Deleted table successfully`); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('renameTable', (oldName, newName) => { |
|
|
|
Cypress.Commands.add("renameTable", (oldName, newName) => { |
|
|
|
|
|
|
|
|
|
|
|
// right click on project table name
|
|
|
|
// right click on project table name
|
|
|
|
cy.get(`.nc-project-tree-tbl-${oldName}`) |
|
|
|
cy.get(`.nc-project-tree-tbl-${oldName}`) |
|
|
|
.should('exist') |
|
|
|
.should("exist") |
|
|
|
.first() |
|
|
|
.first() |
|
|
|
.rightclick(); |
|
|
|
.rightclick(); |
|
|
|
|
|
|
|
|
|
|
|
// choose rename option from menu
|
|
|
|
// choose rename option from menu
|
|
|
|
cy.getActiveMenu('.nc-dropdown-tree-view-context-menu') |
|
|
|
cy.getActiveMenu(".nc-dropdown-tree-view-context-menu") |
|
|
|
.find('[role="menuitem"]') |
|
|
|
.find('[role="menuitem"]') |
|
|
|
.contains('Rename') |
|
|
|
.contains("Rename") |
|
|
|
.click({ force: true }); |
|
|
|
.click({ force: true }); |
|
|
|
|
|
|
|
|
|
|
|
// feed new name
|
|
|
|
// feed new name
|
|
|
|
cy.getActiveModal('.nc-modal-table-rename').find('input').clear().type(newName); |
|
|
|
cy.getActiveModal(".nc-modal-table-rename") |
|
|
|
|
|
|
|
.find("input") |
|
|
|
|
|
|
|
.clear() |
|
|
|
|
|
|
|
.type(newName); |
|
|
|
|
|
|
|
|
|
|
|
// submit
|
|
|
|
// submit
|
|
|
|
cy.getActiveModal('.nc-modal-table-rename').find('button').contains('Submit').click(); |
|
|
|
cy.getActiveModal(".nc-modal-table-rename") |
|
|
|
|
|
|
|
.find("button") |
|
|
|
cy.toastWait('Table renamed successfully'); |
|
|
|
.contains("Submit") |
|
|
|
|
|
|
|
.click(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cy.toastWait("Table renamed successfully"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Cypress.Commands.add('createColumn', (table, columnName) => {
|
|
|
|
// Cypress.Commands.add('createColumn', (table, columnName) => {
|
|
|
@ -376,43 +366,48 @@ Cypress.Commands.add('renameTable', (oldName, newName) => { |
|
|
|
// cy.get('th:contains(new_column)').should('exist');
|
|
|
|
// cy.get('th:contains(new_column)').should('exist');
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('toastWait', (msg) => { |
|
|
|
Cypress.Commands.add("toastWait", (msg) => { |
|
|
|
// cy.get('.ant-message-notice-content:visible', { timout: 30000 }).should('exist')
|
|
|
|
// cy.get('.ant-message-notice-content:visible', { timout: 30000 }).should('exist')
|
|
|
|
cy.get(`.ant-message-notice-content:visible:contains("${msg}")`, { timeout: 30000 }).should('exist'); |
|
|
|
cy.get(`.ant-message-notice-content:visible:contains("${msg}")`, { |
|
|
|
cy.get('.ant-message-notice-content:visible', { timeout: 12000 }).should('not.exist'); |
|
|
|
timeout: 30000, |
|
|
|
|
|
|
|
}).should("exist"); |
|
|
|
|
|
|
|
cy.get(".ant-message-notice-content:visible", { timeout: 12000 }).should( |
|
|
|
|
|
|
|
"not.exist" |
|
|
|
|
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// vn: view name
|
|
|
|
// vn: view name
|
|
|
|
// rc: expected row count. validate row count if rc!=0
|
|
|
|
// rc: expected row count. validate row count if rc!=0
|
|
|
|
Cypress.Commands.add('openViewsTab', (vn, rc) => { |
|
|
|
Cypress.Commands.add("openViewsTab", (vn, rc) => { |
|
|
|
cy.task('log', `[openViewsTab] ${vn} ${rc}`); |
|
|
|
cy.task("log", `[openViewsTab] ${vn} ${rc}`); |
|
|
|
|
|
|
|
|
|
|
|
cy.get(`.nc-project-tree-tbl-${vn}`, { timeout: 10000 }).should('exist') |
|
|
|
cy.get(`.nc-project-tree-tbl-${vn}`, { timeout: 10000 }) |
|
|
|
|
|
|
|
.should("exist") |
|
|
|
.first() |
|
|
|
.first() |
|
|
|
.click({ force: true }); |
|
|
|
.click({ force: true }); |
|
|
|
|
|
|
|
|
|
|
|
// kludge to make new tab active
|
|
|
|
// kludge to make new tab active
|
|
|
|
cy.get('.ant-tabs-tab-btn') |
|
|
|
cy.get(".ant-tabs-tab-btn") |
|
|
|
.contains(vn) |
|
|
|
.contains(vn) |
|
|
|
.should('exist') |
|
|
|
.should("exist") |
|
|
|
.click({ force: true }); |
|
|
|
.click({ force: true }); |
|
|
|
|
|
|
|
|
|
|
|
// wait for page rendering to complete
|
|
|
|
// wait for page rendering to complete
|
|
|
|
if (rc != 0) { |
|
|
|
if (rc != 0) { |
|
|
|
cy.get('.xc-row-table.nc-grid').should('exist'); |
|
|
|
cy.get(".xc-row-table.nc-grid").should("exist"); |
|
|
|
cy.get('.nc-grid-row').should('have.length', rc); |
|
|
|
cy.get(".nc-grid-row").should("have.length", rc); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('closeViewsTab', (vn) => { |
|
|
|
Cypress.Commands.add("closeViewsTab", (vn) => { |
|
|
|
cy.task('log', `[closeViewsTab] ${vn}`); |
|
|
|
cy.task("log", `[closeViewsTab] ${vn}`); |
|
|
|
cy.get('.ant-tabs-tab-btn') |
|
|
|
cy.get(".ant-tabs-tab-btn") |
|
|
|
.contains(vn) |
|
|
|
.contains(vn) |
|
|
|
.should('exist') |
|
|
|
.should("exist") |
|
|
|
.parent() |
|
|
|
.parent() |
|
|
|
.parent() |
|
|
|
.parent() |
|
|
|
.parent() |
|
|
|
.parent() |
|
|
|
.find('button') |
|
|
|
.find("button") |
|
|
|
.click(); |
|
|
|
.click(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -422,9 +417,9 @@ Cypress.Commands.add('closeViewsTab', (vn) => { |
|
|
|
let screenShotDb = []; |
|
|
|
let screenShotDb = []; |
|
|
|
|
|
|
|
|
|
|
|
// snip entire screen
|
|
|
|
// snip entire screen
|
|
|
|
Cypress.Commands.add('snip', (filename) => { |
|
|
|
Cypress.Commands.add("snip", (filename) => { |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
true === Cypress.env('screenshot') && |
|
|
|
true === Cypress.env("screenshot") && |
|
|
|
false === screenShotDb.includes(filename) |
|
|
|
false === screenShotDb.includes(filename) |
|
|
|
) { |
|
|
|
) { |
|
|
|
let storeName = `${screenShotDb.length}_${filename}`; |
|
|
|
let storeName = `${screenShotDb.length}_${filename}`; |
|
|
@ -435,9 +430,9 @@ Cypress.Commands.add('snip', (filename) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// snip current modal
|
|
|
|
// snip current modal
|
|
|
|
Cypress.Commands.add('snipActiveModal', (filename) => { |
|
|
|
Cypress.Commands.add("snipActiveModal", (filename) => { |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
true === Cypress.env('screenshot') && |
|
|
|
true === Cypress.env("screenshot") && |
|
|
|
false === screenShotDb.includes(filename) |
|
|
|
false === screenShotDb.includes(filename) |
|
|
|
) { |
|
|
|
) { |
|
|
|
let storeName = `${screenShotDb.length}_${filename}`; |
|
|
|
let storeName = `${screenShotDb.length}_${filename}`; |
|
|
@ -452,9 +447,9 @@ Cypress.Commands.add('snipActiveModal', (filename) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// snip current menu
|
|
|
|
// snip current menu
|
|
|
|
Cypress.Commands.add('snipActiveMenu', (filename) => { |
|
|
|
Cypress.Commands.add("snipActiveMenu", (filename) => { |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
true === Cypress.env('screenshot') && |
|
|
|
true === Cypress.env("screenshot") && |
|
|
|
false === screenShotDb.includes(filename) |
|
|
|
false === screenShotDb.includes(filename) |
|
|
|
) { |
|
|
|
) { |
|
|
|
let storeName = `${screenShotDb.length}_${filename}`; |
|
|
|
let storeName = `${screenShotDb.length}_${filename}`; |
|
|
@ -469,22 +464,26 @@ Cypress.Commands.add('snipActiveMenu', (filename) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// pre-test file hook
|
|
|
|
// pre-test file hook
|
|
|
|
Cypress.Commands.add('fileHook', () => { |
|
|
|
Cypress.Commands.add("fileHook", () => { |
|
|
|
window.localStorage.setItem('vueuse-color-scheme', 'light'); |
|
|
|
window.localStorage.setItem("vueuse-color-scheme", "light"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('signOut', () => { |
|
|
|
Cypress.Commands.add("signOut", () => { |
|
|
|
// sign out
|
|
|
|
// sign out
|
|
|
|
cy.visit(`/`); |
|
|
|
cy.visit(`/`); |
|
|
|
cy.get('.nc-project-page-title', { timeout: 30000 }).contains('My Projects').should('be.visible'); |
|
|
|
cy.get(".nc-project-page-title", { timeout: 30000 }) |
|
|
|
cy.get('.nc-menu-accounts', { timeout: 30000 }).should('exist').click(); |
|
|
|
.contains("My Projects") |
|
|
|
cy.getActiveMenu('.nc-dropdown-user-accounts-menu').find('.ant-dropdown-menu-item').eq(1).click(); |
|
|
|
.should("be.visible"); |
|
|
|
|
|
|
|
cy.get(".nc-menu-accounts", { timeout: 30000 }).should("exist").click(); |
|
|
|
|
|
|
|
cy.getActiveMenu(".nc-dropdown-user-accounts-menu") |
|
|
|
|
|
|
|
.find(".ant-dropdown-menu-item") |
|
|
|
|
|
|
|
.eq(1) |
|
|
|
|
|
|
|
.click(); |
|
|
|
|
|
|
|
|
|
|
|
cy.wait(5000); |
|
|
|
cy.wait(5000); |
|
|
|
cy.get('button:contains("SIGN")').should('exist'); |
|
|
|
cy.get('button:contains("SIGN")').should("exist"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Drag n Drop
|
|
|
|
// Drag n Drop
|
|
|
|
// refer: https://stackoverflow.com/a/55409853
|
|
|
|
// refer: https://stackoverflow.com/a/55409853
|
|
|
|
/* |
|
|
|
/* |
|
|
|