-
Notifications
You must be signed in to change notification settings - Fork 21
CNV-87995 Add Cypress E2E tests for NNCP, Physical networks, VM networks, and NNS #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| BRIDGE_BASE_ADDRESS="https://console-openshift-console.apps.your-cluster.example.com" | ||
| BRIDGE_KUBEADMIN_PASSWORD="" | ||
| TEST_NS=cy-test-ns | ||
| HIDE_XHR=true | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||
| #!/usr/bin/env bash | ||||||
|
|
||||||
| # Cleanup nmstate test resources from previous runs | ||||||
| # Sources .env for namespace names | ||||||
|
|
||||||
| source .env 2>/dev/null || true | ||||||
| #TEST_NS="${TEST_NS:-cy-test-ns}" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uncomment and use the TEST_NS default. Line 7 is commented out, so 🔧 Proposed fix-#TEST_NS="${TEST_NS:-cy-test-ns}"
+TEST_NS="${TEST_NS:-cy-test-ns}"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| cleanup () { | ||||||
| echo "Cleaning up nmstate ui test resources..." | ||||||
| # NNCPs and VirtualMachineNetworks are cluster-scoped resources — no namespace flag needed | ||||||
| oc delete nncp test-form-nncp test-req-nncp example test-nncp-physical-network --ignore-not-found --wait=true --timeout=180s | ||||||
| oc delete --ignore-not-found=true virtualmachinenetwork test-project-vmn test-labeled-vmn --wait=true --timeout=60s 2>/dev/null || true | ||||||
| echo "Cleanup done." | ||||||
| } | ||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Setup test namespaces (create if they don't exist) | ||
| # Sources .env for namespace names | ||
|
|
||
| source .env 2>/dev/null || true | ||
| TEST_NS="${TEST_NS:-cy-test-ns}" | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| setup () { | ||
| echo "Setting up test namespaces..." | ||
| oc get namespace "${TEST_NS}" 2>/dev/null || oc create namespace "${TEST_NS}" | ||
| echo "Setup done." | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,44 @@ | ||||||||
| #!/usr/bin/env bash | ||||||||
|
|
||||||||
| set +e | ||||||||
|
|
||||||||
| source ./cleanup.sh | ||||||||
| source ./setup.sh | ||||||||
|
|
||||||||
| set -x | ||||||||
|
|
||||||||
| while getopts g:s: flag | ||||||||
| do | ||||||||
| case "${flag}" in | ||||||||
| g) gui=${OPTARG};; | ||||||||
| s) spec=${OPTARG};; | ||||||||
| esac | ||||||||
| done | ||||||||
|
|
||||||||
| if [ -z "${spec-}" ]; then | ||||||||
| spec="tests/all.cy.ts" | ||||||||
| fi | ||||||||
|
|
||||||||
| # Run cleanup and setup before tests | ||||||||
| cleanup | ||||||||
| setup | ||||||||
|
|
||||||||
| cd ui-tests-cy | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling to the If 🛡️ Proposed fix-cd ui-tests-cy
+cd ui-tests-cy || exit 1
npm ci📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.11.0)[warning] 25-25: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164) 🤖 Prompt for AI Agents |
||||||||
| npm ci | ||||||||
| mkdir -p gui-test-screenshots | ||||||||
|
|
||||||||
| if [ -n "${gui-}" ]; then | ||||||||
| npx cypress open --env openshift=true --spec "$spec" | ||||||||
| else | ||||||||
| node --max-old-space-size=4096 ./node_modules/.bin/cypress run --env openshift=true --browser "${BRIDGE_E2E_BROWSER_NAME:=electron}" --spec "$spec" | tee ./gui-test-screenshots/build.log | ||||||||
| test_exit_code=${PIPESTATUS[0]} | ||||||||
| cd .. | ||||||||
| cd ui-tests-cy && npm run cypress-postreport && cd .. | ||||||||
|
|
||||||||
| # Copy JUnit XML to path expected by Jenkins pipeline | ||||||||
| mkdir -p cypress/gui-test-screenshots | ||||||||
| cp ui-tests-cy/gui-test-screenshots/junit_cypress-*.xml cypress/gui-test-screenshots/ 2>/dev/null || true | ||||||||
|
|
||||||||
| cleanup | ||||||||
| exit "${test_exit_code}" | ||||||||
| fi | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "env": { | ||
| "cypress/globals": true, | ||
| "node": true | ||
| }, | ||
| "extends": ["plugin:cypress/recommended"], | ||
| "plugins": ["cypress"], | ||
| "rules": { | ||
| "no-console": "off", | ||
| "no-namespace": "off", | ||
| "no-redeclare": "off", | ||
| "@typescript-eslint/no-var-requires": "off", | ||
| "@typescript-eslint/no-namespace": "off" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| const { defineConfig } = require('cypress'); | ||
|
|
||
| module.exports = defineConfig({ | ||
| chromeWebSecurity: false, | ||
| defaultCommandTimeout: 60000, | ||
| e2e: { | ||
| setupNodeEvents(on, config) { | ||
| return require('./plugins/index.ts')(on, config); | ||
| }, | ||
| specPattern: 'tests/**/*.cy.ts', | ||
| supportFile: 'support/index.ts', | ||
| testIsolation: false, | ||
| }, | ||
| fixturesFolder: false, | ||
| pageLoadTimeout: 120000, | ||
| reporter: './node_modules/cypress-multi-reporters', | ||
| reporterOptions: { configFile: 'reporter-config.json' }, | ||
| retries: { openMode: 0, runMode: 0 }, | ||
| screenshotOnRunFailure: true, | ||
| screenshotsFolder: './gui-test-screenshots/screenshots/', | ||
| trashAssetsBeforeRuns: true, | ||
| video: true, | ||
| videoCompression: false, | ||
| videosFolder: './gui-test-screenshots/videos/', | ||
| viewportHeight: 1080, | ||
| viewportWidth: 1920, | ||
| watchForFileChanges: false, | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.