Browse Source

test(cypress): meta-sync align with new UI changes

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/894/head
Raju Udava 3 years ago
parent
commit
2d94bfb343
  1. 27
      packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableTables.vue
  2. 102
      scripts/cypress/integration/common/1e_meta_sync.js

27
packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableTables.vue

@ -22,6 +22,7 @@
<v-spacer /> <v-spacer />
<x-btn <x-btn
btn.class="nc-btn-metasync-reload"
outlined outlined
tooltip="Reload list" tooltip="Reload list"
small small
@ -41,7 +42,7 @@
> >
Reload Reload
</x-btn>--> </x-btn>-->
<x-btn <!--x-btn
outlined outlined
:loading="updating" :loading="updating"
:disabled="updating || !edited" :disabled="updating || !edited"
@ -52,7 +53,7 @@
@click="saveModels()" @click="saveModels()"
> >
Save Save
</x-btn> </!--x-btn-->
</v-toolbar> </v-toolbar>
<div class="d-flex d-100 justify-center"> <div class="d-flex d-100 justify-center">
@ -64,13 +65,13 @@
</th> </th>
<!-- <th>APIs</th>--> <!-- <th>APIs</th>-->
<th class="grey--text"> <th class="grey--text">
Actions Sync state
</th> </th>
<th /> <th />
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="model in diff" :key="model.title"> <tr v-for="model in diff" :key="model.title" :class="`nc-metasync-row-${model.tn}`">
<!-- v-if="model.alias.toLowerCase().indexOf(filter.toLowerCase()) > -1">--> <!-- v-if="model.alias.toLowerCase().indexOf(filter.toLowerCase()) > -1">-->
<td> <td>
<v-tooltip bottom> <v-tooltip bottom>
@ -88,7 +89,7 @@
@change="edited = true" @change="edited = true"
/> />
</td>--> </td>-->
<td> <!--td>
<x-icon <x-icon
small small
color="primary" color="primary"
@ -96,7 +97,7 @@
> >
mdi-reload mdi-reload
</x-icon> </x-icon>
</td> </!--td-->
<td> <td>
<span <span
@ -104,6 +105,12 @@
class="caption error--text" class="caption error--text"
>{{ model.detectedChanges.map(m => m.msg).join(', ') }}</span> >{{ model.detectedChanges.map(m => m.msg).join(', ') }}</span>
<span
v-else
class="caption grey--text"
>
{{ 'No change identified' }}
</span>
<!-- <span v-else class="caption grey&#45;&#45;text">Recreate metadata.</span>--> <!-- <span v-else class="caption grey&#45;&#45;text">Recreate metadata.</span>-->
</td> </td>
</tr> </tr>
@ -186,7 +193,7 @@
<v-spacer /> <v-spacer />
<v-tooltip bottom> <v-tooltip bottom>
<template #activator="{on}"> <!-- template #activator="{on}">
<v-alert <v-alert
v-if="isNewOrDeletedModelFound" v-if="isNewOrDeletedModelFound"
dense dense
@ -213,10 +220,10 @@
Metadata for API creation & management is in sync with Metadata for API creation & management is in sync with
'{{ dbAliasList[dbsTab].connection.database }}' Database. '{{ dbAliasList[dbsTab].connection.database }}' Database.
</template> </template>
<template v-else> <template-- v-else>
Metadata for API creation & management isn't sync with Metadata for API creation & management isn't sync with
'{{ dbAliasList[dbsTab].connection.database }}' Database. '{{ dbAliasList[dbsTab].connection.database }}' Database.
</template> </template-->
</v-tooltip> </v-tooltip>
<v-spacer /> <v-spacer />
</div> </div>
@ -237,7 +244,7 @@
<x-btn <x-btn
x-large x-large
btn.class="mx-auto primary" btn.class="mx-auto primary nc-btn-metasync-sync-now"
tooltip="Sync metadata" tooltip="Sync metadata"
@click="syncMetaDiff" @click="syncMetaDiff"
> >

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

