Browse Source

test(cypress) enable xcdb-rest suite

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/914/head
Raju Udava 3 years ago
parent
commit
ce0c54321b
  1. 158
      .github/workflows/ci-cd.yml
  2. 1
      package.json
  3. 2
      packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableTables.vue
  4. 10
      scripts/cypress/cypress.json
  5. 61
      scripts/cypress/integration/common/1e_meta_sync.js
  6. 9
      scripts/cypress/support/page_objects/mainPage.js

158
.github/workflows/ci-cd.yml

@ -81,7 +81,6 @@ jobs:
${{ runner.os }}-build- ${{ runner.os }}-build-
${{ runner.os }}- ${{ runner.os }}-
- name: Set env - name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV run: echo "NODE_ENV=test" >> $GITHUB_ENV
- name: Cypress run - name: Cypress run
@ -120,7 +119,6 @@ jobs:
${{ runner.os }}-build- ${{ runner.os }}-build-
${{ runner.os }}- ${{ runner.os }}-
- name: Set env - name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV run: echo "NODE_ENV=test" >> $GITHUB_ENV
- name: Cypress run - name: Cypress run
@ -159,7 +157,6 @@ jobs:
${{ runner.os }}-build- ${{ runner.os }}-build-
${{ runner.os }}- ${{ runner.os }}-
- name: Set env - name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV run: echo "NODE_ENV=test" >> $GITHUB_ENV
- name: Cypress run - name: Cypress run
@ -173,7 +170,82 @@ jobs:
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js" wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200 wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json config-file: scripts/cypress/cypress.json
cypress-gqlTableOps-run: cypress-xcdb-restTableOps-run:
runs-on: ubuntu-20.04
steps:
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV
- name: Cypress run
uses: cypress-io/github-action@v2
with:
start: |
npm run start:xcdb-api
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restTableOps.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json
cypress-xcdb-restViews-run:
runs-on: ubuntu-20.04
steps:
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV
- name: Cypress run
uses: cypress-io/github-action@v2
with:
start: |
npm run start:xcdb-api
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restViews.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json
cypress-xcdb-restRoles-run:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Setup Node - name: Setup Node
@ -198,6 +270,81 @@ jobs:
${{ runner.os }}-build- ${{ runner.os }}-build-
${{ runner.os }}- ${{ runner.os }}-
- name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV
- name: Cypress run
uses: cypress-io/github-action@v2
with:
start: |
npm run start:xcdb-api
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restRoles.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json
cypress-xcdb-restMisc-run:
runs-on: ubuntu-20.04
steps:
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV
- name: Cypress run
uses: cypress-io/github-action@v2
with:
start: |
npm run start:xcdb-api
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restMisc.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json
cypress-gqlTableOps-run:
runs-on: ubuntu-20.04
steps:
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Set env - name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV run: echo "NODE_ENV=test" >> $GITHUB_ENV
@ -237,7 +384,6 @@ jobs:
${{ runner.os }}-build- ${{ runner.os }}-build-
${{ runner.os }}- ${{ runner.os }}-
- name: Set env - name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV run: echo "NODE_ENV=test" >> $GITHUB_ENV
- name: Cypress run - name: Cypress run
@ -276,7 +422,6 @@ jobs:
${{ runner.os }}-build- ${{ runner.os }}-build-
${{ runner.os }}- ${{ runner.os }}-
- name: Set env - name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV run: echo "NODE_ENV=test" >> $GITHUB_ENV
- name: Cypress run - name: Cypress run
@ -315,7 +460,6 @@ jobs:
${{ runner.os }}-build- ${{ runner.os }}-build-
${{ runner.os }}- ${{ runner.os }}-
- name: Set env - name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV run: echo "NODE_ENV=test" >> $GITHUB_ENV
- name: Cypress run - name: Cypress run

1
package.json

