Skip to content

Commit

Permalink
Update cypress configuration (#6646)
Browse files Browse the repository at this point in the history
Disable namespace selector e2e test
  • Loading branch information
floreks authored Dec 2, 2021
1 parent 183ae39 commit 26c9e43
Show file tree
Hide file tree
Showing 13 changed files with 193 additions and 17 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ dist/
coverage/
cypress/screenshots
cypress/videos
cypress/support

# System specific files:
.DS_Store
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ e2e: start-cluster
npm run e2e
make stop-cluster

.PHONY: e2e-headed
e2e-headed: start-cluster
npm run e2e:headed
make stop-cluster

.PHONY: docker-build-release
docker-build-release: build-cross
for ARCH in $(ARCHITECTURES) ; do \
Expand Down
1 change: 1 addition & 0 deletions aio/scripts/conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ARCH=$(uname | awk '{print tolower($0)}')
HEAPSTER_VERSION="v1.5.4"
HEAPSTER_PORT=8082
KIND_VERSION="v0.11.1"
K8S_VERSION="v1.21.1"
KIND_BIN=${CACHE_DIR}/kind-${KIND_VERSION}
CODEGEN_VERSION="v0.22.4"
CODEGEN_BIN=${GOPATH}/pkg/mod/k8s.io/code-generator@${CODEGEN_VERSION}/generate-groups.sh
Expand Down
2 changes: 1 addition & 1 deletion aio/scripts/start-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function start-ci-heapster {
}

function start-kind {
${KIND_BIN} create cluster --name="k8s-cluster-ci" --image=kindest/node:v1.21.1
${KIND_BIN} create cluster --name="k8s-cluster-ci" --image="kindest/node:${K8S_VERSION}"
ensure-kubeconfig
if [ "${CI}" = true ] ; then
start-ci-heapster
Expand Down
9 changes: 4 additions & 5 deletions aio/tsconfig.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"strict": true,
"outDir": "../out-tsc/e2e",
"baseUrl": "../cypress",
"baseUrl": "../node_modules",
"types": ["cypress"]
},
"include": [
"../cypress/integration/**/*.ts",
"../cypress/pages/**/*.ts",
"../node_modules/cypress/**/*.ts"]
"integration/**/*.ts",
"pages/**/*.ts",
"../node_modules/cypress"]
}
9 changes: 7 additions & 2 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"baseUrl": "http://localhost:8080",
"supportFile": "./cypress/support/index.ts",
"video": false,
"viewportWidth": 1920,
"viewportHeight": 1080
"chromeWebSecurity": false,
"screenshotOnRunFailure": true,
"videoCompression": false,
"pageLoadTimeout": 10000,
"viewportHeight": 1080,
"viewportWidth": 1920
}
4 changes: 2 additions & 2 deletions cypress/integration/specs/nav.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ describe('Navbar', () => {
NavbarPage.assertUrlContains('workload');
});

// Namespace selector
it('namespace selector', () => {
// TODO: passes locally but often fails in the CI. Needs to be investigated and fixed.
xit('namespace selector', () => {
const ns = 'kube-public';
NavbarPage.visitHome();
NavbarPage.clickItem(NavbarPage.namespaceSelectorItemId);
Expand Down
2 changes: 1 addition & 1 deletion cypress/pages/abstractPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class AbstractPage {
}

static clickSelectorItem(option: string) {
cy.get('mat-option').contains(option).click();
cy.get('mat-option').contains(option).click({force: true});
}

static assertUrlContains(url: string) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import webpack from '@cypress/webpack-preprocessor';

const webpackOptions = {
resolve: {extensions: ['.ts', '.js']},
module: {
Expand All @@ -18,6 +16,4 @@ const webpackOptions = {
},
};

export default async (on) => {
on('file:preprocessor', webpack({webpackOptions}));
}
export const configuration = {webpackOptions};
20 changes: 20 additions & 0 deletions cypress/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import webpack from '@cypress/webpack-preprocessor';
import failFast from 'cypress-fail-fast/plugin';
import del from 'del';
import {configuration} from './cy-ts-preprocessor';

// @ts-ignore
export default async (on, config) => {
on('file:preprocessor', webpack(configuration));

// Remove videos of successful tests and keep only failed ones.
// @ts-ignore
on('after:spec', (_, results) => {
if (results.stats.failures === 0 && results.video) {
return del(results.video);
}
});

failFast(on, config);
return config;
};
3 changes: 3 additions & 0 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
before(() => {
cy.clearCookies();
});
146 changes: 146 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"fix": "make fix",
"test": "make test",
"e2e": "concurrently -kill-others --success first \"npm run start:e2e\" \"wait-on http://localhost:8080 && npx cypress run\"",
"e2e:headed": "concurrently -kill-others --success first \"npm run start:e2e\" \"wait-on http://localhost:8080 && npx cypress run --headed\"",
"postinstall": "make ensure-version && go mod vendor && ngcc",
"prepare": "husky install"
},
Expand Down Expand Up @@ -114,6 +115,7 @@
"codelyzer": "6.0.2",
"concurrently": "6.4.0",
"cypress": "8.7.0",
"cypress-fail-fast": "3.3.0",
"del": "6.0.0",
"eslint": "8.3.0",
"eslint-plugin-node": "11.1.0",
Expand Down

0 comments on commit 26c9e43

Please sign in to comment.