@ -12,22 +12,17 @@ export const genTest = (type, xcdb) => {
// loginPage.loginAndOpenProject(type); // loginPage.loginAndOpenProject(type);
}); });
function openMetaTab(msg) { function openMetaTab() {
// open Project metadata tab // open Project metadata tab
// //
mainPage.navigationDraw(mainPage.PROJ_METADATA).click(); mainPage.navigationDraw(mainPage.PROJ_METADATA).click();
cy.get(".nc-meta-mgmt-metadata-tab") cy.get(".nc-meta-mgmt-metadata-tab")
.should('exist') .should("exist")
.click({ force: true }); .click({ force: true });
// kludge, at times test failed to open tab on click // kludge, at times test failed to open tab on click
cy.get(".nc-meta-mgmt-metadata-tab") cy.get(".nc-meta-mgmt-metadata-tab")
.should('exist') .should("exist")
.click({ force: true }); .click({ force: true });
// validate alert message
cy.get(".v-alert")
.contains(msg)
.should("exist");
} }
function closeMetaTab() { function closeMetaTab() {
@ -39,74 +34,97 @@ export const genTest = (type, xcdb) => {
cy.refreshTableTab(); cy.refreshTableTab();
} }
function metaSyncValidate(scenario, context) { function metaSyncValidate(tbl, msg) {
if (scenario === 'out of sync') { cy.get(".nc-btn-metasync-reload").should("exist").click({ force: true });
openMetaTab(`Tables metadata is out of sync`); cy.get(`.nc-metasync-row-${tbl}`).contains(msg).should("exist");
cy.get('.nc-btn-sync-meta-data').should('exist').click(); cy.get(".nc-btn-metasync-sync-now")
cy.toastWait(`Table metadata ${context} successfully`); .should("exist")
.click({ force: true });
} else { cy.toastWait(`Table metadata recreated successfully`);
openMetaTab(`Tables metadata is in sync`); // cy.get(`.nc-metasync-row-${tbl}`).should("exist");
}
closeMetaTab();
} }
beforeEach(() => { before(() => {
// ensure tables are in sync before each operation openMetaTab();
openMetaTab(`Tables metadata is in sync`); });
after(() => {
closeMetaTab(); closeMetaTab();
}) });
it(`Create table`, () => { it(`Create table`, () => {
// Create Table // Create Table
cy.task("queryDb", `CREATE TABLE sakila.table1 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`); cy.task(
cy.task("queryDb", `CREATE TABLE sakila.table2 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`); "queryDb",
metaSyncValidate('out of sync', 'added'); `CREATE TABLE sakila.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))`
);
metaSyncValidate("table1", "New table");
// metaSyncValidate("table2", "Table added");
});
it(`Add relation`, () => { it(`Add relation`, () => {
// Add relation (FK) // Add relation (FK)
cy.task("queryDb", `ALTER TABLE sakila.table1 ADD INDEX fk1_idx (col1 ASC) VISIBLE`) cy.task(
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`); "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`
);
// fix me // fix me
metaSyncValidate('in sync'); metaSyncValidate("table1", "New relation added");
}) });
it(`Remove relation`, () => { it(`Remove relation`, () => {
// 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 // fix me
metaSyncValidate('in sync'); metaSyncValidate("table1", "Relation removed");
}) });
it(`Add column`, () => { it(`Add column`, () => {
// Add Column // Add Column
cy.task("queryDb", `ALTER TABLE sakila.table1 ADD COLUMN newCol VARCHAR(45) NULL AFTER id`); cy.task(
"queryDb",
`ALTER TABLE sakila.table1 ADD COLUMN newCol VARCHAR(45) NULL AFTER id`
);
// fix me // fix me
metaSyncValidate('in sync'); metaSyncValidate("table1", "New column(newCol)");
}) });
it(`Rename column`, () => { it(`Rename column`, () => {
// Rename Column // Rename Column
cy.task("queryDb", `ALTER TABLE sakila.table1 CHANGE COLUMN newCol newColName VARCHAR(45) NULL DEFAULT NULL`); cy.task(
"queryDb",
`ALTER TABLE sakila.table1 CHANGE COLUMN newCol newColName VARCHAR(45) NULL DEFAULT NULL`
);
// fix me // fix me
metaSyncValidate('in sync'); metaSyncValidate(
}) "table1",
"New column(newColName), Column removed(newCol)"
);
});
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 // fix me
metaSyncValidate('in sync'); metaSyncValidate("table1", "Column removed(newColName)");
}) });
it(`Delete table`, () => { it(`Delete table`, () => {
// DROP TABLE // DROP TABLE
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('out of sync', 'deleted'); metaSyncValidate("table1", "Table removed");
}) // metaSyncValidate("table2", "out of sync");
});
}); });
}; };

Loading…
Cancel
Save