@ -14,6 +14,7 @@
}, },
"scripts": { "scripts": {
"start:api": "cd ./packages/nocodb; npm install; npm run watch:run", "start:api": "cd ./packages/nocodb; npm install; npm run watch:run",
"start:xcdb-api": "cd ./packages/nocodb; npm install; NC_INFLECTION=camelize DATABASE_URL=sqlite:../../../scripts/cypress/fixtures/sqlite-sakila/sakila.db npm run watch:run",
"start:web": "cd ./packages/nc-gui; npm install; npm run dev", "start:web": "cd ./packages/nc-gui; npm install; npm run dev",
"cypress:run": "cypress run --config-file ./scripts/cypress/cypress.json", "cypress:run": "cypress run --config-file ./scripts/cypress/cypress.json",
"cypress:open": "cypress open --config-file ./scripts/cypress/cypress.json", "cypress:open": "cypress open --config-file ./scripts/cypress/cypress.json",

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

@ -75,7 +75,7 @@
v-for="model in diff" v-for="model in diff"
v-show="!filter.trim() || (model.tn || model.title || '').toLowerCase().includes(filter.toLowerCase())" v-show="!filter.trim() || (model.tn || model.title || '').toLowerCase().includes(filter.toLowerCase())"
:key="model.title" :key="model.title"
:class="`nc-metasync-row-${model.tn}`" :class="`nc-metasync-row 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>

10
scripts/cypress/cypress.json

@ -5,10 +5,18 @@
"test/restViews.js", "test/restViews.js",
"test/restRoles.js", "test/restRoles.js",
"test/restMisc.js", "test/restMisc.js",
"test/xcdb-restTableOps.js",
"test/xcdb-restViews.js",
"test/xcdb-restRoles.js",
"test/xcdb-restMisc.js",
"test/gqlTableOps.js", "test/gqlTableOps.js",
"test/gqlViews.js", "test/gqlViews.js",
"test/gqlRoles.js", "test/gqlRoles.js",
"test/gqlMisc.js" "test/gqlMisc.js",
"test/xcdb-gqlTableOps.js",
"test/xcdb-gqlViews.js",
"test/xcdb-gqlRoles.js",
"test/xcdb-gqlMisc.js"
], ],
"defaultCommandTimeout": 13000, "defaultCommandTimeout": 13000,
"pageLoadTimeout": 600000, "pageLoadTimeout": 600000,

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

