diff --git a/.github/actions/e2e/action.yml b/.github/actions/e2e/action.yml index 7a951582d0..22b3da57f2 100644 --- a/.github/actions/e2e/action.yml +++ b/.github/actions/e2e/action.yml @@ -80,7 +80,7 @@ runs: env: PLAYWRIGHT_TARGET_ENV: ${{ inputs.target }} run: | - if [[ $PLAYWRIGHT_TARGET_ENV != "local" && $PLAYWRIGHT_TARGET_ENV != "staging" ]]; then echo "invalid e2e test target provided" && exit 1; fi + if [[ $PLAYWRIGHT_TARGET_ENV != "local" && $PLAYWRIGHT_TARGET_ENV != "staging" && $PLAYWRIGHT_TARGET_ENV != "grantor1" && $PLAYWRIGHT_TARGET_ENV != "grantor2" && $PLAYWRIGHT_TARGET_ENV != "grantee1" && $PLAYWRIGHT_TARGET_ENV != "grantee2" ]]; then echo "invalid e2e test target provided" && exit 1; fi - name: Check out code uses: actions/checkout@v6 @@ -133,7 +133,20 @@ runs: if [[ ${{ inputs.target }} = "staging" ]]; then echo "base_url=https://staging.simpler.grants.gov" >> "$GITHUB_ENV" echo "api_url=https://api.staging.simpler.grants.gov" >> "$GITHUB_ENV" + elif [[ ${{ inputs.target }} = "grantor1" ]]; then + echo "base_url=https://grantor1.teams.simpler.grants.gov" >> "$GITHUB_ENV" + echo "api_url=https://api.grantor1.teams.simpler.grants.gov" >> "$GITHUB_ENV" + elif [[ ${{ inputs.target }} = "grantor2" ]]; then + echo "base_url=https://grantor2.teams.simpler.grants.gov" >> "$GITHUB_ENV" + echo "api_url=https://api.grantor2.teams.simpler.grants.gov" >> "$GITHUB_ENV" + elif [[ ${{ inputs.target }} = "grantee1" ]]; then + echo "base_url=https://grantee1.teams.simpler.grants.gov" >> "$GITHUB_ENV" + echo "api_url=https://api.grantee1.teams.simpler.grants.gov" >> "$GITHUB_ENV" + elif [[ ${{ inputs.target }} = "grantee2" ]]; then + echo "base_url=https://grantee2.teams.simpler.grants.gov" >> "$GITHUB_ENV" + echo "api_url=https://api.grantee2.teams.simpler.grants.gov" >> "$GITHUB_ENV" fi + - name: Run all e2e tests (Shard ${{ inputs.current_shard }}/${{ inputs.total_shards }}) if: ${{ inputs.playwright_tags == '' }} working-directory: ./frontend diff --git a/.github/workflows/e2e-create-report.yml b/.github/workflows/e2e-create-report.yml index e64bd2517a..fa8269181a 100644 --- a/.github/workflows/e2e-create-report.yml +++ b/.github/workflows/e2e-create-report.yml @@ -55,12 +55,26 @@ jobs: # run: | # npx playwright install --with-deps + - name: Check target environment + run: | + if [[ "${{ inputs.target }}" != "local" && "${{ inputs.target }}" != "staging" && "${{ inputs.target }}" != "grantee1" && "${{ inputs.target }}" != "grantee2" && "${{ inputs.target }}" != "grantor1" && "${{ inputs.target }}" != "grantor2" ]]; then + echo "Unsupported target environment" + exit 1 + fi + - name: Set target environment + run: | + if [[ -z "${{ inputs.target }}" ]]; then + echo "defaulted_target=staging" >> "$GITHUB_ENV"; + else + echo "defaulted_target=${{ inputs.target }}" >> "$GITHUB_ENV"; + fi + - name: Download All Blob Reports uses: actions/download-artifact@v7 with: path: frontend/all-blob-reports run-id: ${{ inputs.run_id }} - pattern: blob-report-shard-${{ inputs.target }}-* + pattern: blob-report-shard-${{ env.defaulted_target }}-* merge-multiple: true - name: Verify Downloaded Artifacts run: | @@ -75,6 +89,6 @@ jobs: - name: Upload Merged HTML Report uses: actions/upload-artifact@v7 with: - name: merged-html-report-${{ inputs.target }} + name: merged-html-report-${{ env.defaulted_target }} path: frontend/playwright-report retention-days: 30 diff --git a/.github/workflows/e2e-staging.yml b/.github/workflows/e2e-staging.yml index d899d760dc..03d2880bfc 100644 --- a/.github/workflows/e2e-staging.yml +++ b/.github/workflows/e2e-staging.yml @@ -16,6 +16,10 @@ on: type: choice options: - staging + - grantee1 + - grantee2 + - grantor1 + - grantor2 playwright_tags: description: "pipe separated list of @tags denoting groups of tests to run (e.g. @smoke|@core-regression). Leave blank to run all tests" type: string @@ -39,10 +43,21 @@ jobs: e2e-tests-deployed: runs-on: ubuntu-22.04 steps: + - name: Check target environment + run: | + if [[ "${{ inputs.target }}" != "staging" && "${{ inputs.target }}" != "grantee1" && "${{ inputs.target }}" != "grantee2" && "${{ inputs.target }}" != "grantor1" && "${{ inputs.target }}" != "grantor2" ]]; then + echo "Unsupported target environment" + exit 1 + fi - name: Checkout repository uses: actions/checkout@v6 - - name: Set target - run: if [[ -z "${{ inputs.target }}" ]]; then echo "defaulted_target=staging" >> "$GITHUB_ENV"; else echo "defaulted_target=${{ inputs.target }}" >> "$GITHUB_ENV"; fi + - name: Set target environment + run: | + if [[ -z "${{ inputs.target }}" ]]; then + echo "defaulted_target=staging" >> "$GITHUB_ENV"; + else + echo "defaulted_target=${{ inputs.target }}" >> "$GITHUB_ENV"; + fi - name: Determine test groups to run shell: bash run: | @@ -74,7 +89,7 @@ jobs: secrets: inherit with: run_id: ${{ github.run_id }} - target: ${{ inputs.target || 'staging' }} + target: ${{ inputs.target }} send-slack-notification: if: failure() needs: [create-report] diff --git a/frontend/.env.local.example b/frontend/.env.local.example index 0962aaabef..5a711d7f8f 100644 --- a/frontend/.env.local.example +++ b/frontend/.env.local.example @@ -128,6 +128,7 @@ CI= # Only needed if running end-to-end tests with Playwright # See: frontend/tests/e2e/playwright-env.ts + # Target environment info for playwright tests # Defaults to local, set to staging, or grantor/grantee environment to run tests there instead PLAYWRIGHT_TARGET_ENV= @@ -147,3 +148,4 @@ TEST_USER_MANAGER_API_KEY=local-manager-key # Playwright shard configuration (for parallel test execution) TOTAL_SHARDS= CURRENT_SHARD= + diff --git a/frontend/tests/e2e/apply/fixtures/general-apply-fixtures.ts b/frontend/tests/e2e/apply/fixtures/general-apply-fixtures.ts new file mode 100644 index 0000000000..30cfc52dc2 --- /dev/null +++ b/frontend/tests/e2e/apply/fixtures/general-apply-fixtures.ts @@ -0,0 +1,6 @@ +import playwrightEnv from "tests/e2e/playwright-env"; + +export const OPPORTUNITY_ID = + playwrightEnv.targetEnv !== "local" + ? "39df8091-6e99-4b0f-9db7-1f3aca9cb6e5" + : "c3c59562-a54f-4203-b0f6-98f2f0383481"; diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-budget-narrative-attachment.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-budget-narrative-attachment.spec.ts index 6a6b94f82b..de05f6d2cd 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-budget-narrative-attachment.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-budget-narrative-attachment.spec.ts @@ -14,6 +14,7 @@ import { BUDGET_NARRATIVE_ATTACHMENT_FORM_MATCHER, BUDGET_NARRATIVE_ATTACHMENT_REQUIRED_FIELD_ERRORS, } from "tests/e2e/apply/fixtures/budget-narrative-attachment-field-definitions"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; @@ -27,15 +28,8 @@ import { } from "tests/e2e/utils/forms/verify-form-status-utils"; const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; +const { testOrgLabel } = playwrightEnv; -// Environment-specific opportunity IDs -// Staging: 39df8091-6e99-4b0f-9db7-1f3aca9cb6e5 -// Local: c3c59562-a54f-4203-b0f6-98f2f0383481 -const OPPORTUNITY_ID = - targetEnv === "staging" - ? "39df8091-6e99-4b0f-9db7-1f3aca9cb6e5" - : "c3c59562-a54f-4203-b0f6-98f2f0383481"; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-cd511.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-cd511.spec.ts index 5c6b1b4b45..66ec96fb85 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-cd511.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-cd511.spec.ts @@ -14,10 +14,10 @@ import { CD511_FORM_MATCHER, CD511_REQUIRED_FIELD_ERRORS, } from "tests/e2e/apply/fixtures/cd511-field-definitions"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; -import { getOpportunityId } from "tests/e2e/utils/application/get-opportunityId-utils"; import { authenticateE2eUser } from "tests/e2e/utils/auth/authenticate-e2e-user-utils"; import { skipNonChromeOnStaging } from "tests/e2e/utils/auth/skip-non-chrome-staging-utils"; import { openForm } from "tests/e2e/utils/forms/form-navigation-utils"; @@ -30,7 +30,7 @@ import { const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; const { testOrgLabel } = playwrightEnv; -const OPPORTUNITY_URL = `/opportunity/${getOpportunityId()}`; +const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging test.beforeEach(({ page: _ }, testInfo) => { diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-epa-keycontacts.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-epa-keycontacts.spec.ts index 91db191473..0768694b8a 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-epa-keycontacts.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-epa-keycontacts.spec.ts @@ -16,6 +16,7 @@ import { fieldDefinitionsEPAKeyContacts, } from "tests/e2e/apply/fixtures/epa-key-contacts-field-definitions"; import { epaKeyContactsFailurePathTestData } from "tests/e2e/apply/fixtures/epa-key-contacts-fill-data"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; @@ -30,15 +31,8 @@ import { } from "tests/e2e/utils/forms/verify-form-status-utils"; const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; +const { testOrgLabel } = playwrightEnv; -// Environment-specific opportunity IDs -// Staging: 39cf0a5c-5fed-40b4-8f46-5374101ae419 -// Local: c3c59562-a54f-4203-b0f6-98f2f0383481 -const OPPORTUNITY_ID = - targetEnv === "staging" - ? "39cf0a5c-5fed-40b4-8f46-5374101ae419" - : "c3c59562-a54f-4203-b0f6-98f2f0383481"; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-epa4700-4.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-epa4700-4.spec.ts index 24dd54c1a5..fb2c08cdf1 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-epa4700-4.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-epa4700-4.spec.ts @@ -14,10 +14,10 @@ import { EPA4700_4_FORM_MATCHER, EPA4700_4_REQUIRED_FIELD_ERRORS, } from "tests/e2e/apply/fixtures/epa4700-4-field-definitions"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; -import { getOpportunityId } from "tests/e2e/utils/application/get-opportunityId-utils"; import { authenticateE2eUser } from "tests/e2e/utils/auth/authenticate-e2e-user-utils"; import { skipNonChromeOnStaging } from "tests/e2e/utils/auth/skip-non-chrome-staging-utils"; import { openForm } from "tests/e2e/utils/forms/form-navigation-utils"; @@ -30,7 +30,7 @@ import { const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; const { testOrgLabel } = playwrightEnv; -const OPPORTUNITY_URL = `/opportunity/${getOpportunityId()}`; +const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging test.beforeEach(({ page: _ }, testInfo) => { diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-grantsgov-lobbying.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-grantsgov-lobbying.spec.ts index e6cf9ba9f8..7bed631453 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-grantsgov-lobbying.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-grantsgov-lobbying.spec.ts @@ -10,6 +10,7 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { GRANTSGOV_LOBBYING_FORM_MATCHER, GRANTSGOV_LOBBYING_REQUIRED_FIELD_ERRORS, @@ -27,15 +28,8 @@ import { } from "tests/e2e/utils/forms/verify-form-status-utils"; const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; +const { testOrgLabel } = playwrightEnv; -// Environment-specific opportunity IDs -// Staging: 39cf0a5c-5fed-40b4-8f46-5374101ae419 -// Local: c3c59562-a54f-4203-b0f6-98f2f0383481 -const OPPORTUNITY_ID = - targetEnv === "staging" - ? "39cf0a5c-5fed-40b4-8f46-5374101ae419" - : "c3c59562-a54f-4203-b0f6-98f2f0383481"; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-other-narrative-attachment.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-other-narrative-attachment.spec.ts index e928f35c22..a2bdc70c04 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-other-narrative-attachment.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-other-narrative-attachment.spec.ts @@ -10,6 +10,7 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { OTHER_NARRATIVE_ATTACHMENT_FORM_MATCHER, OTHER_NARRATIVE_ATTACHMENT_REQUIRED_FIELD_ERRORS, @@ -27,15 +28,8 @@ import { } from "tests/e2e/utils/forms/verify-form-status-utils"; const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; +const { testOrgLabel } = playwrightEnv; -// Environment-specific opportunity IDs -// Staging: 39df8091-6e99-4b0f-9db7-1f3aca9cb6e5 -// Local: c3c59562-a54f-4203-b0f6-98f2f0383481 -const OPPORTUNITY_ID = - targetEnv === "staging" - ? "39df8091-6e99-4b0f-9db7-1f3aca9cb6e5" - : "c3c59562-a54f-4203-b0f6-98f2f0383481"; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-abstract-summary.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-abstract-summary.spec.ts index 9b9365d4ef..d7c3a29919 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-abstract-summary.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-abstract-summary.spec.ts @@ -10,6 +10,7 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { PROJECT_ABSTRACT_SUMMARY_FORM_MATCHER, PROJECT_ABSTRACT_SUMMARY_REQUIRED_FIELD_ERRORS, @@ -17,7 +18,6 @@ import { import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; -import { getOpportunityId } from "tests/e2e/utils/application/get-opportunityId-utils"; import { authenticateE2eUser } from "tests/e2e/utils/auth/authenticate-e2e-user-utils"; import { skipNonChromeOnStaging } from "tests/e2e/utils/auth/skip-non-chrome-staging-utils"; import { openForm } from "tests/e2e/utils/forms/form-navigation-utils"; @@ -29,7 +29,7 @@ import { const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; const { testOrgLabel } = playwrightEnv; -const OPPORTUNITY_URL = `/opportunity/${getOpportunityId()}`; +const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging test.beforeEach(({ page: _ }, testInfo) => { diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-abstract.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-abstract.spec.ts index 61071a1c8e..7f3fdb926f 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-abstract.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-abstract.spec.ts @@ -10,6 +10,7 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { PROJECT_ABSTRACT_FORM_MATCHER, PROJECT_ABSTRACT_REQUIRED_FIELD_ERRORS, @@ -27,15 +28,8 @@ import { } from "tests/e2e/utils/forms/verify-form-status-utils"; const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; +const { testOrgLabel } = playwrightEnv; -// Environment-specific opportunity IDs -// Staging: 39cf0a5c-5fed-40b4-8f46-5374101ae419 -// Local: c3c59562-a54f-4203-b0f6-98f2f0383481 -const OPPORTUNITY_ID = - targetEnv === "staging" - ? "39cf0a5c-5fed-40b4-8f46-5374101ae419" - : "c3c59562-a54f-4203-b0f6-98f2f0383481"; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-narrative-attachment.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-narrative-attachment.spec.ts index 93fcf7f5b5..8c55132095 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-narrative-attachment.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-project-narrative-attachment.spec.ts @@ -10,6 +10,7 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { PROJECT_NARRATIVE_ATTACHMENT_FORM_MATCHER, PROJECT_NARRATIVE_ATTACHMENT_REQUIRED_FIELD_ERRORS, @@ -27,15 +28,8 @@ import { } from "tests/e2e/utils/forms/verify-form-status-utils"; const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; +const { testOrgLabel } = playwrightEnv; -// Environment-specific opportunity IDs -// Staging: 39df8091-6e99-4b0f-9db7-1f3aca9cb6e5 -// Local: c3c59562-a54f-4203-b0f6-98f2f0383481 -const OPPORTUNITY_ID = - targetEnv === "staging" - ? "39df8091-6e99-4b0f-9db7-1f3aca9cb6e5" - : "c3c59562-a54f-4203-b0f6-98f2f0383481"; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424.spec.ts index 5bc336f9bd..f4907302d1 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424.spec.ts @@ -10,6 +10,7 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { SF424_FORM_MATCHER, SF424_REQUIRED_FIELD_ERRORS, @@ -17,7 +18,6 @@ import { import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; -import { getOpportunityId } from "tests/e2e/utils/application/get-opportunityId-utils"; import { authenticateE2eUser } from "tests/e2e/utils/auth/authenticate-e2e-user-utils"; import { skipNonChromeOnStaging } from "tests/e2e/utils/auth/skip-non-chrome-staging-utils"; import { openForm } from "tests/e2e/utils/forms/form-navigation-utils"; @@ -30,7 +30,7 @@ import { const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; const { testOrgLabel } = playwrightEnv; -const OPPORTUNITY_URL = `/opportunity/${getOpportunityId()}`; +const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging test.beforeEach(({ page: _ }, testInfo) => { diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424a.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424a.spec.ts index 1dd0838778..0e4a71f298 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424a.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424a.spec.ts @@ -10,15 +10,12 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { SF424A_ALERT_ERRORS, SF424A_FORM_MATCHER, SF424A_REQUIRED_FIELD_ERRORS, } from "tests/e2e/apply/fixtures/sf424a-field-definitions"; -import { - testdata_local_environment, - testdata_staging_environment, -} from "tests/e2e/opportunity-id-data"; import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; @@ -33,11 +30,7 @@ import { const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; -const OPPORTUNITY_ID = - targetEnv === "staging" - ? testdata_staging_environment.opportunityID - : testdata_local_environment.opportunityID; +const { testOrgLabel } = playwrightEnv; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424d.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424d.spec.ts index 8b9ee9967c..253135138d 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424d.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sf424d.spec.ts @@ -10,6 +10,7 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { SF424D_FORM_MATCHER, SF424D_REQUIRED_FIELD_ERRORS, @@ -17,7 +18,6 @@ import { import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; -import { getOpportunityId } from "tests/e2e/utils/application/get-opportunityId-utils"; import { authenticateE2eUser } from "tests/e2e/utils/auth/authenticate-e2e-user-utils"; import { skipNonChromeOnStaging } from "tests/e2e/utils/auth/skip-non-chrome-staging-utils"; import { openForm } from "tests/e2e/utils/forms/form-navigation-utils"; @@ -29,7 +29,7 @@ import { const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; const { testOrgLabel } = playwrightEnv; -const OPPORTUNITY_URL = `/opportunity/${getOpportunityId()}`; +const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging test.beforeEach(({ page: _ }, testInfo) => { diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sflll.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sflll.spec.ts index 5a1ebae503..452f526310 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sflll.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-sflll.spec.ts @@ -33,7 +33,7 @@ const { testOrgLabel, targetEnv } = playwrightEnv; // Staging: 39cf0a5c-5fed-40b4-8f46-5374101ae419 // Local: c3c59562-a54f-4203-b0f6-98f2f0383481 const OPPORTUNITY_ID = - targetEnv === "staging" + targetEnv !== "local" ? "39cf0a5c-5fed-40b4-8f46-5374101ae419" : "c3c59562-a54f-4203-b0f6-98f2f0383481"; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; diff --git a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-suppcoversheet-neh-grantsprogram.spec.ts b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-suppcoversheet-neh-grantsprogram.spec.ts index 0847122992..1baf3c6695 100644 --- a/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-suppcoversheet-neh-grantsprogram.spec.ts +++ b/frontend/tests/e2e/apply/forms/failure-path/specs/failure-path-suppcoversheet-neh-grantsprogram.spec.ts @@ -10,6 +10,7 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { SUPP_COVER_SHEET_NEH_FORM_MATCHER, SUPP_COVER_SHEET_NEH_REQUIRED_FIELD_ERRORS, @@ -27,15 +28,8 @@ import { } from "tests/e2e/utils/forms/verify-form-status-utils"; const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; +const { testOrgLabel } = playwrightEnv; -// Environment-specific opportunity IDs -// Staging: 39df8091-6e99-4b0f-9db7-1f3aca9cb6e5 -// Local: c3c59562-a54f-4203-b0f6-98f2f0383481 -const OPPORTUNITY_ID = - targetEnv === "staging" - ? "39df8091-6e99-4b0f-9db7-1f3aca9cb6e5" - : "c3c59562-a54f-4203-b0f6-98f2f0383481"; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging diff --git a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-budget-narrative-attachment.spec.ts b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-budget-narrative-attachment.spec.ts index 50f655899b..deecd0d01e 100644 --- a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-budget-narrative-attachment.spec.ts +++ b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-budget-narrative-attachment.spec.ts @@ -12,6 +12,7 @@ import { } from "@playwright/test"; import { BUDGET_NARRATIVE_ATTACHMENT_FORM_CONFIG } from "tests/e2e/apply/fixtures/budget-narrative-attachment-field-definitions"; import { budgetNarrativeAttachmentHappyPathTestData } from "tests/e2e/apply/fixtures/budget-narrative-attachment-fill-data"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; @@ -21,15 +22,8 @@ import { fillForm } from "tests/e2e/utils/forms/general-forms-filling"; import { verifyFormStatusAfterSave } from "tests/e2e/utils/forms/verify-form-status-utils"; const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; +const { testOrgLabel } = playwrightEnv; -// Environment-specific opportunity IDs -// Staging: 39df8091-6e99-4b0f-9db7-1f3aca9cb6e5 -// Local: c3c59562-a54f-4203-b0f6-98f2f0383481 -const OPPORTUNITY_ID = - targetEnv === "staging" - ? "39df8091-6e99-4b0f-9db7-1f3aca9cb6e5" - : "c3c59562-a54f-4203-b0f6-98f2f0383481"; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging diff --git a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-cd511.spec.ts b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-cd511.spec.ts index ab05ef671a..fd1ab97bc2 100644 --- a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-cd511.spec.ts +++ b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-cd511.spec.ts @@ -12,10 +12,10 @@ import { } from "@playwright/test"; import { CD511_FORM_CONFIG } from "tests/e2e/apply/fixtures/cd511-field-definitions"; import { cd511HappyPathTestData } from "tests/e2e/apply/fixtures/cd511-fill-data"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; -import { getOpportunityId } from "tests/e2e/utils/application/get-opportunityId-utils"; import { authenticateE2eUser } from "tests/e2e/utils/auth/authenticate-e2e-user-utils"; import { skipNonChromeOnStaging } from "tests/e2e/utils/auth/skip-non-chrome-staging-utils"; import { fillForm } from "tests/e2e/utils/forms/general-forms-filling"; @@ -23,7 +23,8 @@ import { verifyFormStatusAfterSave } from "tests/e2e/utils/forms/verify-form-sta const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; const { testOrgLabel } = playwrightEnv; -const OPPORTUNITY_URL = `/opportunity/${getOpportunityId()}`; + +const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging test.beforeEach(({ page: _ }, testInfo) => { diff --git a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-epa-keycontacts.spec.ts b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-epa-keycontacts.spec.ts index d83d77d9b8..9be8785759 100644 --- a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-epa-keycontacts.spec.ts +++ b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-epa-keycontacts.spec.ts @@ -12,10 +12,10 @@ import { } from "@playwright/test"; import { EPA_KEY_CONTACTS_FORM_CONFIG } from "tests/e2e/apply/fixtures/epa-key-contacts-field-definitions"; import { epaKeyContactsHappyPathTestData } from "tests/e2e/apply/fixtures/epa-key-contacts-fill-data"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; -import { getOpportunityId } from "tests/e2e/utils/application/get-opportunityId-utils"; import { authenticateE2eUser } from "tests/e2e/utils/auth/authenticate-e2e-user-utils"; import { skipNonChromeOnStaging } from "tests/e2e/utils/auth/skip-non-chrome-staging-utils"; import { fillForm } from "tests/e2e/utils/forms/general-forms-filling"; @@ -23,7 +23,7 @@ import { verifyFormStatusAfterSave } from "tests/e2e/utils/forms/verify-form-sta const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; const { testOrgLabel } = playwrightEnv; -const OPPORTUNITY_URL = `/opportunity/${getOpportunityId()}`; +const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging to avoid OTP rate-limiting test.beforeEach(({ page: _ }, testInfo) => { diff --git a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-epa4700-4.spec.ts b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-epa4700-4.spec.ts index 51ada808ff..88884a90ed 100644 --- a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-epa4700-4.spec.ts +++ b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-epa4700-4.spec.ts @@ -12,10 +12,10 @@ import { } from "@playwright/test"; import { EPA4700_4_FORM_CONFIG } from "tests/e2e/apply/fixtures/epa4700-4-field-definitions"; import { epa4700_4HappyPathTestData } from "tests/e2e/apply/fixtures/epa4700-4-fill-data"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; -import { getOpportunityId } from "tests/e2e/utils/application/get-opportunityId-utils"; import { authenticateE2eUser } from "tests/e2e/utils/auth/authenticate-e2e-user-utils"; import { skipNonChromeOnStaging } from "tests/e2e/utils/auth/skip-non-chrome-staging-utils"; import { fillForm } from "tests/e2e/utils/forms/general-forms-filling"; @@ -24,7 +24,7 @@ import { verifyFormStatusAfterSave } from "tests/e2e/utils/forms/verify-form-sta const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; const { testOrgLabel } = playwrightEnv; -const OPPORTUNITY_URL = `/opportunity/${getOpportunityId()}`; +const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging test.beforeEach(({ page: _ }, testInfo) => { diff --git a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-other-narrative-attachment.spec.ts b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-other-narrative-attachment.spec.ts index e71b30b17e..f9443e1a6e 100644 --- a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-other-narrative-attachment.spec.ts +++ b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-other-narrative-attachment.spec.ts @@ -10,6 +10,7 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { OTHER_NARRATIVE_ATTACHMENT_FORM_CONFIG } from "tests/e2e/apply/fixtures/other-narrative-attachment-field-definitions"; import { otherNarrativeAttachmentHappyPathTestData } from "tests/e2e/apply/fixtures/other-narrative-attachment-fill-data"; import playwrightEnv from "tests/e2e/playwright-env"; @@ -21,15 +22,7 @@ import { fillForm } from "tests/e2e/utils/forms/general-forms-filling"; import { verifyFormStatusAfterSave } from "tests/e2e/utils/forms/verify-form-status-utils"; const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; - -// Environment-specific opportunity IDs -// Staging: 39df8091-6e99-4b0f-9db7-1f3aca9cb6e5 -// Local: c3c59562-a54f-4203-b0f6-98f2f0383481 -const OPPORTUNITY_ID = - targetEnv === "staging" - ? "39df8091-6e99-4b0f-9db7-1f3aca9cb6e5" - : "c3c59562-a54f-4203-b0f6-98f2f0383481"; +const { testOrgLabel } = playwrightEnv; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; diff --git a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-project-abstract.spec.ts b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-project-abstract.spec.ts index a88519d0f4..5d741c3b6f 100644 --- a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-project-abstract.spec.ts +++ b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-project-abstract.spec.ts @@ -10,6 +10,7 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { PROJECT_ABSTRACT_FORM_CONFIG } from "tests/e2e/apply/fixtures/project-abstract-field-definitions"; import { projectAbstractHappyPathTestData } from "tests/e2e/apply/fixtures/project-abstract-fill-data"; import playwrightEnv from "tests/e2e/playwright-env"; @@ -21,15 +22,8 @@ import { fillForm } from "tests/e2e/utils/forms/general-forms-filling"; import { verifyFormStatusAfterSave } from "tests/e2e/utils/forms/verify-form-status-utils"; const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; +const { testOrgLabel } = playwrightEnv; -// Environment-specific opportunity IDs -// Staging: 39cf0a5c-5fed-40b4-8f46-5374101ae419 -// Local: c3c59562-a54f-4203-b0f6-98f2f0383481 -const OPPORTUNITY_ID = - targetEnv === "staging" - ? "39cf0a5c-5fed-40b4-8f46-5374101ae419" - : "c3c59562-a54f-4203-b0f6-98f2f0383481"; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging diff --git a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-project-narrative-attachment.spec.ts b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-project-narrative-attachment.spec.ts index 2d28059c94..016ca9a2ea 100644 --- a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-project-narrative-attachment.spec.ts +++ b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-project-narrative-attachment.spec.ts @@ -10,6 +10,7 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { PROJECT_NARRATIVE_ATTACHMENT_FORM_CONFIG } from "tests/e2e/apply/fixtures/project-narrative-attachment-field-definitions"; import { projectNarrativeAttachmentHappyPathTestData } from "tests/e2e/apply/fixtures/project-narrative-attachment-fill-data"; import playwrightEnv from "tests/e2e/playwright-env"; @@ -21,15 +22,7 @@ import { fillForm } from "tests/e2e/utils/forms/general-forms-filling"; import { verifyFormStatusAfterSave } from "tests/e2e/utils/forms/verify-form-status-utils"; const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; -const { testOrgLabel, targetEnv } = playwrightEnv; - -// Environment-specific opportunity IDs -// Staging: 39df8091-6e99-4b0f-9db7-1f3aca9cb6e5 -// Local: c3c59562-a54f-4203-b0f6-98f2f0383481 -const OPPORTUNITY_ID = - targetEnv === "staging" - ? "39df8091-6e99-4b0f-9db7-1f3aca9cb6e5" - : "c3c59562-a54f-4203-b0f6-98f2f0383481"; +const { testOrgLabel } = playwrightEnv; const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; diff --git a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-sf424d.spec.ts b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-sf424d.spec.ts index 5849c43033..78140b054d 100644 --- a/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-sf424d.spec.ts +++ b/frontend/tests/e2e/apply/forms/happy-path/specs/happy-path-sf424d.spec.ts @@ -9,12 +9,12 @@ import { type Page, type TestInfo, } from "@playwright/test"; +import { OPPORTUNITY_ID } from "tests/e2e/apply/fixtures/general-apply-fixtures"; import { SF424D_FORM_CONFIG } from "tests/e2e/apply/fixtures/sf424d-field-definitions"; import { sf424DHappyPathTestData } from "tests/e2e/apply/fixtures/sf424d-fill-data"; import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createApplication } from "tests/e2e/utils/application/create-application-utils"; -import { getOpportunityId } from "tests/e2e/utils/application/get-opportunityId-utils"; import { authenticateE2eUser } from "tests/e2e/utils/auth/authenticate-e2e-user-utils"; import { skipNonChromeOnStaging } from "tests/e2e/utils/auth/skip-non-chrome-staging-utils"; import { fillForm } from "tests/e2e/utils/forms/general-forms-filling"; @@ -22,7 +22,7 @@ import { verifyFormStatusAfterSave } from "tests/e2e/utils/forms/verify-form-sta const { APPLY, APPLY_FORMS, CORE_REGRESSION } = VALID_TAGS; const { testOrgLabel } = playwrightEnv; -const OPPORTUNITY_URL = `/opportunity/${getOpportunityId()}`; +const OPPORTUNITY_URL = `/opportunity/${OPPORTUNITY_ID}`; // Skip non-Chrome browsers in staging test.beforeEach(({ page: _ }, testInfo) => { diff --git a/frontend/tests/e2e/login/specs/login-with-login-gov.spec.ts b/frontend/tests/e2e/login/specs/login-with-login-gov.spec.ts index 9c5d60eb13..3f46e7ddf2 100644 --- a/frontend/tests/e2e/login/specs/login-with-login-gov.spec.ts +++ b/frontend/tests/e2e/login/specs/login-with-login-gov.spec.ts @@ -28,7 +28,7 @@ test.describe("Login.gov based authentication tests", () => { // Skip test if env missing const envMissing = - targetEnv !== "staging" || + targetEnv === "local" || !testUserEmail || !testUserPassword || !testUserAuthKey; @@ -53,7 +53,7 @@ test.describe("Login.gov based authentication tests", () => { // Given the user launches the application await page.goto(baseUrl, { waitUntil: "domcontentloaded", - timeout: targetEnv === "staging" ? 180000 : 60000, + timeout: targetEnv !== "local" ? 180000 : 60000, }); // When the user clicks the "Sign in" button diff --git a/frontend/tests/e2e/opportunity-id-data.ts b/frontend/tests/e2e/opportunity-id-data.ts deleted file mode 100644 index 7687129864..0000000000 --- a/frontend/tests/e2e/opportunity-id-data.ts +++ /dev/null @@ -1,6 +0,0 @@ -export const testdata_local_environment = { - opportunityID: "c3c59562-a54f-4203-b0f6-98f2f0383481", -} as const; -export const testdata_staging_environment = { - opportunityID: "39cf0a5c-5fed-40b4-8f46-5374101ae419", -} as const; diff --git a/frontend/tests/e2e/opportunity/specs/failure-path-create-opportunity.spec.ts b/frontend/tests/e2e/opportunity/specs/failure-path-create-opportunity.spec.ts index b0ceb6e9be..0a7c349f64 100644 --- a/frontend/tests/e2e/opportunity/specs/failure-path-create-opportunity.spec.ts +++ b/frontend/tests/e2e/opportunity/specs/failure-path-create-opportunity.spec.ts @@ -51,7 +51,7 @@ test.describe("Opportunity failure path - create opportunity", () => { //-----------------------Test setup----------------- // Skip non-Chrome browsers in staging. test.beforeEach(({ page: _ }, testInfo) => { - if (targetEnv === "staging") { + if (targetEnv !== "local") { test.skip( testInfo.project.name !== "Chrome", "Staging MFA login is limited to Chrome to avoid OTP rate-limiting", diff --git a/frontend/tests/e2e/opportunity/specs/failure-path-opportunity-overview-initial-state.spec.ts b/frontend/tests/e2e/opportunity/specs/failure-path-opportunity-overview-initial-state.spec.ts index 154a6af07a..c80ffe160c 100644 --- a/frontend/tests/e2e/opportunity/specs/failure-path-opportunity-overview-initial-state.spec.ts +++ b/frontend/tests/e2e/opportunity/specs/failure-path-opportunity-overview-initial-state.spec.ts @@ -30,7 +30,7 @@ const { targetEnv } = playwrightEnv; test.describe("Grantor opportunity overview failure path - initial state gating", () => { test.beforeEach(({ page: _ }, testInfo) => { - if (targetEnv === "staging") { + if (targetEnv !== "local") { test.skip( testInfo.project.name !== "Chrome", "Staging MFA login is limited to Chrome to avoid OTP rate-limiting", diff --git a/frontend/tests/e2e/opportunity/specs/failure-path-opportunity-summary.spec.ts b/frontend/tests/e2e/opportunity/specs/failure-path-opportunity-summary.spec.ts index e961501180..67aaacbade 100644 --- a/frontend/tests/e2e/opportunity/specs/failure-path-opportunity-summary.spec.ts +++ b/frontend/tests/e2e/opportunity/specs/failure-path-opportunity-summary.spec.ts @@ -33,7 +33,6 @@ import { REQUIRED_FIELD_DEFINITIONS, } from "tests/e2e/opportunity/fixtures/opportunity-pages-field-definitions"; import { buildOpportunityHappyPathFillData } from "tests/e2e/opportunity/fixtures/opportunity-pages-fill-data"; -import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { createAuthenticatedPageLifecycle } from "tests/e2e/utils/common/auth-storage-state-utils"; import { assertCharacterLimitValidationsFromDefinitions } from "tests/e2e/utils/common/character-limit-validation-utils"; @@ -45,7 +44,6 @@ import { assertRequiredFieldValidationsFromDefinitions } from "tests/e2e/utils/c import { createOpportunity } from "tests/e2e/utils/opportunity/create-opportunity-utils"; const { GRANTOR, CORE_REGRESSION } = VALID_TAGS; -const { targetEnv } = playwrightEnv; async function setupAndNavigateToOpportunitySummary(page: Page) { const fillData = buildOpportunityHappyPathFillData(new Date()); @@ -72,7 +70,6 @@ async function setupAndNavigateToOpportunitySummary(page: Page) { test.describe("Grantor Opportunity Summary Failure Path", () => { // One-login-per-spec lifecycle shared across failure-path specs. const authenticatedLifecycle = createAuthenticatedPageLifecycle({ - targetEnv, skipTest: (condition, description) => test.skip(condition, description), }); diff --git a/frontend/tests/e2e/opportunity/specs/happy-path-create-opportunity.spec.ts b/frontend/tests/e2e/opportunity/specs/happy-path-create-opportunity.spec.ts index 62a8bdbe82..9176825a0f 100644 --- a/frontend/tests/e2e/opportunity/specs/happy-path-create-opportunity.spec.ts +++ b/frontend/tests/e2e/opportunity/specs/happy-path-create-opportunity.spec.ts @@ -28,7 +28,7 @@ const { targetEnv } = playwrightEnv; test.describe("Grantor Opportunity Happy Path", () => { test.beforeEach(({ page: _ }, testInfo) => { - if (targetEnv === "staging") { + if (targetEnv !== "local") { test.skip( testInfo.project.name !== "Chrome", "Staging MFA login is limited to Chrome to avoid OTP rate-limiting", diff --git a/frontend/tests/e2e/opportunity/specs/happy-path-opportunity-overview-initial-state.spec.ts b/frontend/tests/e2e/opportunity/specs/happy-path-opportunity-overview-initial-state.spec.ts index bb07532368..7a81f37e75 100644 --- a/frontend/tests/e2e/opportunity/specs/happy-path-opportunity-overview-initial-state.spec.ts +++ b/frontend/tests/e2e/opportunity/specs/happy-path-opportunity-overview-initial-state.spec.ts @@ -39,7 +39,7 @@ const { targetEnv } = playwrightEnv; test.describe("Grantor opportunity overview happy path - initial state", () => { test.beforeEach(({ page: _ }, testInfo) => { - if (targetEnv === "staging") { + if (targetEnv !== "local") { test.skip( testInfo.project.name !== "Chrome", "Staging MFA login is limited to Chrome to avoid OTP rate-limiting", @@ -88,7 +88,7 @@ test.describe("Grantor opportunity overview happy path - initial state", () => { "Additional information": "Not started", "Attachments": "Not started", "Application requirements": "Not started", - "Forms": "Not started", + "Forms": "Not started", */ }); diff --git a/frontend/tests/e2e/opportunity/specs/happy-path-opportunity-summary.spec.ts b/frontend/tests/e2e/opportunity/specs/happy-path-opportunity-summary.spec.ts index a62bafac24..1c897e2aeb 100644 --- a/frontend/tests/e2e/opportunity/specs/happy-path-opportunity-summary.spec.ts +++ b/frontend/tests/e2e/opportunity/specs/happy-path-opportunity-summary.spec.ts @@ -50,7 +50,7 @@ const { targetEnv } = playwrightEnv; test.describe("Grantor Opportunity Summary Happy Path", () => { test.beforeEach(({ page: _ }, testInfo) => { - if (targetEnv === "staging") { + if (targetEnv !== "local") { test.skip( testInfo.project.name !== "Chrome", "Staging MFA login is limited to Chrome to avoid OTP rate-limiting", diff --git a/frontend/tests/e2e/opportunity/specs/opportunity.spec.ts b/frontend/tests/e2e/opportunity/specs/opportunity.spec.ts index 0b84e65b58..b904c9165e 100644 --- a/frontend/tests/e2e/opportunity/specs/opportunity.spec.ts +++ b/frontend/tests/e2e/opportunity/specs/opportunity.spec.ts @@ -32,6 +32,10 @@ const testOpportunityIdMap: { } = { staging: "332d9e58-7a4d-4bd0-afc8-70b4458262bc", local: "6a483cd8-9169-418a-8dfb-60fa6e6f51e5", + grantee1: "332d9e58-7a4d-4bd0-afc8-70b4458262bc", + grantee2: "332d9e58-7a4d-4bd0-afc8-70b4458262bc", + grantor1: "332d9e58-7a4d-4bd0-afc8-70b4458262bc", + grantor2: "332d9e58-7a4d-4bd0-afc8-70b4458262bc", }; // either a statically seeded id or an id that exists in staging pointing to a fully populated opportunity diff --git a/frontend/tests/e2e/organizations/specs/organization-detail-access.spec.ts b/frontend/tests/e2e/organizations/specs/organization-detail-access.spec.ts index 569e0944c8..bda726e83d 100644 --- a/frontend/tests/e2e/organizations/specs/organization-detail-access.spec.ts +++ b/frontend/tests/e2e/organizations/specs/organization-detail-access.spec.ts @@ -21,7 +21,7 @@ import { expect, test } from "@playwright/test"; import playwrightEnv from "tests/e2e/playwright-env"; import { VALID_TAGS } from "tests/e2e/tags"; import { authenticateE2eUser } from "tests/e2e/utils/auth/authenticate-e2e-user-utils"; -import { TEST_ORG_IDS } from "tests/e2e/utils/auth/test-users"; +import { getTestOrgId } from "tests/e2e/utils/auth/test-users"; const { AUTH, CORE_REGRESSION } = VALID_TAGS; @@ -35,7 +35,7 @@ test.describe("Organization detail page access", () => { // Run staging on Chrome only, mirroring the other staging auth specs; // cross-browser staging spoofing hasn't been validated yet. test.beforeEach(({ page: _ }, testInfo) => { - if (targetEnv === "staging") { + if (targetEnv !== "local") { test.skip( testInfo.project.name !== "Chrome", "Staging auth specs run on Chrome only", @@ -56,9 +56,12 @@ test.describe("Organization detail page access", () => { await authenticateE2eUser(page, context, isMobile, "orgMember"); // When the user navigates to their organization's detail page - await page.goto(`/workspace/organizations/${TEST_ORG_IDS.e2eTestOrg}`, { - waitUntil: "domcontentloaded", - }); + await page.goto( + `/workspace/organizations/${getTestOrgId("e2eTestOrg")}`, + { + waitUntil: "domcontentloaded", + }, + ); // Then the organization name is shown as the page heading await expect( diff --git a/frontend/tests/e2e/playwright-env.ts b/frontend/tests/e2e/playwright-env.ts index e1fc256a28..ceb71afab3 100644 --- a/frontend/tests/e2e/playwright-env.ts +++ b/frontend/tests/e2e/playwright-env.ts @@ -8,17 +8,30 @@ if (fs.existsSync(envPath)) { dotenv.config({ path: envPath, quiet: true }); } -const SUPPORTED_ENVS = ["local", "staging"] as const; -export type SupportedEnvs = (typeof SUPPORTED_ENVS)[number]; - // Organization label shown in the "Start new application" modal dropdown. // Must match the legal_business_name in seed_orgs_and_users.py. const TEST_ORG_LABELS: Record = { local: "Sally's Soup Emporium", staging: "Automatic staging Organization for UEI AUTOHQDCCHBY", + grantee1: "Automatic staging Organization for UEI AUTOHQDCCHBY", + grantee2: "Automatic staging Organization for UEI AUTOHQDCCHBY", + grantor1: "Automatic staging Organization for UEI AUTOHQDCCHBY", + grantor2: "Automatic staging Organization for UEI AUTOHQDCCHBY", }; +export const SUPPORTED_ENVS = [ + "local", + "staging", + "grantee1", + "grantee2", + "grantor1", + "grantor2", +] as const; + +export type SupportedEnvs = (typeof SUPPORTED_ENVS)[number]; + const targetEnv = process.env.PLAYWRIGHT_TARGET_ENV || "local"; + const testOrgLabel = TEST_ORG_LABELS[targetEnv]; const isLocal = targetEnv === "local"; @@ -48,10 +61,16 @@ const webServerEnv: Record = Object.fromEntries( }).filter(([, value]) => typeof value === "string"), ); +if (SUPPORTED_ENVS.indexOf(targetEnv as SupportedEnvs) === -1) { + throw new Error( + `Unsupported PLAYWRIGHT_TARGET_ENV: ${targetEnv}. Allowed values: ${SUPPORTED_ENVS.join(", ")}`, + ); +} + const playwrightEnv = { webServerEnv, - baseUrl, - apiUrl, + baseUrl: process.env.PLAYWRIGHT_BASE_URL || "http://127.0.0.1:3000", + apiUrl: process.env.PLAYWRIGHT_API_URL || "http://127.0.0.1:8080", targetEnv, testOrgLabel, isCi: process.env.CI, @@ -62,6 +81,10 @@ const playwrightEnv = { testUserEmail: process.env.STAGING_TEST_USER_EMAIL || "", testUserPassword: process.env.STAGING_TEST_USER_PASSWORD || "", testUserAuthKey: process.env.STAGING_TEST_USER_MFA_KEY || "", + // API key for the "test user manager" whose credentials authorize + // POST /v1/internal/e2e-token. A single variable set per environment by the + // e2e composite action (local uses the committed local-manager-key; staging + // injects its own secret value). testUserManagerApiKey: process.env.TEST_USER_MANAGER_API_KEY || "", }; diff --git a/frontend/tests/e2e/playwrightUtils.ts b/frontend/tests/e2e/playwrightUtils.ts index 811800b20b..1bc0092439 100644 --- a/frontend/tests/e2e/playwrightUtils.ts +++ b/frontend/tests/e2e/playwrightUtils.ts @@ -48,7 +48,7 @@ export async function waitForURLContainsQueryParamValue( timeoutOverride?: number, ) { // Use longer timeout for staging environment due to slower response times - const timeout = timeoutOverride ?? (targetEnv === "staging" ? 300000 : 60000); + const timeout = timeoutOverride ?? (targetEnv !== "local" ? 300000 : 60000); const changeCheck = (pageUrl: string): boolean => { const url = new URL(pageUrl); @@ -91,7 +91,7 @@ export async function waitForURLContainsQueryParamValues( queryParamValues: string[], timeoutOverride?: number, ) { - const timeout = timeoutOverride ?? (targetEnv === "staging" ? 300000 : 60000); + const timeout = timeoutOverride ?? (targetEnv !== "local" ? 300000 : 60000); const expectedSorted = [...queryParamValues].sort(); @@ -185,7 +185,7 @@ export const openMobileNav = async (page: Page) => { const menuOpener = page.locator(`button[data-testid="navMenuButton"]`); const nav = page.locator(".usa-nav"); const overlay = page.locator(".usa-overlay"); - const timeout = targetEnv === "staging" ? 120000 : 10000; + const timeout = targetEnv !== "local" ? 120000 : 10000; // If the nav is already open (e.g. left open by authenticateE2eUser), skip // clicking the hamburger button — clicking it again would close the nav and @@ -198,7 +198,7 @@ export const openMobileNav = async (page: Page) => { await menuOpener.click(); // Wait for animation to complete on slow staging environment - if (targetEnv === "staging") { + if (targetEnv !== "local") { await page.waitForTimeout(5000); } diff --git a/frontend/tests/e2e/saved-opportunities/specs/saved-opportunities.spec.ts b/frontend/tests/e2e/saved-opportunities/specs/saved-opportunities.spec.ts index 651ffadc68..85012ce802 100644 --- a/frontend/tests/e2e/saved-opportunities/specs/saved-opportunities.spec.ts +++ b/frontend/tests/e2e/saved-opportunities/specs/saved-opportunities.spec.ts @@ -87,7 +87,7 @@ test.describe("Saved Opportunities", () => { await waitForURLChange(page, (url) => !!url.match(/saved-opportunities/)); // And the page title should be "Saved opportunities | Simpler.Grants.gov" - const timeout = targetEnv === "staging" ? 30000 : 5000; + const timeout = targetEnv !== "local" ? 30000 : 5000; await expect(page).toHaveTitle( "Saved opportunities | Simpler.Grants.gov", { timeout }, diff --git a/frontend/tests/e2e/search/search-state/specs/search-error-recovery.spec.ts b/frontend/tests/e2e/search/search-state/specs/search-error-recovery.spec.ts index 40ee391520..7dca3c5265 100644 --- a/frontend/tests/e2e/search/search-state/specs/search-error-recovery.spec.ts +++ b/frontend/tests/e2e/search/search-state/specs/search-error-recovery.spec.ts @@ -14,7 +14,7 @@ import { const { GRANTEE, OPPORTUNITY_SEARCH, CORE_REGRESSION } = VALID_TAGS; -const SEARCH_TIMEOUT = playwrightEnv.targetEnv === "staging" ? 15000 : 5000; +const SEARCH_TIMEOUT = playwrightEnv.targetEnv !== "local" ? 15000 : 5000; test.describe("Search error page", () => { test( diff --git a/frontend/tests/e2e/search/search-state/specs/search-state-persistence.spec.ts b/frontend/tests/e2e/search/search-state/specs/search-state-persistence.spec.ts index a322c779ca..3d1d8e7954 100644 --- a/frontend/tests/e2e/search/search-state/specs/search-state-persistence.spec.ts +++ b/frontend/tests/e2e/search/search-state/specs/search-state-persistence.spec.ts @@ -78,13 +78,9 @@ const categoryCheckboxesMulti = { const { baseUrl, targetEnv } = playwrightEnv; -const GOTO_TIMEOUT = targetEnv === "staging" ? 300000 : 60000; +const GOTO_TIMEOUT = targetEnv !== "local" ? 300000 : 60000; const goToSearch = async (page: Page) => { - if (targetEnv !== "local" && targetEnv !== "staging") { - throw new Error(`Unsupported env ${targetEnv}`); - } - for (let attempt = 1; attempt <= 2; attempt += 1) { try { await page.goto(`${baseUrl}/search`, { timeout: GOTO_TIMEOUT }); diff --git a/frontend/tests/e2e/static-pages/specs/404.spec.ts b/frontend/tests/e2e/static-pages/specs/404.spec.ts index c63924201d..500f3873f8 100644 --- a/frontend/tests/e2e/static-pages/specs/404.spec.ts +++ b/frontend/tests/e2e/static-pages/specs/404.spec.ts @@ -14,14 +14,14 @@ const { STATIC, FULL_REGRESSION, CORE_REGRESSION } = VALID_TAGS; const { targetEnv } = playwrightEnv; test.beforeEach(async ({ page }) => { - const timeout = targetEnv === "staging" ? 180000 : 60000; + const timeout = targetEnv !== "local" ? 180000 : 60000; // Background: Given I open "/imnothere" await page.goto("/imnothere", { waitUntil: "load", timeout, }); // Wait for staging to stabilize - if (targetEnv === "staging") { + if (targetEnv !== "local") { await page.waitForTimeout(3000); // Skip if staging is unhealthy const isUnhealthy = await page.evaluate(() => @@ -35,7 +35,7 @@ test.beforeEach(async ({ page }) => { // Scenario: Show the 404 page title test("has title", { tag: [STATIC, CORE_REGRESSION] }, async ({ page }) => { - const timeout = targetEnv === "staging" ? 30000 : 5000; + const timeout = targetEnv !== "local" ? 30000 : 5000; // Then the page title should be "Oops, we can't find that page." await expect(page).toHaveTitle("Oops, we can't find that page.", { timeout, @@ -47,7 +47,7 @@ test( "can view the home button", { tag: [STATIC, FULL_REGRESSION] }, async ({ page }) => { - const timeout = targetEnv === "staging" ? 30000 : 5000; + const timeout = targetEnv !== "local" ? 30000 : 5000; await expect( // Then I should see a link titled "Visit our homepage" page.getByRole("link", { name: "Visit our homepage" }), diff --git a/frontend/tests/e2e/static-pages/specs/home.spec.ts b/frontend/tests/e2e/static-pages/specs/home.spec.ts index da5c974639..875e445a65 100644 --- a/frontend/tests/e2e/static-pages/specs/home.spec.ts +++ b/frontend/tests/e2e/static-pages/specs/home.spec.ts @@ -23,7 +23,7 @@ const { targetEnv } = playwrightEnv; // Background: the user navigates to the home page "/" test.beforeEach(async ({ page }) => { - const timeout = targetEnv === "staging" ? 180000 : 60000; + const timeout = targetEnv !== "local" ? 180000 : 60000; await page.goto("/", { waitUntil: "domcontentloaded", timeout }); }); diff --git a/frontend/tests/e2e/subscribe/specs/subscribe.spec.ts b/frontend/tests/e2e/subscribe/specs/subscribe.spec.ts index 5f10b9297a..b68b6cf34f 100644 --- a/frontend/tests/e2e/subscribe/specs/subscribe.spec.ts +++ b/frontend/tests/e2e/subscribe/specs/subscribe.spec.ts @@ -16,7 +16,7 @@ const { FULL_REGRESSION } = VALID_TAGS; const { targetEnv } = playwrightEnv; test.beforeEach(async ({ page }) => { - const timeout = targetEnv === "staging" ? 180000 : 60000; + const timeout = targetEnv !== "local" ? 180000 : 60000; // Background: Given I open "/newsletter" await page.goto("/newsletter", { waitUntil: "domcontentloaded", timeout }); diff --git a/frontend/tests/e2e/utils/application/get-opportunityId-utils.ts b/frontend/tests/e2e/utils/application/get-opportunityId-utils.ts deleted file mode 100644 index fee73fe245..0000000000 --- a/frontend/tests/e2e/utils/application/get-opportunityId-utils.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { - testdata_local_environment, - testdata_staging_environment, -} from "tests/e2e/opportunity-id-data"; -import playwrightEnv from "tests/e2e/playwright-env"; - -export function getOpportunityId() { - const { targetEnv } = playwrightEnv; - return targetEnv === "local" - ? testdata_local_environment.opportunityID - : testdata_staging_environment.opportunityID; -} diff --git a/frontend/tests/e2e/utils/auth/authenticate-e2e-user-utils.ts b/frontend/tests/e2e/utils/auth/authenticate-e2e-user-utils.ts index 0a55892397..b1acb92490 100644 --- a/frontend/tests/e2e/utils/auth/authenticate-e2e-user-utils.ts +++ b/frontend/tests/e2e/utils/auth/authenticate-e2e-user-utils.ts @@ -21,7 +21,7 @@ import { type TestUserKey, } from "tests/e2e/utils/auth/test-users"; -const { baseUrl, targetEnv, apiUrl, testUserManagerApiKey } = playwrightEnv; +const { baseUrl, apiUrl, testUserManagerApiKey } = playwrightEnv; // Fetches a server-side session token for a test user by calling the internal // e2e-token endpoint with the manager API key and the target user id. @@ -52,10 +52,6 @@ export async function authenticateE2eUser( isMobile: boolean, testUserKey: TestUserKey = "primaryOrgAdmin", ): Promise { - if (targetEnv !== "local" && targetEnv !== "staging") { - throw new Error(`Unsupported env ${targetEnv}`); - } - const userId = getTestUserId(testUserKey); const token = await fetchE2eSessionToken(userId); await createSpoofedSessionCookie(context, token); diff --git a/frontend/tests/e2e/utils/auth/perform-login-utils.ts b/frontend/tests/e2e/utils/auth/perform-login-utils.ts index 809d5783b4..49ba2fc845 100644 --- a/frontend/tests/e2e/utils/auth/perform-login-utils.ts +++ b/frontend/tests/e2e/utils/auth/perform-login-utils.ts @@ -5,7 +5,7 @@ import { openMobileNav } from "tests/e2e/playwrightUtils"; // Error if env missing and running against staging if ( - playwrightEnv.targetEnv === "staging" && + playwrightEnv.targetEnv !== "local" && (!playwrightEnv.testUserEmail || !playwrightEnv.testUserPassword || !playwrightEnv.testUserAuthKey) @@ -14,7 +14,7 @@ if ( } // --- Timeouts --- -const TIMEOUT_HOME = playwrightEnv.targetEnv === "staging" ? 180000 : 60000; +const TIMEOUT_HOME = playwrightEnv.targetEnv !== "local" ? 180000 : 60000; const TIMEOUT_MFA = 120000; // TOTP codes are valid for 30s windows. If we're within this many seconds diff --git a/frontend/tests/e2e/utils/auth/skip-non-chrome-staging-utils.ts b/frontend/tests/e2e/utils/auth/skip-non-chrome-staging-utils.ts index 45bad1f5ee..0fda9850b6 100644 --- a/frontend/tests/e2e/utils/auth/skip-non-chrome-staging-utils.ts +++ b/frontend/tests/e2e/utils/auth/skip-non-chrome-staging-utils.ts @@ -6,7 +6,7 @@ import playwrightEnv from "tests/e2e/playwright-env"; * Call inside a test.beforeEach in any spec that authenticates against staging. */ export function skipNonChromeOnStaging(testInfo: TestInfo): void { - if (playwrightEnv.targetEnv === "staging") { + if (playwrightEnv.targetEnv !== "local") { test.skip( testInfo.project.name !== "Chrome", "Staging MFA login is limited to Chrome to avoid OTP rate-limiting", diff --git a/frontend/tests/e2e/utils/auth/test-users.ts b/frontend/tests/e2e/utils/auth/test-users.ts index 01ae0eca31..ab816c854d 100644 --- a/frontend/tests/e2e/utils/auth/test-users.ts +++ b/frontend/tests/e2e/utils/auth/test-users.ts @@ -1,4 +1,4 @@ -import playwrightEnv from "tests/e2e/playwright-env"; +import playwrightEnv, { SupportedEnvs } from "tests/e2e/playwright-env"; /* Central map of E2E test users, keyed by a readable identifier and resolving to @@ -12,6 +12,10 @@ import playwrightEnv from "tests/e2e/playwright-env"; */ export type TestUserKey = "primaryOrgAdmin" | "orgMember"; +// Organization ids used to build org-scoped URLs (e.g. the org detail page). +export type TestOrgKey = "e2eTestOrg"; + +const targetEnv = playwrightEnv.targetEnv as SupportedEnvs; // Local ids match api/tests/lib/seed_e2e.py + api/tests/lib/seed_orgs_and_users.py. const LOCAL_TEST_USER_IDS: Record = { @@ -36,9 +40,6 @@ const STAGING_TEST_USER_IDS: Record = { orgMember: "ba856cd5-e047-436e-9b6b-f53b4cc534cc", }; -// Organization ids used to build org-scoped URLs (e.g. the org detail page). -export type TestOrgKey = "e2eTestOrg"; - const LOCAL_TEST_ORG_IDS: Record = { // "E2E Test Organization" — orgMember above is a member of this org. e2eTestOrg: "e5f6a7b8-c9d0-4e5f-8a0b-1c2d3e4f5061", @@ -51,14 +52,26 @@ const STAGING_TEST_ORG_IDS: Record = { e2eTestOrg: "9c6fcfb9-029d-4b69-af43-3b41257639f5", }; -const isStaging = playwrightEnv.targetEnv === "staging"; +export const TEST_USER_IDS = { + local: LOCAL_TEST_USER_IDS, + staging: STAGING_TEST_USER_IDS, + grantee1: STAGING_TEST_USER_IDS, + grantee2: STAGING_TEST_USER_IDS, + grantor1: STAGING_TEST_USER_IDS, + grantor2: STAGING_TEST_USER_IDS, +}; -export const TEST_USER_IDS = isStaging - ? STAGING_TEST_USER_IDS - : LOCAL_TEST_USER_IDS; +export const TEST_ORG_IDS = { + local: LOCAL_TEST_ORG_IDS, + staging: STAGING_TEST_ORG_IDS, + grantee1: STAGING_TEST_ORG_IDS, + grantee2: STAGING_TEST_ORG_IDS, + grantor1: STAGING_TEST_ORG_IDS, + grantor2: STAGING_TEST_ORG_IDS, +}; -export const TEST_ORG_IDS = isStaging - ? STAGING_TEST_ORG_IDS - : LOCAL_TEST_ORG_IDS; +export const getTestUserId = (key: TestUserKey): string => + TEST_USER_IDS[targetEnv][key]; -export const getTestUserId = (key: TestUserKey): string => TEST_USER_IDS[key]; +export const getTestOrgId = (key: TestOrgKey): string => + TEST_ORG_IDS[targetEnv][key]; diff --git a/frontend/tests/e2e/utils/common/auth-storage-state-utils.ts b/frontend/tests/e2e/utils/common/auth-storage-state-utils.ts index 1275a383a3..127d8f619a 100644 --- a/frontend/tests/e2e/utils/common/auth-storage-state-utils.ts +++ b/frontend/tests/e2e/utils/common/auth-storage-state-utils.ts @@ -28,6 +28,7 @@ import { type TestInfo, type WorkerInfo, } from "@playwright/test"; +import playwrightEnv from "tests/e2e/playwright-env"; import { authenticateE2eUser } from "tests/e2e/utils/auth/authenticate-e2e-user-utils"; export type AuthenticatedStorageState = Awaited< @@ -68,7 +69,6 @@ export async function createPageWithStorageState( } type AuthLifecycleOptions = { - targetEnv: string; timeoutMs?: number; stagingProjectName?: string; stagingSkipMessage?: string; @@ -98,7 +98,7 @@ export function createAuthenticatedPageLifecycle( workerInfo: WorkerInfo, ): Promise => { if ( - options.targetEnv === "staging" && + playwrightEnv.targetEnv !== "local" && workerInfo.project.name !== stagingProjectName ) { return; @@ -121,7 +121,7 @@ export function createAuthenticatedPageLifecycle( ): Promise => { testInfo.setTimeout(timeoutMs); - if (options.targetEnv === "staging") { + if (playwrightEnv.targetEnv !== "local") { options.skipTest?.( testInfo.project.name !== stagingProjectName, stagingSkipMessage, diff --git a/frontend/tests/e2e/utils/saved-opportunities/save-opportunity-utils.ts b/frontend/tests/e2e/utils/saved-opportunities/save-opportunity-utils.ts index 6e4c90289f..fe2ea0789f 100644 --- a/frontend/tests/e2e/utils/saved-opportunities/save-opportunity-utils.ts +++ b/frontend/tests/e2e/utils/saved-opportunities/save-opportunity-utils.ts @@ -18,7 +18,7 @@ async function assertSavedOpportunitiesPageReady( title: string, ): Promise { - const timeout = targetEnv === "staging" ? 30000 : 5000; + const timeout = targetEnv !== "local" ? 30000 : 5000; await expect(page).toHaveTitle("Saved opportunities | Simpler.Grants.gov", { timeout, @@ -100,7 +100,7 @@ export async function ensureOpportunityIsSaved( title: string, ): Promise { - const timeout = targetEnv === "staging" ? 30000 : 5000; + const timeout = targetEnv !== "local" ? 30000 : 5000; await expect(page).toHaveTitle("Saved opportunities | Simpler.Grants.gov", { timeout, diff --git a/frontend/tests/e2e/utils/search/searchSpecUtil.ts b/frontend/tests/e2e/utils/search/searchSpecUtil.ts index 4ff94cfc43..82d17a6204 100644 --- a/frontend/tests/e2e/utils/search/searchSpecUtil.ts +++ b/frontend/tests/e2e/utils/search/searchSpecUtil.ts @@ -12,7 +12,7 @@ import { const { targetEnv } = playwrightEnv; -const FILTER_OPTIONS_TIMEOUT = targetEnv === "staging" ? 30000 : 10000; +const FILTER_OPTIONS_TIMEOUT = targetEnv !== "local" ? 30000 : 10000; const getBrowserType = (page: Page, projectName?: string) => { if (projectName) { @@ -151,7 +151,7 @@ export async function toggleCheckbox(page: Page, idWithoutHash: string) { const checkBoxLabel = page .locator(`label[for="${idWithoutHash}"]:visible`) .first(); - const timeout = targetEnv === "staging" ? 120000 : 30000; + const timeout = targetEnv !== "local" ? 120000 : 30000; await checkBox.waitFor({ state: "attached", timeout }); await checkBoxLabel.waitFor({ state: "visible", timeout }); await checkBoxLabel.scrollIntoViewIfNeeded(); @@ -223,7 +223,7 @@ export async function selectSortBy( projectName?: string, ) { const timeoutOption = - targetEnv === "staging" ? { timeout: 60000 } : { timeout: 10000 }; + targetEnv !== "local" ? { timeout: 60000 } : { timeout: 10000 }; const sortSelectElement = drawer ? page.locator("#search-sort-by-select-drawer") : page.locator("#search-sort-by-select").first(); @@ -238,7 +238,7 @@ export async function selectSortBy( await sortSelectElement.selectOption(sortByValue); // For mobile drawer on staging, wait longer as it can be very slow - if (drawer && targetEnv === "staging") { + if (drawer && targetEnv !== "local") { await page.waitForTimeout(5000); } @@ -247,7 +247,7 @@ export async function selectSortBy( export async function expectSortBy(page: Page, value: string, drawer = false) { const timeoutOption = - targetEnv === "staging" ? { timeout: 60000 } : { timeout: 10000 }; + targetEnv !== "local" ? { timeout: 60000 } : { timeout: 10000 }; const sortSelectElement = drawer ? page.locator("#search-sort-by-select-drawer") : page.locator("#search-sort-by-select").first(); @@ -258,7 +258,7 @@ export async function waitForSearchResultsInitialLoad( page: Page, timeoutOverride?: number, ) { - let timeout = targetEnv === "staging" ? 180000 : 60000; + let timeout = targetEnv !== "local" ? 180000 : 60000; if (timeoutOverride) { timeout = timeoutOverride; } @@ -384,7 +384,7 @@ export async function ensureAccordionExpanded( const button = page.locator( `button.usa-accordion__button:has-text("${accordionTitle}"):visible`, ); - const timeout = targetEnv === "staging" ? 120000 : 30000; + const timeout = targetEnv !== "local" ? 120000 : 30000; await button.waitFor({ state: "visible", timeout }); await button.scrollIntoViewIfNeeded(); await page.waitForTimeout(100); diff --git a/frontend/tests/playwright.config.ts b/frontend/tests/playwright.config.ts index 39c370ef5a..3dbb1b725f 100644 --- a/frontend/tests/playwright.config.ts +++ b/frontend/tests/playwright.config.ts @@ -9,10 +9,10 @@ const { baseUrl, targetEnv, webServerEnv, isCi, totalShards, currentShard } = * See https://playwright.dev/docs/test-configuration. */ export default defineConfig({ - timeout: targetEnv === "local" ? 75000 : 120000, + timeout: targetEnv !== "local" ? 120000 : 75000, testDir: "./e2e", /* Run tests in files in parallel */ - fullyParallel: targetEnv !== "staging", + fullyParallel: targetEnv === "local", /* Fail the build on CI if you accidentally left test.only in the source code. */ forbidOnly: !!isCi, /* Retry on CI only */ @@ -33,7 +33,7 @@ export default defineConfig({ screenshot: "on", video: "on-first-retry", launchOptions: - targetEnv === "staging" + targetEnv !== "local" ? { args: ["--disable-dev-shm-usage"], } @@ -48,7 +48,7 @@ export default defineConfig({ }, /* Configure projects for major browsers */ projects: - targetEnv === "staging" + targetEnv !== "local" ? [ { name: "Chrome", @@ -98,13 +98,13 @@ export default defineConfig({ // Only start the local dev server when running in the local environment. webServer: - targetEnv === "local" - ? { + targetEnv !== "local" + ? undefined + : { command: "npm run start", url: baseUrl, reuseExistingServer: !isCi, env: webServerEnv, timeout: 120_000, // default is only 60s and can be too short for cold starts in CI causing webkit failures - } - : undefined, + }, });