|
|
@ -4,7 +4,6 @@ import { SettingsPage, SettingTab } from '../pages/Dashboard/Settings'; |
|
|
|
import setup, { NcContext } from '../setup'; |
|
|
|
import setup, { NcContext } from '../setup'; |
|
|
|
import { isMysql, isPg, isSqlite, mysqlExec, pgExec, sqliteExec } from '../setup/db'; |
|
|
|
import { isMysql, isPg, isSqlite, mysqlExec, pgExec, sqliteExec } from '../setup/db'; |
|
|
|
|
|
|
|
|
|
|
|
// todo: Enable when view bug is fixed
|
|
|
|
|
|
|
|
test.describe('Meta sync', () => { |
|
|
|
test.describe('Meta sync', () => { |
|
|
|
let dashboard: DashboardPage; |
|
|
|
let dashboard: DashboardPage; |
|
|
|
let settings: SettingsPage; |
|
|
|
let settings: SettingsPage; |
|
|
@ -33,30 +32,31 @@ test.describe('Meta sync', () => { |
|
|
|
test.setTimeout(process.env.CI ? 100000 : 70000); |
|
|
|
test.setTimeout(process.env.CI ? 100000 : 70000); |
|
|
|
|
|
|
|
|
|
|
|
await dashboard.gotoSettings(); |
|
|
|
await dashboard.gotoSettings(); |
|
|
|
await settings.selectTab({ tab: SettingTab.ProjectMetadata }); |
|
|
|
await settings.selectTab({ tab: SettingTab.DataSources }); |
|
|
|
|
|
|
|
await settings.dataSources.openMetaSync(); |
|
|
|
|
|
|
|
|
|
|
|
await dbExec(`CREATE TABLE table1 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`); |
|
|
|
await dbExec(`CREATE TABLE table1 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`); |
|
|
|
await dbExec(`CREATE TABLE table2 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`); |
|
|
|
await dbExec(`CREATE TABLE table2 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`); |
|
|
|
|
|
|
|
|
|
|
|
await settings.metaData.clickReload(); |
|
|
|
await settings.dataSources.metaData.clickReload(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: `table1`, |
|
|
|
model: `table1`, |
|
|
|
state: 'New table', |
|
|
|
state: 'New table', |
|
|
|
}); |
|
|
|
}); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 22 : 17, |
|
|
|
index: isPg(context) ? 22 : 17, |
|
|
|
model: `table2`, |
|
|
|
model: `table2`, |
|
|
|
state: 'New table', |
|
|
|
state: 'New table', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await settings.metaData.sync(); |
|
|
|
await settings.dataSources.metaData.sync(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: 'Table1', |
|
|
|
model: 'Table1', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
|
}); |
|
|
|
}); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 22 : 17, |
|
|
|
index: isPg(context) ? 22 : 17, |
|
|
|
model: 'Table2', |
|
|
|
model: 'Table2', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
@ -72,16 +72,16 @@ test.describe('Meta sync', () => { |
|
|
|
`ALTER TABLE table1 ADD CONSTRAINT fk1 FOREIGN KEY (col1) REFERENCES table2 (id) ON DELETE NO ACTION ON UPDATE NO ACTION` |
|
|
|
`ALTER TABLE table1 ADD CONSTRAINT fk1 FOREIGN KEY (col1) REFERENCES table2 (id) ON DELETE NO ACTION ON UPDATE NO ACTION` |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
await settings.metaData.clickReload(); |
|
|
|
await settings.dataSources.metaData.clickReload(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: 'Table1', |
|
|
|
model: 'Table1', |
|
|
|
state: 'New relation added', |
|
|
|
state: 'New relation added', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//verify after sync
|
|
|
|
//verify after sync
|
|
|
|
await settings.metaData.sync(); |
|
|
|
await settings.dataSources.metaData.sync(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: 'Table1', |
|
|
|
model: 'Table1', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
@ -94,16 +94,16 @@ test.describe('Meta sync', () => { |
|
|
|
await dbExec(`ALTER TABLE table1 DROP FOREIGN KEY fk1`); |
|
|
|
await dbExec(`ALTER TABLE table1 DROP FOREIGN KEY fk1`); |
|
|
|
await dbExec(`ALTER TABLE table1 DROP INDEX fk1_idx`); |
|
|
|
await dbExec(`ALTER TABLE table1 DROP INDEX fk1_idx`); |
|
|
|
} |
|
|
|
} |
|
|
|
await settings.metaData.clickReload(); |
|
|
|
await settings.dataSources.metaData.clickReload(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: 'Table1', |
|
|
|
model: 'Table1', |
|
|
|
state: 'Relation removed', |
|
|
|
state: 'Relation removed', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//verify after sync
|
|
|
|
//verify after sync
|
|
|
|
await settings.metaData.sync(); |
|
|
|
await settings.dataSources.metaData.sync(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: 'Table1', |
|
|
|
model: 'Table1', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
@ -119,16 +119,16 @@ test.describe('Meta sync', () => { |
|
|
|
await dbExec(`ALTER TABLE table1 ADD COLUMN newCol INT`); |
|
|
|
await dbExec(`ALTER TABLE table1 ADD COLUMN newCol INT`); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await settings.metaData.clickReload(); |
|
|
|
await settings.dataSources.metaData.clickReload(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: `Table1`, |
|
|
|
model: `Table1`, |
|
|
|
state: 'New column(newCol)', |
|
|
|
state: 'New column(newCol)', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//verify after sync
|
|
|
|
//verify after sync
|
|
|
|
await settings.metaData.sync(); |
|
|
|
await settings.dataSources.metaData.sync(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: 'Table1', |
|
|
|
model: 'Table1', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
@ -143,16 +143,16 @@ test.describe('Meta sync', () => { |
|
|
|
await dbExec(`ALTER TABLE table1 RENAME COLUMN newCol TO newColName`); |
|
|
|
await dbExec(`ALTER TABLE table1 RENAME COLUMN newCol TO newColName`); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await settings.metaData.clickReload(); |
|
|
|
await settings.dataSources.metaData.clickReload(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: `Table1`, |
|
|
|
model: `Table1`, |
|
|
|
state: 'New column(newColName), Column removed(newCol)', |
|
|
|
state: 'New column(newColName), Column removed(newCol)', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//verify after sync
|
|
|
|
//verify after sync
|
|
|
|
await settings.metaData.sync(); |
|
|
|
await settings.dataSources.metaData.sync(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: 'Table1', |
|
|
|
model: 'Table1', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
@ -162,16 +162,16 @@ test.describe('Meta sync', () => { |
|
|
|
// todo: Add for sqlite
|
|
|
|
// todo: Add for sqlite
|
|
|
|
if (!isSqlite(context)) { |
|
|
|
if (!isSqlite(context)) { |
|
|
|
await dbExec(`ALTER TABLE table1 DROP COLUMN newColName`); |
|
|
|
await dbExec(`ALTER TABLE table1 DROP COLUMN newColName`); |
|
|
|
await settings.metaData.clickReload(); |
|
|
|
await settings.dataSources.metaData.clickReload(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: `Table1`, |
|
|
|
model: `Table1`, |
|
|
|
state: 'Column removed(newColName)', |
|
|
|
state: 'Column removed(newColName)', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//verify after sync
|
|
|
|
//verify after sync
|
|
|
|
await settings.metaData.sync(); |
|
|
|
await settings.dataSources.metaData.sync(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: 'Table1', |
|
|
|
model: 'Table1', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
@ -181,51 +181,51 @@ test.describe('Meta sync', () => { |
|
|
|
// Delete table
|
|
|
|
// Delete table
|
|
|
|
await dbExec(`DROP TABLE table1`); |
|
|
|
await dbExec(`DROP TABLE table1`); |
|
|
|
await dbExec(`DROP TABLE table2`); |
|
|
|
await dbExec(`DROP TABLE table2`); |
|
|
|
await settings.metaData.clickReload(); |
|
|
|
await settings.dataSources.metaData.clickReload(); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
index: isPg(context) ? 21 : 16, |
|
|
|
model: `table1`, |
|
|
|
model: `table1`, |
|
|
|
state: 'Table removed', |
|
|
|
state: 'Table removed', |
|
|
|
}); |
|
|
|
}); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: isPg(context) ? 22 : 17, |
|
|
|
index: isPg(context) ? 22 : 17, |
|
|
|
model: `table2`, |
|
|
|
model: `table2`, |
|
|
|
state: 'Table removed', |
|
|
|
state: 'Table removed', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//verify after sync
|
|
|
|
//verify after sync
|
|
|
|
await settings.metaData.sync(); |
|
|
|
await settings.dataSources.metaData.sync(); |
|
|
|
|
|
|
|
|
|
|
|
if (isSqlite(context)) { |
|
|
|
if (isSqlite(context)) { |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: 16, |
|
|
|
index: 16, |
|
|
|
model: 'CustomerList', |
|
|
|
model: 'CustomerList', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
|
}); |
|
|
|
}); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: 17, |
|
|
|
index: 17, |
|
|
|
model: 'FilmList', |
|
|
|
model: 'FilmList', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
if (isPg(context)) { |
|
|
|
if (isPg(context)) { |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: 21, |
|
|
|
index: 21, |
|
|
|
model: 'ActorInfo', |
|
|
|
model: 'ActorInfo', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
|
}); |
|
|
|
}); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: 22, |
|
|
|
index: 22, |
|
|
|
model: 'CustomerList', |
|
|
|
model: 'CustomerList', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else if (isMysql(context)) { |
|
|
|
} else if (isMysql(context)) { |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: 16, |
|
|
|
index: 16, |
|
|
|
model: 'ActorInfo', |
|
|
|
model: 'ActorInfo', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
|
}); |
|
|
|
}); |
|
|
|
await settings.metaData.verifyRow({ |
|
|
|
await settings.dataSources.metaData.verifyRow({ |
|
|
|
index: 17, |
|
|
|
index: 17, |
|
|
|
model: 'CustomerList', |
|
|
|
model: 'CustomerList', |
|
|
|
state: 'No change identified', |
|
|
|
state: 'No change identified', |
|
|
@ -242,10 +242,11 @@ test.describe('Meta sync', () => { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
await dashboard.gotoSettings(); |
|
|
|
await dashboard.gotoSettings(); |
|
|
|
await settings.selectTab({ tab: SettingTab.ProjectMetadata }); |
|
|
|
await settings.selectTab({ tab: SettingTab.DataSources }); |
|
|
|
|
|
|
|
await settings.dataSources.openMetaSync(); |
|
|
|
|
|
|
|
|
|
|
|
await settings.metaData.clickReload(); |
|
|
|
await settings.dataSources.metaData.clickReload(); |
|
|
|
await settings.metaData.sync(); |
|
|
|
await settings.dataSources.metaData.sync(); |
|
|
|
await settings.close(); |
|
|
|
await settings.close(); |
|
|
|
|
|
|
|
|
|
|
|
await dashboard.treeView.openTable({ title: 'Table1' }); |
|
|
|
await dashboard.treeView.openTable({ title: 'Table1' }); |
|
|
|