Browse Source

Merge pull request #1264 from dstala/develop

test: CI-CD integration for Cypress PG test suite
pull/1274/head
Raju Udava 3 years ago committed by GitHub
parent
commit
45986b1681
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 180
      .github/workflows/ci-cd.yml
  2. 0
      scripts/cypress/docker-compose-pg.yml
  3. 169
      scripts/cypress/integration/common/1d_pg_table_view_drag_drop_reorder.js
  4. 3
      scripts/cypress/integration/common/1e_pg_meta_sync.js
  5. 2
      scripts/cypress/integration/test/pg-restTableOps.js
  6. 14
      scripts/cypress/support/page_objects/navigation.js

180
.github/workflows/ci-cd.yml

@ -18,6 +18,178 @@ on:
- ".github/workflows/ci-cd.yml"
jobs:
cypress-pg-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:api
npm run start:web
docker-compose -f ./scripts/cypress/docker-compose-pg.yml up -d
spec: "./scripts/cypress/integration/test/pg-restTableOps.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json
- name: Upload screenshots
uses: actions/upload-artifact@v2
with:
name: restTableOps-snapshots
path: scripts/cypress/screenshots
retention-days: 2
cypress-pg-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:api
npm run start:web
docker-compose -f ./scripts/cypress/docker-compose-pg.yml up -d
spec: "./scripts/cypress/integration/test/pg-restViews.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json
- name: Upload screenshots
uses: actions/upload-artifact@v2
with:
name: restTableOps-snapshots
path: scripts/cypress/screenshots
retention-days: 2
cypress-pg-restRoles-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:api
npm run start:web
docker-compose -f ./scripts/cypress/docker-compose-pg.yml up -d
spec: "./scripts/cypress/integration/test/pg-restRoles.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json
- name: Upload screenshots
uses: actions/upload-artifact@v2
with:
name: restTableOps-snapshots
path: scripts/cypress/screenshots
retention-days: 2
cypress-pg-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:api
npm run start:web
docker-compose -f ./scripts/cypress/docker-compose-pg.yml up -d
spec: "./scripts/cypress/integration/test/pg-restMisc.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json
- name: Upload screenshots
uses: actions/upload-artifact@v2
with:
name: restTableOps-snapshots
path: scripts/cypress/screenshots
retention-days: 2
cypress-restTableOps-run:
runs-on: ubuntu-20.04
steps:
@ -225,7 +397,6 @@ jobs:
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
@ -269,7 +440,6 @@ jobs:
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
@ -313,7 +483,6 @@ jobs:
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
@ -357,7 +526,6 @@ jobs:
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
@ -577,7 +745,6 @@ jobs:
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-gqlTableOps.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200
@ -621,7 +788,6 @@ jobs:
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-gqlViews.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200
@ -665,7 +831,6 @@ jobs:
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-gqlRoles.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200
@ -709,7 +874,6 @@ jobs:
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-gqlMisc.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200

0
scripts/cypress/docker-compose.yml → scripts/cypress/docker-compose-pg.yml

169
scripts/cypress/integration/common/1d_pg_table_view_drag_drop_reorder.js

