diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index 4a9da43a79..da6d66b154 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -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 diff --git a/cypress/e2e/po/pages/extensions.po.ts b/cypress/e2e/po/pages/extensions.po.ts index 06055ef4fc..47188cb17c 100644 --- a/cypress/e2e/po/pages/extensions.po.ts +++ b/cypress/e2e/po/pages/extensions.po.ts @@ -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 }`); diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index bbfe266d1c..48c3566f61 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -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(); diff --git a/package.json b/package.json index 02577a24ee..0775845d6f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/e2e b/scripts/e2e index d961830d62..34029497c7 100755 --- a/scripts/e2e +++ b/scripts/e2e @@ -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