Browse Source

test(cypress): additional delay between sqlite query

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/1027/head
Raju Udava 3 years ago
parent
commit
b79d6bddb6
  1. 327
      scripts/cypress/integration/common/00_pre_configurations.js

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

@ -4,35 +4,35 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation"; import { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import { import {
staticProjects, staticProjects,
roles, roles,
isTestSuiteActive, isTestSuiteActive,
getPrimarySuite, getPrimarySuite,
isSecondarySuite, isSecondarySuite,
getCurrentMode, getCurrentMode,
isXcdb, isXcdb,
setProjectString, setProjectString,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
function prepareSqliteQuery(projId) { function prepareSqliteQuery(projId) {
let sqliteQuery = [ let sqliteQuery = [
`ALTER TABLE "actor" RENAME TO "nc_${projId}__actor"`, `ALTER TABLE "actor" RENAME TO "nc_${projId}__actor"`,
`ALTER TABLE "address" RENAME TO "nc_${projId}__address"`, `ALTER TABLE "address" RENAME TO "nc_${projId}__address"`,
`ALTER TABLE "category" RENAME TO "nc_${projId}__category"`, `ALTER TABLE "category" RENAME TO "nc_${projId}__category"`,
`ALTER TABLE "city" RENAME TO "nc_${projId}__city"`, `ALTER TABLE "city" RENAME TO "nc_${projId}__city"`,
`ALTER TABLE "country" RENAME TO "nc_${projId}__country"`, `ALTER TABLE "country" RENAME TO "nc_${projId}__country"`,
`ALTER TABLE "customer" RENAME TO "nc_${projId}__customer"`, `ALTER TABLE "customer" RENAME TO "nc_${projId}__customer"`,
`ALTER TABLE "film" RENAME TO "nc_${projId}__film"`, `ALTER TABLE "film" RENAME TO "nc_${projId}__film"`,
`ALTER TABLE "film_actor" RENAME TO "nc_${projId}__film_actor"`, `ALTER TABLE "film_actor" RENAME TO "nc_${projId}__film_actor"`,
`ALTER TABLE "film_category" RENAME TO "nc_${projId}__film_category"`, `ALTER TABLE "film_category" RENAME TO "nc_${projId}__film_category"`,
`ALTER TABLE "film_text" RENAME TO "nc_${projId}__film_text"`, `ALTER TABLE "film_text" RENAME TO "nc_${projId}__film_text"`,
`ALTER TABLE "inventory" RENAME TO "nc_${projId}__inventory"`, `ALTER TABLE "inventory" RENAME TO "nc_${projId}__inventory"`,
`ALTER TABLE "language" RENAME TO "nc_${projId}__language"`, `ALTER TABLE "language" RENAME TO "nc_${projId}__language"`,
`ALTER TABLE "payment" RENAME TO "nc_${projId}__payment"`, `ALTER TABLE "payment" RENAME TO "nc_${projId}__payment"`,
`ALTER TABLE "rental" RENAME TO "nc_${projId}__rental"`, `ALTER TABLE "rental" RENAME TO "nc_${projId}__rental"`,
`ALTER TABLE "staff" RENAME TO "nc_${projId}__staff"`, `ALTER TABLE "staff" RENAME TO "nc_${projId}__staff"`,
`ALTER TABLE "store" RENAME TO "nc_${projId}__store"`, `ALTER TABLE "store" RENAME TO "nc_${projId}__store"`,
`CREATE VIEW nc_${projId}__customer_list `CREATE VIEW nc_${projId}__customer_list
AS AS
SELECT cu.customer_id AS ID, SELECT cu.customer_id AS ID,
cu.first_name||' '||cu.last_name AS name, cu.first_name||' '||cu.last_name AS name,
@ -45,7 +45,7 @@ function prepareSqliteQuery(projId) {
cu.store_id AS SID cu.store_id AS SID
FROM "nc_${projId}__customer" AS cu JOIN "nc_${projId}__address" AS a ON cu.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id FROM "nc_${projId}__customer" AS cu JOIN "nc_${projId}__address" AS a ON cu.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id
JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`, JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`,
`CREATE VIEW nc_${projId}__film_list `CREATE VIEW nc_${projId}__film_list
AS AS
SELECT "nc_${projId}__film".film_id AS FID, SELECT "nc_${projId}__film".film_id AS FID,
"nc_${projId}__film".title AS title, "nc_${projId}__film".title AS title,
@ -58,7 +58,7 @@ function prepareSqliteQuery(projId) {
FROM "nc_${projId}__category" LEFT JOIN "nc_${projId}__film_category" ON "nc_${projId}__category".category_id = "nc_${projId}__film_category".category_id LEFT JOIN "nc_${projId}__film" ON "nc_${projId}__Film_category".film_id = "nc_${projId}__film".film_id FROM "nc_${projId}__category" LEFT JOIN "nc_${projId}__film_category" ON "nc_${projId}__category".category_id = "nc_${projId}__film_category".category_id LEFT JOIN "nc_${projId}__film" ON "nc_${projId}__Film_category".film_id = "nc_${projId}__film".film_id
JOIN "nc_${projId}__film_actor" ON "nc_${projId}__film".film_id = "nc_${projId}__film_actor".film_id JOIN "nc_${projId}__film_actor" ON "nc_${projId}__film".film_id = "nc_${projId}__film_actor".film_id
JOIN "nc_${projId}__actor" ON "nc_${projId}__film_actor".actor_id = "nc_${projId}__actor".actor_id`, JOIN "nc_${projId}__actor" ON "nc_${projId}__film_actor".actor_id = "nc_${projId}__actor".actor_id`,
`CREATE VIEW nc_${projId}__sales_by_film_category `CREATE VIEW nc_${projId}__sales_by_film_category
AS AS
SELECT SELECT
c.name AS category c.name AS category
@ -70,7 +70,7 @@ function prepareSqliteQuery(projId) {
INNER JOIN "nc_${projId}__film_category" AS fc ON f.film_id = fc.film_id INNER JOIN "nc_${projId}__film_category" AS fc ON f.film_id = fc.film_id
INNER JOIN "nc_${projId}__category" AS c ON fc.category_id = c.category_id INNER JOIN "nc_${projId}__category" AS c ON fc.category_id = c.category_id
GROUP BY c.name`, GROUP BY c.name`,
`CREATE VIEW nc_${projId}__sales_by_store `CREATE VIEW nc_${projId}__sales_by_store
AS AS
SELECT SELECT
s.store_id s.store_id
@ -89,7 +89,7 @@ function prepareSqliteQuery(projId) {
s.store_id s.store_id
, c.city||','||cy.country , c.city||','||cy.country
, m.first_name||' '||m.last_name`, , m.first_name||' '||m.last_name`,
`CREATE VIEW nc_${projId}__staff_list `CREATE VIEW nc_${projId}__staff_list
AS AS
SELECT s.staff_id AS ID, SELECT s.staff_id AS ID,
s.first_name||' '||s.last_name AS name, s.first_name||' '||s.last_name AS name,
@ -101,8 +101,8 @@ function prepareSqliteQuery(projId) {
s.store_id AS SID s.store_id AS SID
FROM "nc_${projId}__staff" AS s JOIN "nc_${projId}__address" AS a ON s.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id FROM "nc_${projId}__staff" AS s JOIN "nc_${projId}__address" AS a ON s.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id
JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`, JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`,
// below two are dummy entries to ensure view record exists // below two are dummy entries to ensure view record exists
`CREATE VIEW nc_${projId}__actor_info `CREATE VIEW nc_${projId}__actor_info
AS AS
SELECT s.staff_id AS ID, SELECT s.staff_id AS ID,
s.first_name||' '||s.last_name AS name, s.first_name||' '||s.last_name AS name,
@ -114,7 +114,7 @@ function prepareSqliteQuery(projId) {
s.store_id AS SID s.store_id AS SID
FROM "nc_${projId}__staff" AS s JOIN "nc_${projId}__address" AS a ON s.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id FROM "nc_${projId}__staff" AS s JOIN "nc_${projId}__address" AS a ON s.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id
JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`, JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`,
`CREATE VIEW nc_${projId}__nice_but_slower_film_list `CREATE VIEW nc_${projId}__nice_but_slower_film_list
AS AS
SELECT s.staff_id AS ID, SELECT s.staff_id AS ID,
s.first_name||' '||s.last_name AS name, s.first_name||' '||s.last_name AS name,
@ -126,155 +126,156 @@ function prepareSqliteQuery(projId) {
s.store_id AS SID s.store_id AS SID
FROM "nc_${projId}__staff" AS s JOIN "nc_${projId}__address" AS a ON s.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id FROM "nc_${projId}__staff" AS s JOIN "nc_${projId}__address" AS a ON s.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id
JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`, JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`,
// `CREATE VIEW nc_${projId}__actor_info // `CREATE VIEW nc_${projId}__actor_info
// AS // AS
// SELECT // SELECT
// a.actor_id AS actor_id, // a.actor_id AS actor_id,
// a.first_name AS first_name, // a.first_name AS first_name,
// a.last_name AS last_name, // a.last_name AS last_name,
// GROUP_CONCAT(DISTINCT CONCAT(c.name, // GROUP_CONCAT(DISTINCT CONCAT(c.name,
// ': ', // ': ',
// (SELECT // (SELECT
// GROUP_CONCAT(f.title // GROUP_CONCAT(f.title
// ORDER BY f.title ASC // ORDER BY f.title ASC
// SEPARATOR ', ') // SEPARATOR ', ')
// FROM // FROM
// ((nc_${projId}__film f // ((nc_${projId}__film f
// JOIN nc_${projId}__film_category fc ON ((f.film_id = fc.film_id))) // JOIN nc_${projId}__film_category fc ON ((f.film_id = fc.film_id)))
// JOIN nc_${projId}__film_actor fa ON ((f.film_id = fa.film_id))) // JOIN nc_${projId}__film_actor fa ON ((f.film_id = fa.film_id)))
// WHERE // WHERE
// ((fc.category_id = c.category_id) // ((fc.category_id = c.category_id)
// AND (fa.actor_id = a.actor_id)))) // AND (fa.actor_id = a.actor_id))))
// ORDER BY c.name ASC // ORDER BY c.name ASC
// SEPARATOR '; ') AS nc_${projId}__film_info // SEPARATOR '; ') AS nc_${projId}__film_info
// FROM // FROM
// (((actor a // (((actor a
// LEFT JOIN nc_${projId}__film_actor fa ON ((a.actor_id = fa.actor_id))) // LEFT JOIN nc_${projId}__film_actor fa ON ((a.actor_id = fa.actor_id)))
// LEFT JOIN nc_${projId}__film_category fc ON ((fa.film_id = fc.film_id))) // LEFT JOIN nc_${projId}__film_category fc ON ((fa.film_id = fc.film_id)))
// LEFT JOIN nc_${projId}__category c ON ((fc.category_id = c.category_id))) // LEFT JOIN nc_${projId}__category c ON ((fc.category_id = c.category_id)))
// GROUP BY a.actor_id , a.first_name , a.last_name`, // GROUP BY a.actor_id , a.first_name , a.last_name`,
]; ];
return sqliteQuery; return sqliteQuery;
} }
export const genTest = (type, xcdb) => { export const genTest = (type, xcdb) => {
if (!isTestSuiteActive(type, xcdb)) return; if (!isTestSuiteActive(type, xcdb)) return;
describe(`Project pre-configurations`, () => { describe(`Project pre-configurations`, () => {
it("Admin SignUp", () => { it("Admin SignUp", () => {
cy.task("log", "This will be output to the terminal"); cy.task("log", "This will be output to the terminal");
cy.waitForSpinners(); cy.waitForSpinners();
cy.signinOrSignup(roles.owner.credentials); cy.signinOrSignup(roles.owner.credentials);
}); });
const createProject = (proj) => { const createProject = (proj) => {
it(`Create ${proj.basic.name} project`, () => { it(`Create ${proj.basic.name} project`, () => {
// click home button // click home button
cy.get(".nc-noco-brand-icon").click(); cy.get(".nc-noco-brand-icon").click();
cy.get(".nc-container").then((obj) => { cy.get(".nc-container").then((obj) => {
cy.log(obj); cy.log(obj);
// if project already created, open // if project already created, open
// else, create a new one // else, create a new one
if (true == obj[0].innerHTML.includes(proj.basic.name)) { if (true == obj[0].innerHTML.includes(proj.basic.name)) {
projectsPage.openProject(proj.basic.name); projectsPage.openProject(proj.basic.name);
} else { } else {
projectsPage.createProject(proj.basic, proj.config); projectsPage.createProject(proj.basic, proj.config);
} }
if (xcdb) { if (xcdb) {
// store base URL- to re-visit and delete form view later // store base URL- to re-visit and delete form view later
let projId; let projId;
cy.url() cy.url()
.then((url) => { .then((url) => {
// project prefix code can include "_" // project prefix code can include "_"
// projId = url.split("_")[1].split("?")[0]; // projId = url.split("_")[1].split("?")[0];
let startIdx = url.indexOf("_"); let startIdx = url.indexOf("_");
let endIdx = url.indexOf("?"); let endIdx = url.indexOf("?");
projId = url.slice(startIdx + 1, endIdx); projId = url.slice(startIdx + 1, endIdx);
cy.log(url, projId); cy.log(url, projId);
setProjectString(projId); setProjectString(projId);
let query = prepareSqliteQuery(projId); let query = prepareSqliteQuery(projId);
for (let i = 0; i < query.length; i++) { for (let i = 0; i < query.length; i++) {
cy.task("sqliteExec", query[i]); cy.task("sqliteExec", query[i]);
} cy.wait(1000);
}) }
.then(() => { })
cy.log(projId); .then(() => {
mainPage.openMetaTab(); cy.log(projId);
mainPage.metaSyncValidate( mainPage.openMetaTab();
`nc_${projId}__actor`, mainPage.metaSyncValidate(
`New table, New relation added` `nc_${projId}__actor`,
); `New table, New relation added`
mainPage.closeMetaTab(); );
}); mainPage.closeMetaTab();
} });
}
// create requested project // create requested project
// projectsPage.createProject(proj.basic, proj.config) // projectsPage.createProject(proj.basic, proj.config)
}); });
}); });
}; };
// if (isTestSuiteActive('rest', true)) createProject(staticProjects.sampleREST) // if (isTestSuiteActive('rest', true)) createProject(staticProjects.sampleREST)
// if (isTestSuiteActive('graphql', true)) createProject(staticProjects.sampleGQL) // if (isTestSuiteActive('graphql', true)) createProject(staticProjects.sampleGQL)
// if (isTestSuiteActive('rest', false)) createProject(staticProjects.externalREST) // if (isTestSuiteActive('rest', false)) createProject(staticProjects.externalREST)
// if (isTestSuiteActive('graphql', false)) createProject(staticProjects.externalGQL) // if (isTestSuiteActive('graphql', false)) createProject(staticProjects.externalGQL)
if ("rest" == type) { if ("rest" == type) {
if (true == xcdb) { if (true == xcdb) {
createProject(staticProjects.sampleREST); createProject(staticProjects.sampleREST);
} else { } else {
createProject(staticProjects.externalREST); createProject(staticProjects.externalREST);
} }
} else if ("graphql" == type) { } else if ("graphql" == type) {
if (true == xcdb) { if (true == xcdb) {
createProject(staticProjects.sampleGQL); createProject(staticProjects.sampleGQL);
} else { } else {
createProject(staticProjects.externalGQL); createProject(staticProjects.externalGQL);
} }
} }
}); });
// describe('Static user creations (different roles)', () => { // describe('Static user creations (different roles)', () => {
// beforeEach(() => { // beforeEach(() => {
// loginPage.signIn(roles.owner.credentials) // loginPage.signIn(roles.owner.credentials)
// projectsPage.openProject(getPrimarySuite().basic.name) // projectsPage.openProject(getPrimarySuite().basic.name)
// }) // })
// const addUser = (user) => { // const addUser = (user) => {
// it(`RoleType: ${user.name}`, () => { // it(`RoleType: ${user.name}`, () => {
// mainPage.addNewUserToProject(user.credentials, user.name) // mainPage.addNewUserToProject(user.credentials, user.name)
// }) // })
// } // }
// addUser(roles.creator) // addUser(roles.creator)
// addUser(roles.editor) // addUser(roles.editor)
// addUser(roles.commenter) // addUser(roles.commenter)
// addUser(roles.viewer) // addUser(roles.viewer)
// }) // })
// describe('Static users- add to other static projects', () => { // describe('Static users- add to other static projects', () => {
// const addUserToProject = (proj) => { // const addUserToProject = (proj) => {
// it(`Add users to ${proj.basic.name}`, () => { // it(`Add users to ${proj.basic.name}`, () => {
// loginPage.signIn(roles.owner.credentials) // loginPage.signIn(roles.owner.credentials)
// projectsPage.openProject(proj.basic.name) // projectsPage.openProject(proj.basic.name)
// mainPage.addExistingUserToProject(roles.creator.credentials.username, roles.creator.name) // mainPage.addExistingUserToProject(roles.creator.credentials.username, roles.creator.name)
// mainPage.addExistingUserToProject(roles.editor.credentials.username, roles.editor.name) // mainPage.addExistingUserToProject(roles.editor.credentials.username, roles.editor.name)
// mainPage.addExistingUserToProject(roles.commenter.credentials.username, roles.commenter.name) // mainPage.addExistingUserToProject(roles.commenter.credentials.username, roles.commenter.name)
// mainPage.addExistingUserToProject(roles.viewer.credentials.username, roles.viewer.name) // mainPage.addExistingUserToProject(roles.viewer.credentials.username, roles.viewer.name)
// }) // })
// } // }
// if (isSecondarySuite('rest', true)) addUserToProject(staticProjects.sampleREST) // if (isSecondarySuite('rest', true)) addUserToProject(staticProjects.sampleREST)
// if (isSecondarySuite('graphql', true)) addUserToProject(staticProjects.sampleGQL) // if (isSecondarySuite('graphql', true)) addUserToProject(staticProjects.sampleGQL)
// if (isSecondarySuite('rest', false)) addUserToProject(staticProjects.externalREST) // if (isSecondarySuite('rest', false)) addUserToProject(staticProjects.externalREST)
// if (isSecondarySuite('graphql', false)) addUserToProject(staticProjects.externalGQL) // if (isSecondarySuite('graphql', false)) addUserToProject(staticProjects.externalGQL)
// }) // })
}; };
/** /**

Loading…
Cancel
Save