@ -0,0 +1,169 @@
import {
isTestSuiteActive,
isXcdb,
getProjectString,
isPostgres,
} from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} Table/view drag-drop reorder`, () => {
function validateTreeField(index, tblName) {
cy.get(`:nth-child(${index}) > .v-list-item__title > .caption`)
.contains(tblName)
.should("exist");
}
/*
Original order of list items
Actor, Address, Category, City, Country, Customer, FIlm, FilmText, Language, Payment, Rental Staff
ActorInfo, CustomerList, FilmList, NiceButSlowerFilmList, SalesByFilmCategory, SalesByStore, StaffList
*/
it(`Table & SQL View list, Drag/drop`, () => {
// expand tree-view menu
// cy.get(".nc-project-tree")
// .find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
// .should("exist")
// .first()
// .click({ force: true });
validateTreeField(1, "Actor");
// move Actor field down, above Staff (drag, drop)
cy.get(".nc-child-draggable-icon-Actor").drag(
".nc-child-draggable-icon-Film"
);
validateTreeField(7, "Actor");
// move ActorInfo (View) field up to first place (drag, drop)
cy.get(".nc-child-draggable-icon-ActorInfo").drag(
".nc-child-draggable-icon-Address"
);
validateTreeField(1, "ActorInfo");
validateTreeField(2, "Address");
validateTreeField(8, "Actor");
// restore ActorInfo field (drag, drop)
cy.get(".nc-child-draggable-icon-ActorInfo").drag(
".nc-child-draggable-icon-Staff"
);
// restore Actor field (drag, drop)
cy.get(".nc-child-draggable-icon-Actor").drag(
".nc-child-draggable-icon-Address"
);
validateTreeField(1, "Actor");
validateTreeField(2, "Address");
if (isPostgres()) {
validateTreeField(17, "Staff");
validateTreeField(18, "ActorInfo");
validateTreeField(19, "CustomerList");
} else {
validateTreeField(12, "Staff");
validateTreeField(13, "ActorInfo");
validateTreeField(14, "CustomerList");
}
// undo project-tree expand operation
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", {
timeout: 10000,
})
.should("exist")
.first()
.click({ force: true });
});
// create new view as specified by 'viewType'
// can be - grid/ gallery/ form
// wait for toast to appear
//
function createView(viewType) {
// click on 'Grid/Gallery' button on Views bar
cy.get(`.nc-create-${viewType}-view`).click();
// Pop up window, click Submit (accepting default name for view)
cy.getActiveModal().find("button:contains(Submit)").click();
cy.toastWait("View created successfully");
}
// verify view 'viewName' to be present at position 'index'
// index starts from 0
function validateViewField(index, viewName) {
cy.get(".nc-view-item.nc-draggable-child")
.eq(index)
.contains(viewName)
.should("exist");
}
it(`View (Gallery/ Grid/ Form) re-order`, () => {
cy.openTableTab("Actor", 25);
// create 3 views, use default names
// Actor1, Actor2, Actor3
createView("grid");
createView("gallery");
createView("form");
// validate position order
validateViewField(0, "Actor");
validateViewField(1, "Actor1");
validateViewField(2, "Actor2");
validateViewField(3, "Actor3");
// move Actor3 field on top (drag, drop)
cy.get(".nc-child-draggable-icon-Actor3").drag(
`.nc-child-draggable-icon-${
isXcdb() ? `nc_${getProjectString()}__` : ``
}actor`
);
// validate new position order, Actor3 on top
validateViewField(0, "Actor3");
validateViewField(1, "Actor");
validateViewField(2, "Actor1");
validateViewField(3, "Actor2");
// delete all created views
// click on delete icon (becomes visible on hovering mouse)
cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully");
cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully");
cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully");
// wind up
cy.closeTableTab("Actor");
});
});
};
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Pranav C Balan <pranavxc@gmail.com>
* @author Raju Udava <sivadstala@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

3
scripts/cypress/integration/common/1e_pg_meta_sync.js

@ -172,7 +172,8 @@ export const genTest = (apiType, dbType) => {
);
cy.openTableTab("Table1", 9);
cy.deleteTable("Table1", dbType);
// kludge- delete table triggered post sql backend operations doesnt carry any trigger toast
cy.deleteTable("Table1", "mysql");
});
});
};

2
scripts/cypress/integration/test/pg-restTableOps.js

@ -3,7 +3,7 @@ let t01 = require("../common/00_pre_configurations");
let t1a = require("../common/1a_table_operations");
let t1b = require("../common/1b_table_column_operations");
let t1c = require("../common/1c_sql_view");
let t1d = require("../common/1d_table_view_drag_drop_reorder");
let t1d = require("../common/1d_pg_table_view_drag_drop_reorder");
let t1e = require("../common/1e_pg_meta_sync");
let t2a = require("../common/2a_table_with_belongs_to_colulmn");
let t2b = require("../common/2b_table_with_m2m_column");

14
scripts/cypress/support/page_objects/navigation.js

@ -68,7 +68,19 @@ export class _loginPage {
} else if (dbType === "xcdb") {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.sampleREST.basic.name);
else projectsPage.openProject(staticProjects.sampleGQL.basic.name);
else {
projectsPage.openProject(staticProjects.sampleGQL.basic.name);
}
} else if (dbType === "postgres") {
if ("rest" == apiType)
projectsPage.openProject(
staticProjects.pgExternalREST.basic.name
);
else {
projectsPage.openProject(
staticProjects.pgExternalGQL.basic.name
);
}
}
}
}

Loading…
Cancel
Save