@ -16,44 +16,14 @@ export const genTest = (type, xcdb) => {
// loginPage.loginAndOpenProject(type); // loginPage.loginAndOpenProject(type);
}); });
function openMetaTab() {
// open Project metadata tab
//
mainPage.navigationDraw(mainPage.PROJ_METADATA).click();
cy.get(".nc-meta-mgmt-metadata-tab")
.should("exist")
.click({ force: true });
// kludge, at times test failed to open tab on click
cy.get(".nc-meta-mgmt-metadata-tab")
.should("exist")
.click({ force: true });
}
function closeMetaTab() {
// user href link to find meta mgmt tab
cy.get('[href="#disableOrEnableModel||||Meta Management"]')
.find("button.mdi-close")
.click({ force: true });
// refresh
cy.refreshTableTab();
}
function metaSyncValidate(tbl, msg) {
cy.get(".nc-btn-metasync-reload").should("exist").click({ force: true });
cy.get(`.nc-metasync-row-${tbl}`).contains(msg).should("exist");
cy.get(".nc-btn-metasync-sync-now")
.should("exist")
.click({ force: true });
cy.toastWait(`Table metadata recreated successfully`);
// cy.get(`.nc-metasync-row-${tbl}`).should("exist");
}
before(() => { before(() => {
openMetaTab(); mainPage.openMetaTab();
}); });
after(() => { after(() => {
closeMetaTab(); mainPage.closeMetaTab();
}); });
it(`Create table`, () => { it(`Create table`, () => {
@ -66,7 +36,7 @@ export const genTest = (type, xcdb) => {
"queryDb", "queryDb",
`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"); mainPage.metaSyncValidate("table1", "New table");
}); });
it(`Add relation`, () => { it(`Add relation`, () => {
@ -79,14 +49,14 @@ 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`
); );
metaSyncValidate("table1", "New relation added"); mainPage.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`);
metaSyncValidate("table1", "Relation removed"); mainPage.metaSyncValidate("table1", "Relation removed");
}); });
it(`Add column`, () => { it(`Add column`, () => {
@ -95,7 +65,7 @@ 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`
); );
metaSyncValidate("table1", "New column(newCol)"); mainPage.metaSyncValidate("table1", "New column(newCol)");
}); });
it(`Rename column`, () => { it(`Rename column`, () => {
@ -104,7 +74,7 @@ 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`
); );
metaSyncValidate( mainPage.metaSyncValidate(
"table1", "table1",
"New column(newColName), Column removed(newCol)" "New column(newColName), Column removed(newCol)"
); );
@ -113,14 +83,14 @@ 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`);
metaSyncValidate("table1", "Column removed(newColName)"); mainPage.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("table1", "Table removed"); mainPage.metaSyncValidate("table1", "Table removed");
}); });
it(`Hide, Filter, Sort`, () => { it(`Hide, Filter, Sort`, () => {
@ -132,8 +102,8 @@ export const genTest = (type, xcdb) => {
"queryDb", "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);` `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"); mainPage.metaSyncValidate("table1", "New table");
closeMetaTab(); mainPage.closeMetaTab();
cy.openTableTab("Table1", 9); cy.openTableTab("Table1", 9);
mainPage.hideField("Col1"); mainPage.hideField("Col1");
@ -144,13 +114,16 @@ export const genTest = (type, xcdb) => {
}); });
it(`Verify`, () => { it(`Verify`, () => {
openMetaTab(); mainPage.openMetaTab();
// Rename Column // Rename Column
cy.task( cy.task(
"queryDb", "queryDb",
`ALTER TABLE sakila.table1 CHANGE COLUMN col1 newCol INT NULL DEFAULT NULL` `ALTER TABLE sakila.table1 CHANGE COLUMN col1 newCol INT NULL DEFAULT NULL`
); );
metaSyncValidate("table1", "New column(newCol), Column removed(col1)"); mainPage.metaSyncValidate(
"table1",
"New column(newCol), Column removed(col1)"
);
cy.openTableTab("Table1", 0); cy.openTableTab("Table1", 0);
cy.deleteTable("Table1"); cy.deleteTable("Table1");

9
scripts/cypress/support/page_objects/mainPage.js

@ -403,6 +403,15 @@ export class _mainPage {
cy.get(".nc-btn-metasync-reload").should("exist").click({ force: true }); cy.get(".nc-btn-metasync-reload").should("exist").click({ force: true });
cy.get(`.nc-metasync-row-${tbl}`).contains(msg).should("exist"); cy.get(`.nc-metasync-row-${tbl}`).contains(msg).should("exist");
cy.get(".nc-btn-metasync-sync-now").should("exist").click({ force: true }); cy.get(".nc-btn-metasync-sync-now").should("exist").click({ force: true });
cy.get(".nc-metasync-row").then((row) => {
for (let i = 0; i < row.length; i++) {
cy.wrap(row).contains("No change identified").should("exist");
}
});
// cy.get(`.nc-metasync-row-${tbl}`).contains(msg).should("not.exist");
// cy.get(`.nc-metasync-row-${tbl}`)
// .contains("No change identified")
// .should("exist");
cy.toastWait(`Table metadata recreated successfully`); cy.toastWait(`Table metadata recreated successfully`);
// cy.get(`.nc-metasync-row-${tbl}`).should("exist"); // cy.get(`.nc-metasync-row-${tbl}`).should("exist");
} }

Loading…
Cancel
Save