adjust e2e test run to pass spec + adjust add of main extensions repo

This commit is contained in:
Alexandre Alves 2024-07-26 09:53:41 +01:00
parent eb650605f3
commit 486351c2e9
5 changed files with 44 additions and 33 deletions

View File

@ -62,7 +62,7 @@ jobs:
# This is the actual triggering of the e2e test specs
- name: Run user tests
run: |
yarn e2e:prod
export SPEC_FILE="cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts" && yarn e2e:prod
[ "$BUILD_DASHBOARD" != "false" ] || exit 0
env:
TEST_SKIP: setup

View File

@ -6,6 +6,7 @@ import NameNsDescriptionPo from '@/cypress/e2e/po/components/name-ns-description
import RepositoriesPagePo from '@/cypress/e2e/po/pages/chart-repositories.po';
import BannersPo from '@/cypress/e2e/po/components/banners.po';
import ChartRepositoriesCreateEditPo from '@/cypress/e2e/po/edit/chart-repositories.po';
import AppClusterRepoEditPo from '@/cypress/e2e/po/edit/catalog.cattle.io.clusterrepo.po';
import { LONG_TIMEOUT_OPT } from '@/cypress/support/utils/timeouts';
export default class ExtensionsPagePo extends PagePo {
@ -83,6 +84,33 @@ export default class ExtensionsPagePo extends PagePo {
appRepoList.list().state(name).should('contain', 'Active');
}
/**
* Adds a cluster repo for extensions
* @param repo - The repository url (e.g. https://github.com/rancher/ui-plugin-examples)
* @param branch - The git branch to target
* @param name - A name for the repository
* @returns {Cypress.Chainable}
*/
addExtensionsRepositoryNew(repo: string, branch: string, name: string, waitForActiveState = true): Cypress.Chainable {
const appRepoList = new RepositoriesPagePo('local', 'apps');
const appRepoCreate = new AppClusterRepoEditPo('local', 'create');
appRepoCreate.goTo();
appRepoCreate.waitForPage();
appRepoCreate.nameNsDescription().name().set(name);
appRepoCreate.selectRadioOptionGitRepo(1);
// fill the git repo form
appRepoCreate.enterGitRepoName(repo);
appRepoCreate.enterGitBranchName(branch);
appRepoCreate.create().click();
if (waitForActiveState) {
appRepoList.waitForPage();
appRepoList.list().state(name).should('contain', 'Active');
}
}
// ------------------ extension card ------------------
extensionCard(extensionName: string) {
return this.self().getId(`extension-card-${ extensionName }`);

View File

@ -1,6 +1,4 @@
import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po';
import ReposListPagePo from '@/cypress/e2e/po/pages/chart-repositories.po';
import AppClusterRepoEditPo from '@/cypress/e2e/po/edit/catalog.cattle.io.clusterrepo.po';
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
import AboutPagePo from '@/cypress/e2e/po/pages/about.po';
@ -14,37 +12,13 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] }
it('add main extensions repository', () => {
// // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry
// const extensionsPo = new ExtensionsPagePo();
const extensionsPo = new ExtensionsPagePo();
// extensionsPo.goTo();
// extensionsPo.waitForPage();
// extensionsPo.extensionTabInstalledClick(); // Avoid nav guard failures that probably auto move user to this tab
// // install the rancher plugin examples
// extensionsPo.addExtensionsRepository('https://github.com/rancher/ui-plugin-charts', 'main', 'Rancher Extensions');
// const appRepoList = new ReposListPagePo('local', 'apps');
// appRepoList.goTo();
// appRepoList.waitForGoTo('/v1/catalog.cattle.io.clusterrepos?exclude=metadata.managedFields');
// appRepoList.create();
const appRepoCreate = new AppClusterRepoEditPo('local', 'create');
appRepoCreate.goTo();
appRepoCreate.waitForPage();
appRepoCreate.nameNsDescription().name().set('rancher-extensions');
appRepoCreate.selectRadioOptionGitRepo(1);
// fill the git repo form
appRepoCreate.enterGitRepoName('https://github.com/rancher/ui-plugin-charts');
appRepoCreate.enterGitBranchName('main');
appRepoCreate.create().click();
cy.wait(5000); // eslint-disable-line cypress/no-unnecessary-waiting
extensionsPo.addExtensionsRepositoryNew('https://github.com/rancher/ui-plugin-charts', 'main', 'rancher-extensions');
});
it('can navigate to About page', () => {
// TODO: TO REMOVE ONCE EVERYTHING IS GOOD!
it('can navigate to About page (get version from about page screenshots to make sure we are on the right system)', () => {
const aboutPage = new AboutPagePo();
HomePagePo.goToAndWaitForGet();

View File

@ -39,7 +39,7 @@
"cy:e2e": "cypress open --e2e --browser chrome",
"cy:open": "cypress open",
"cy:run": "cypress run --browser chrome",
"cy:run:sorry": "./scripts/e2e",
"cy:run:sorry": "./scripts/e2e $SPEC_FILE",
"e2e:pre-dev": "yarn docker:local:stop && yarn docker:local:start && NODE_ENV=dev TEST_INSTRUMENT=true yarn build",
"e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run:sorry",
"e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e",

View File

@ -2,4 +2,13 @@
ID="$(echo ${TEST_RUN_ID:-`date +%s` } | tr '[:upper:]' '[:lower:]' | tr ' ' '-')"
echo "$ID"
CYPRESS_coverage=true CYPRESS_API_URL='http://139.59.134.103:1234' cy2 run --group "$GREP_TAGS" --browser chrome --record --key rancher-dashboard --parallel --ci-build-id "$ID"
# check if script invoke contains any argument. If so, add spec to run
if [ $# -eq 1 ]; then
echo "on the e2e script file where SPEC=$1"
CYPRESS_coverage=true CYPRESS_API_URL='http://139.59.134.103:1234' cy2 run --spec "$1" --group "$GREP_TAGS" --browser chrome --record --key rancher-dashboard --parallel --ci-build-id "$ID"
else
echo "normal e2e script"
CYPRESS_coverage=true CYPRESS_API_URL='http://139.59.134.103:1234' cy2 run --group "$GREP_TAGS" --browser chrome --record --key rancher-dashboard --parallel --ci-build-id "$ID"
fi