Browse Source

test(cypress): metasync updates

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/894/head
Raju Udava 3 years ago
parent
commit
5686b4ea2e
  1. 40
      scripts/cypress/integration/common/1e_meta_sync.js
  2. 14
      scripts/cypress/support/commands.js

40
scripts/cypress/integration/common/1e_meta_sync.js

@ -63,7 +63,6 @@ export const genTest = (type, xcdb) => {
`CREATE TABLE sakila.table2 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))` `CREATE TABLE sakila.table2 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`
); );
metaSyncValidate("table1", "New table"); metaSyncValidate("table1", "New table");
// metaSyncValidate("table2", "Table added");
}); });
it(`Add relation`, () => { it(`Add relation`, () => {
@ -76,7 +75,6 @@ export const genTest = (type, xcdb) => {
"queryDb", "queryDb",
`ALTER TABLE sakila.table1 ADD CONSTRAINT fk1 FOREIGN KEY (col1) REFERENCES sakila.table2 (id) ON DELETE NO ACTION ON UPDATE NO ACTION` `ALTER TABLE sakila.table1 ADD CONSTRAINT fk1 FOREIGN KEY (col1) REFERENCES sakila.table2 (id) ON DELETE NO ACTION ON UPDATE NO ACTION`
); );
// fix me
metaSyncValidate("table1", "New relation added"); metaSyncValidate("table1", "New relation added");
}); });
@ -84,7 +82,6 @@ export const genTest = (type, xcdb) => {
// Remove relation (FK) // Remove relation (FK)
cy.task("queryDb", `ALTER TABLE sakila.table1 DROP FOREIGN KEY fk1`); cy.task("queryDb", `ALTER TABLE sakila.table1 DROP FOREIGN KEY fk1`);
cy.task("queryDb", `ALTER TABLE sakila.table1 DROP INDEX fk1_idx`); cy.task("queryDb", `ALTER TABLE sakila.table1 DROP INDEX fk1_idx`);
// fix me
metaSyncValidate("table1", "Relation removed"); metaSyncValidate("table1", "Relation removed");
}); });
@ -94,7 +91,6 @@ export const genTest = (type, xcdb) => {
"queryDb", "queryDb",
`ALTER TABLE sakila.table1 ADD COLUMN newCol VARCHAR(45) NULL AFTER id` `ALTER TABLE sakila.table1 ADD COLUMN newCol VARCHAR(45) NULL AFTER id`
); );
// fix me
metaSyncValidate("table1", "New column(newCol)"); metaSyncValidate("table1", "New column(newCol)");
}); });
@ -104,7 +100,6 @@ export const genTest = (type, xcdb) => {
"queryDb", "queryDb",
`ALTER TABLE sakila.table1 CHANGE COLUMN newCol newColName VARCHAR(45) NULL DEFAULT NULL` `ALTER TABLE sakila.table1 CHANGE COLUMN newCol newColName VARCHAR(45) NULL DEFAULT NULL`
); );
// fix me
metaSyncValidate( metaSyncValidate(
"table1", "table1",
"New column(newColName), Column removed(newCol)" "New column(newColName), Column removed(newCol)"
@ -114,7 +109,6 @@ export const genTest = (type, xcdb) => {
it(`Delete column`, () => { it(`Delete column`, () => {
// Remove Column // Remove Column
cy.task("queryDb", `ALTER TABLE sakila.table1 DROP COLUMN newColName`); cy.task("queryDb", `ALTER TABLE sakila.table1 DROP COLUMN newColName`);
// fix me
metaSyncValidate("table1", "Column removed(newColName)"); metaSyncValidate("table1", "Column removed(newColName)");
}); });
@ -123,7 +117,39 @@ export const genTest = (type, xcdb) => {
cy.task("queryDb", `DROP TABLE sakila.table1`); cy.task("queryDb", `DROP TABLE sakila.table1`);
cy.task("queryDb", `DROP TABLE sakila.table2`); cy.task("queryDb", `DROP TABLE sakila.table2`);
metaSyncValidate("table1", "Table removed"); metaSyncValidate("table1", "Table removed");
// metaSyncValidate("table2", "out of sync"); });
it(`Hide, Filter, Sort`, () => {
cy.task(
"queryDb",
`CREATE TABLE sakila.table1 (id INT NOT NULL, col1 INT NULL, col2 INT NULL, col3 INT NULL, col4 INT NULL, PRIMARY KEY (id))`
);
cy.task(
"queryDb",
`INSERT INTO sakila.table1 (id, col1, col2, col3, col4) VALUES (1,1,1,1,1), (2,2,2,2,2), (3,3,3,3,3), (4,4,4,4,4), (5,5,5,5,5), (6,6,6,6,6), (7,7,7,7,7), (8,8,8,8,8), (9,9,9,9,9);`
);
metaSyncValidate("table1", "New table");
closeMetaTab();
cy.openTableTab("Table1", 9);
mainPage.hideField("Col1");
mainPage.sortField("Col1", "Z -> A");
mainPage.filterField(`Col1`, ">=", "5");
cy.get(".nc-grid-row").should("have.length", 5);
cy.closeTableTab("Table1");
});
it(`Verify`, () => {
openMetaTab();
// Rename Column
cy.task(
"queryDb",
`ALTER TABLE sakila.table1 CHANGE COLUMN col1 newCol INT NULL DEFAULT NULL`
);
metaSyncValidate("table1", "New column(newCol), Column removed(col1)");
cy.openTableTab("Table1", 0);
cy.deleteTable("Table1");
}); });
}); });
}; };

14
scripts/cypress/support/commands.js

@ -115,11 +115,15 @@ Cypress.Commands.add("refreshTableTab", () => {
.should("exist") .should("exist")
.first() .first()
.rightclick({ force: true }); .rightclick({ force: true });
cy.getActiveMenu().find('[role="menuitem"]').contains('Tables Refresh').click()
cy.toastWait('Tables refreshed'); cy.getActiveMenu()
}) .find('[role="menuitem"]')
.contains("Tables Refresh")
.should("exist")
.click({ force: true });
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
@ -247,7 +251,7 @@ Cypress.Commands.add("deleteTable", (name) => {
cy.get(`.project-tab:contains(${name}):visible`).should("exist"); cy.get(`.project-tab:contains(${name}):visible`).should("exist");
cy.get(".nc-table-delete-btn:visible").click(); cy.get(".nc-table-delete-btn:visible").click();
cy.get("button:contains(Submit)").click(); cy.get("button:contains(Submit)").click();
cy.toastWait(`Delete table.${name} successful`); cy.toastWait(`Delete table.${name.toLowerCase()} successful`);
}); });
Cypress.Commands.add("renameTable", (oldName, newName) => { Cypress.Commands.add("renameTable", (oldName, newName) => {

Loading…
Cancel
Save