From 75f49b6f316d423373eadc11a316c45577a1391b Mon Sep 17 00:00:00 2001 From: PeterYurkovich Date: Wed, 12 Aug 2026 15:35:22 -0400 Subject: [PATCH 1/3] feat: run only changed tests --- web/cypress/run-changed.sh | 62 ++++++++++++++++++++++++++++++++++++++ web/package.json | 3 +- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 web/cypress/run-changed.sh diff --git a/web/cypress/run-changed.sh b/web/cypress/run-changed.sh new file mode 100644 index 000000000..a7a7dcc97 --- /dev/null +++ b/web/cypress/run-changed.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +CHANGED_FILES=$(git diff --name-only origin/main...HEAD) + +RUN_ALL=false +declare -A TAGS_TO_RUN + +# Create frontend folder to tag map +declare -A FEATURE_MAP +FEATURE_MAP["incidents"]="@cluster-health-analyzer" +FEATURE_MAP["alerts"]="@alerting" +FEATURE_MAP["legacy-dashboards"]="@legacy-dashboards" +FEATURE_MAP["metrics"]="@metrics" +FEATURE_MAP["perses-dashboards"]="@perses-dashboards" +FEATURE_MAP["targets"]="@targets" + +for FILE in $CHANGED_FILES; do + + # Check if any file is outside of web/src/features/ + if [[ ! "$FILE" =~ ^web/src/features/ ]]; then + echo "Global or shared file changed: $FILE" + RUN_ALL=true + break + fi + + # File is in features and looks like: web/src/features/incidents/components/App.tsx + # awk splits by '/' and grabs the 4th segment + FEATURE_DIR=$(echo "$FILE" | awk -F'/' '{print $4}') + CYPRESS_TAG=${FEATURE_MAP[$FEATURE_DIR]} + + if [ -n "$CYPRESS_TAG" ]; then + TAGS_TO_RUN["$CYPRESS_TAG"]=1 + else + echo "Error: Unmapped feature directory changed: $FEATURE_DIR" + exit 1 + fi +done + +if [ "$RUN_ALL" = true ]; then + echo "Changes affect global scope or unmapped features. Running ALL monitoring tests..." + + DEFAULT_TAGS="@alerting @legacy-dashboards @metrics @targets acm-alerting @cluster-health-analyzer @perses-dashboards --@flaky --@xfail" + npm run test-cypress-monitoring:base -- --env grepTags="${DEFAULT_TAGS}" +else + UNIQUE_TAGS=("${!TAGS_TO_RUN[@]}") + + if [ ${#UNIQUE_TAGS[@]} -eq 0 ]; then + echo "No relevant source files changed. Skipping tests." + exit 0 + fi + + FEATURE_TAGS=$( + IFS=" " + echo "${UNIQUE_TAGS[*]}" + ) + + GREP_TAGS="${FEATURE_TAGS} --@flaky --@xfail" + + echo "Running specific tests for tags: $GREP_TAGS" + + npm run test-cypress-monitoring:base -- --env grepTags="${GREP_TAGS}" +fi diff --git a/web/package.json b/web/package.json index 612a4d0be..3f57807c2 100644 --- a/web/package.json +++ b/web/package.json @@ -30,7 +30,8 @@ "test": "npm run cypress:run:ci", "test-cypress-console": "./node_modules/.bin/cypress open --browser chrome", "test-cypress-console-headless": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless", - "test-cypress-monitoring": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@alerting @legacy-dashboards @metrics @targets --@flaky --@xfail --@virtualization --@coo'", + "test-cypress-monitoring": "../scripts/run-selective-e2e.sh", + "test-cypress-monitoring:base": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless", "test-cypress-monitoring-dev": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@alerting @legacy-dashboards @metrics @targets --@xfail --@virtualization --@coo'", "test-cypress-monitoring-bvt": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@alerting @legacy-dashboards @metrics @targets --@xfail --@virtualization --@coo'", "test-cypress-monitoring-regression": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@alerting @legacy-dashboards @metrics @targets --@flaky --@xfail --@virtualization --@coo'", From b3e682672252999df57cd98a8d3b858257f422b1 Mon Sep 17 00:00:00 2001 From: PeterYurkovich Date: Mon, 17 Aug 2026 15:27:17 -0400 Subject: [PATCH 2/3] fix: remove last instance of 'cypress/` --- web/cypress/support/alerts/alerts_regressions.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/cypress/support/alerts/alerts_regressions.cy.ts b/web/cypress/support/alerts/alerts_regressions.cy.ts index 8db91613a..75e78a626 100644 --- a/web/cypress/support/alerts/alerts_regressions.cy.ts +++ b/web/cypress/support/alerts/alerts_regressions.cy.ts @@ -18,7 +18,7 @@ import { WatchdogAlert, } from '../../fixtures/shared/cluster-monitoring-operator/constants'; import { FilterOUIAIDs } from '@/shared/constants/data-test'; -import { listPage } from 'cypress/views/shared/list-page'; +import { listPage } from '../../views/shared/list-page'; export interface PerspectiveConfig { name: string; From 3ce73879275ff148ae5e63a6f3e96dfb268464cc Mon Sep 17 00:00:00 2001 From: PeterYurkovich Date: Mon, 17 Aug 2026 15:42:42 -0400 Subject: [PATCH 3/3] chore: update documentation --- AGENTS.md | 11 ++++------- web/cypress/CYPRESS_TESTING_GUIDE.md | 11 +++++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a36c45608..243665c10 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -302,16 +302,13 @@ You should create new Cypress tests when: #### Quick Test Commands ```bash -cd web/cypress - -# Run all regression tests -npm run cypress:run --spec "cypress/e2e/**/regression/**" +cd web -# Run BVT (Build Verification Tests) -npm run cypress:run --spec "cypress/e2e/monitoring/00.bvt_admin.cy.ts" +# Run monitoring tests (changed files only) +npm run test-cypress-monitoring # Run COO tests -npm run cypress:run --spec "cypress/e2e/coo/*.cy.ts" +npx cypress run --env grepTags='@acm-alerting @perses-dashboards @cluster-health-analyzer --@flaky --@xfail' # Interactive mode npm run cypress:open diff --git a/web/cypress/CYPRESS_TESTING_GUIDE.md b/web/cypress/CYPRESS_TESTING_GUIDE.md index d27d98517..c93f62574 100644 --- a/web/cypress/CYPRESS_TESTING_GUIDE.md +++ b/web/cypress/CYPRESS_TESTING_GUIDE.md @@ -228,11 +228,14 @@ export const runAlertTests = (perspective: string) => { ### Common Commands ```bash -cd web/cypress +cd web + +# Run all monitoring tests (changed files only) +npm run test-cypress-monitoring # Run specific tests -npm run cypress:run -- --spec "cypress/e2e/alerts/alerts_regression.cy.ts" -npm run cypress:run -- --spec "cypress/e2e/metrics/metrics_regression.cy.ts" +npx cypress run --spec "cypress/e2e/alerts/alerts_regression.cy.ts" +npx cypress run --spec "cypress/e2e/metrics/metrics_regression.cy.ts" # Interactive mode (GUI) npm run cypress:open @@ -278,7 +281,7 @@ source ./configure-env.sh 3. **Run with debug**: ```bash export CYPRESS_DEBUG=true - npm run cypress:run + npm run test-cypress-monitoring ``` 4. **Run interactively**: ```bash