|
|
|
@ -1,24 +1,28 @@
|
|
|
|
|
import { mainPage } from "../../support/page_objects/mainPage"; |
|
|
|
|
import { loginPage } from "../../support/page_objects/navigation"; |
|
|
|
|
import { |
|
|
|
|
getProjectString, |
|
|
|
|
isTestSuiteActive, |
|
|
|
|
isXcdb, |
|
|
|
|
} from "../../support/page_objects/projectConstants"; |
|
|
|
|
|
|
|
|
|
export const genTest = (type, xcdb) => { |
|
|
|
|
if (!isTestSuiteActive(type, xcdb)) return; |
|
|
|
|
if (isXcdb()) return; |
|
|
|
|
|
|
|
|
|
let projPrefix = `sakila.`; |
|
|
|
|
let dbCmd = `queryDb`; |
|
|
|
|
let tblDisplayPrefix = ``; |
|
|
|
|
|
|
|
|
|
describe(`${type.toUpperCase()} api - Meta Sync`, () => { |
|
|
|
|
// Run once before test- create project (rest/graphql)
|
|
|
|
|
//
|
|
|
|
|
before(() => { |
|
|
|
|
// loginPage.loginAndOpenProject(type);
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before(() => { |
|
|
|
|
if (isXcdb()) { |
|
|
|
|
cy.log(getProjectString()); |
|
|
|
|
projPrefix = `nc_${getProjectString()}__`; |
|
|
|
|
dbCmd = `sqliteExec`; |
|
|
|
|
tblDisplayPrefix = `nc_${getProjectString()}__`; |
|
|
|
|
} |
|
|
|
|
mainPage.openMetaTab(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -29,80 +33,106 @@ export const genTest = (type, xcdb) => {
|
|
|
|
|
it(`Create table`, () => { |
|
|
|
|
// Create Table
|
|
|
|
|
cy.task( |
|
|
|
|
"queryDb", |
|
|
|
|
`CREATE TABLE sakila.table1 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))` |
|
|
|
|
dbCmd, |
|
|
|
|
`CREATE TABLE ${projPrefix}table1 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))` |
|
|
|
|
); |
|
|
|
|
cy.task( |
|
|
|
|
"queryDb", |
|
|
|
|
`CREATE TABLE sakila.table2 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))` |
|
|
|
|
dbCmd, |
|
|
|
|
`CREATE TABLE ${projPrefix}table2 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))` |
|
|
|
|
); |
|
|
|
|
mainPage.metaSyncValidate("table1", "New table"); |
|
|
|
|
mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "New table"); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it(`Add relation`, () => { |
|
|
|
|
// Add relation (FK)
|
|
|
|
|
cy.task( |
|
|
|
|
"queryDb", |
|
|
|
|
`ALTER TABLE sakila.table1 ADD INDEX fk1_idx (col1 ASC) VISIBLE` |
|
|
|
|
); |
|
|
|
|
cy.task( |
|
|
|
|
"queryDb", |
|
|
|
|
`ALTER TABLE sakila.table1 ADD CONSTRAINT fk1 FOREIGN KEY (col1) REFERENCES sakila.table2 (id) ON DELETE NO ACTION ON UPDATE NO ACTION` |
|
|
|
|
); |
|
|
|
|
mainPage.metaSyncValidate("table1", "New relation added"); |
|
|
|
|
// working with relations in sqlite requires table to be deleted & recreated
|
|
|
|
|
//
|
|
|
|
|
if (!isXcdb()) { |
|
|
|
|
// Add relation (FK)
|
|
|
|
|
cy.task( |
|
|
|
|
dbCmd, |
|
|
|
|
`ALTER TABLE ${projPrefix}table1 ADD INDEX fk1_idx (col1 ASC) VISIBLE` |
|
|
|
|
); |
|
|
|
|
cy.task( |
|
|
|
|
dbCmd, |
|
|
|
|
`ALTER TABLE ${projPrefix}table1 ADD CONSTRAINT fk1 FOREIGN KEY (col1) REFERENCES ${projPrefix}table2 (id) ON DELETE NO ACTION ON UPDATE NO ACTION` |
|
|
|
|
); |
|
|
|
|
mainPage.metaSyncValidate( |
|
|
|
|
`${tblDisplayPrefix}table1`, |
|
|
|
|
"New relation added" |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it(`Remove relation`, () => { |
|
|
|
|
// Remove relation (FK)
|
|
|
|
|
cy.task("queryDb", `ALTER TABLE sakila.table1 DROP FOREIGN KEY fk1`); |
|
|
|
|
cy.task("queryDb", `ALTER TABLE sakila.table1 DROP INDEX fk1_idx`); |
|
|
|
|
mainPage.metaSyncValidate("table1", "Relation removed"); |
|
|
|
|
// working with relations in sqlite requires table to be deleted & recreated
|
|
|
|
|
//
|
|
|
|
|
if (!isXcdb()) { |
|
|
|
|
// Remove relation (FK)
|
|
|
|
|
cy.task(dbCmd, `ALTER TABLE ${projPrefix}table1 DROP FOREIGN KEY fk1`); |
|
|
|
|
cy.task(dbCmd, `ALTER TABLE ${projPrefix}table1 DROP INDEX fk1_idx`); |
|
|
|
|
mainPage.metaSyncValidate( |
|
|
|
|
`${tblDisplayPrefix}table1`, |
|
|
|
|
"Relation removed" |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it(`Add column`, () => { |
|
|
|
|
// Add Column
|
|
|
|
|
cy.task( |
|
|
|
|
"queryDb", |
|
|
|
|
`ALTER TABLE sakila.table1 ADD COLUMN newCol VARCHAR(45) NULL AFTER id` |
|
|
|
|
let queryString = `ALTER TABLE ${projPrefix}table1 ADD COLUMN newCol VARCHAR(45) NULL AFTER id`; |
|
|
|
|
if (isXcdb()) |
|
|
|
|
queryString = `ALTER TABLE ${projPrefix}table1 ADD COLUMN newCol TEXT NULL`; |
|
|
|
|
cy.task(dbCmd, queryString); |
|
|
|
|
mainPage.metaSyncValidate( |
|
|
|
|
`${tblDisplayPrefix}table1`, |
|
|
|
|
"New column(newCol)" |
|
|
|
|
); |
|
|
|
|
mainPage.metaSyncValidate("table1", "New column(newCol)"); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it(`Rename column`, () => { |
|
|
|
|
// Rename Column
|
|
|
|
|
cy.task( |
|
|
|
|
"queryDb", |
|
|
|
|
`ALTER TABLE sakila.table1 CHANGE COLUMN newCol newColName VARCHAR(45) NULL DEFAULT NULL` |
|
|
|
|
); |
|
|
|
|
let queryString = `ALTER TABLE ${projPrefix}table1 CHANGE COLUMN newCol newColName VARCHAR(45) NULL DEFAULT NULL`; |
|
|
|
|
if (isXcdb()) |
|
|
|
|
queryString = `ALTER TABLE ${projPrefix}table1 RENAME COLUMN newCol TO newColName`; |
|
|
|
|
cy.task(dbCmd, queryString); |
|
|
|
|
mainPage.metaSyncValidate( |
|
|
|
|
"table1", |
|
|
|
|
`${tblDisplayPrefix}table1`, |
|
|
|
|
"New column(newColName), Column removed(newCol)" |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it(`Delete column`, () => { |
|
|
|
|
// Remove Column
|
|
|
|
|
cy.task("queryDb", `ALTER TABLE sakila.table1 DROP COLUMN newColName`); |
|
|
|
|
mainPage.metaSyncValidate("table1", "Column removed(newColName)"); |
|
|
|
|
// to be fixed for SQLITE
|
|
|
|
|
if (!isXcdb()) { |
|
|
|
|
cy.task( |
|
|
|
|
dbCmd, |
|
|
|
|
`ALTER TABLE ${projPrefix}table1 DROP COLUMN newColName` |
|
|
|
|
); |
|
|
|
|
mainPage.metaSyncValidate( |
|
|
|
|
`${tblDisplayPrefix}table1`, |
|
|
|
|
"Column removed(newColName)" |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it(`Delete table`, () => { |
|
|
|
|
// DROP TABLE
|
|
|
|
|
cy.task("queryDb", `DROP TABLE sakila.table1`); |
|
|
|
|
cy.task("queryDb", `DROP TABLE sakila.table2`); |
|
|
|
|
mainPage.metaSyncValidate("table1", "Table removed"); |
|
|
|
|
cy.task(dbCmd, `DROP TABLE ${projPrefix}table1`); |
|
|
|
|
cy.task(dbCmd, `DROP TABLE ${projPrefix}table2`); |
|
|
|
|
mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "Table removed"); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
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))` |
|
|
|
|
dbCmd, |
|
|
|
|
`CREATE TABLE ${projPrefix}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);` |
|
|
|
|
dbCmd, |
|
|
|
|
`INSERT INTO ${projPrefix}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);` |
|
|
|
|
); |
|
|
|
|
mainPage.metaSyncValidate("table1", "New table"); |
|
|
|
|
mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "New table"); |
|
|
|
|
mainPage.closeMetaTab(); |
|
|
|
|
|
|
|
|
|
cy.openTableTab("Table1", 9); |
|
|
|
@ -116,12 +146,12 @@ export const genTest = (type, xcdb) => {
|
|
|
|
|
it(`Verify`, () => { |
|
|
|
|
mainPage.openMetaTab(); |
|
|
|
|
// Rename Column
|
|
|
|
|
cy.task( |
|
|
|
|
"queryDb", |
|
|
|
|
`ALTER TABLE sakila.table1 CHANGE COLUMN col1 newCol INT NULL DEFAULT NULL` |
|
|
|
|
); |
|
|
|
|
let queryString = `ALTER TABLE ${projPrefix}table1 CHANGE COLUMN col1 newCol INT NULL DEFAULT NULL`; |
|
|
|
|
if (isXcdb()) |
|
|
|
|
queryString = `ALTER TABLE ${projPrefix}table1 RENAME COLUMN col1 TO newCol`; |
|
|
|
|
cy.task(dbCmd, queryString); |
|
|
|
|
mainPage.metaSyncValidate( |
|
|
|
|
"table1", |
|
|
|
|
`${tblDisplayPrefix}table1`, |
|
|
|
|
"New column(newCol), Column removed(col1)" |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|