From 12aab7f4506b924fa9510a56b36715a9b707f5b6 Mon Sep 17 00:00:00 2001 From: acouch Date: Mon, 4 Nov 2024 17:32:56 -0500 Subject: [PATCH 1/5] Update opp page for ISR --- frontend/src/app/[locale]/opportunity/[id]/page.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/[locale]/opportunity/[id]/page.tsx b/frontend/src/app/[locale]/opportunity/[id]/page.tsx index 4431140a6..478f0d123 100644 --- a/frontend/src/app/[locale]/opportunity/[id]/page.tsx +++ b/frontend/src/app/[locale]/opportunity/[id]/page.tsx @@ -3,7 +3,6 @@ import NotFound from "src/app/[locale]/not-found"; import fetchers from "src/app/api/Fetchers"; import { OPPORTUNITY_CRUMBS } from "src/constants/breadcrumbs"; import { ApiRequestError, parseErrorStatus } from "src/errors"; -import withFeatureFlag from "src/hoc/search/withFeatureFlag"; import { Opportunity } from "src/types/opportunity/opportunityResponseTypes"; import { getTranslations } from "next-intl/server"; @@ -41,6 +40,10 @@ export async function generateMetadata({ params }: { params: { id: string } }) { return meta; } +export function generateStaticParams() { + return []; +} + function emptySummary() { return { additional_info_url: null, @@ -77,7 +80,11 @@ function emptySummary() { }; } -async function OpportunityListing({ params }: { params: { id: string } }) { +export default async function OpportunityListing({ + params, +}: { + params: { id: string }; +}) { const id = Number(params.id); const breadcrumbs = Object.assign([], OPPORTUNITY_CRUMBS); // Opportunity id needs to be a number greater than 1 @@ -127,5 +134,3 @@ async function OpportunityListing({ params }: { params: { id: string } }) { ); } - -export default withFeatureFlag(OpportunityListing, "showSearchV0"); From bfe025cb207277e79e8e154da134ed5cc6f98391 Mon Sep 17 00:00:00 2001 From: acouch Date: Fri, 8 Nov 2024 14:16:31 -0500 Subject: [PATCH 2/5] Update opp page.tsx to reduce cache lifetime --- frontend/src/app/[locale]/opportunity/[id]/page.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/app/[locale]/opportunity/[id]/page.tsx b/frontend/src/app/[locale]/opportunity/[id]/page.tsx index 478f0d123..7005eec76 100644 --- a/frontend/src/app/[locale]/opportunity/[id]/page.tsx +++ b/frontend/src/app/[locale]/opportunity/[id]/page.tsx @@ -19,6 +19,8 @@ import OpportunityIntro from "src/components/opportunity/OpportunityIntro"; import OpportunityLink from "src/components/opportunity/OpportunityLink"; import OpportunityStatusWidget from "src/components/opportunity/OpportunityStatusWidget"; +export const revalidate = 600 // invalidate ten minutes + export async function generateMetadata({ params }: { params: { id: string } }) { const t = await getTranslations({ locale: "en" }); const id = Number(params.id); From fca9dc22b419cec2f420515cfebbd039d11c3579 Mon Sep 17 00:00:00 2001 From: acouch Date: Fri, 8 Nov 2024 14:18:29 -0500 Subject: [PATCH 3/5] Update ci-frontend-a11y.yml --- .github/workflows/ci-frontend-a11y.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci-frontend-a11y.yml b/.github/workflows/ci-frontend-a11y.yml index b7ed6613c..83d8fbe23 100644 --- a/.github/workflows/ci-frontend-a11y.yml +++ b/.github/workflows/ci-frontend-a11y.yml @@ -58,6 +58,12 @@ jobs: chmod +x ./bin/wait-for-frontend.sh ./bin/wait-for-frontend.sh + - name: Run curl + run: | + curl -I http://localhost:3000/opportunity/1 + curl -I http://localhost:3000/opportunity/1231212 + curl http://localhost:3000/search | grep "/opportunity/*" + - name: Run pa11y-ci run: | set -e # Ensure the script fails if any command fails From 060650e500e41d0a71afaba7992dbf39554e1872 Mon Sep 17 00:00:00 2001 From: acouch Date: Fri, 8 Nov 2024 14:52:59 -0500 Subject: [PATCH 4/5] Add e2e test --- .github/workflows/ci-frontend-a11y.yml | 20 ++++------ frontend/at-test.yml | 38 +++++++++++++++++++ .../app/[locale]/opportunity/[id]/page.tsx | 2 +- frontend/tests/e2e/opportunity.spec.ts | 18 +++++++++ 4 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 frontend/at-test.yml create mode 100644 frontend/tests/e2e/opportunity.spec.ts diff --git a/.github/workflows/ci-frontend-a11y.yml b/.github/workflows/ci-frontend-a11y.yml index 83d8fbe23..2428d4bd9 100644 --- a/.github/workflows/ci-frontend-a11y.yml +++ b/.github/workflows/ci-frontend-a11y.yml @@ -36,12 +36,6 @@ jobs: - name: Create screenshots directory run: mkdir -p screenshots-output - - name: Build project - run: npm run build - - - name: Start server and log output - run: npm run start & - - name: Start API Server for search results run: | cd ../api @@ -52,18 +46,20 @@ jobs: ../api/bin/wait-for-api.sh shell: bash + - name: Build Site + run: | + cat .env.development >> .env.local + npm run build + + - name: Run Server + run: npm run start & + - name: Wait for frontend to be ready run: | # Ensure the server wait script is executable chmod +x ./bin/wait-for-frontend.sh ./bin/wait-for-frontend.sh - - name: Run curl - run: | - curl -I http://localhost:3000/opportunity/1 - curl -I http://localhost:3000/opportunity/1231212 - curl http://localhost:3000/search | grep "/opportunity/*" - - name: Run pa11y-ci run: | set -e # Ensure the script fails if any command fails diff --git a/frontend/at-test.yml b/frontend/at-test.yml new file mode 100644 index 000000000..09686dd32 --- /dev/null +++ b/frontend/at-test.yml @@ -0,0 +1,38 @@ +config: + target: http://localhost:3000 + phases: + - arrivalCount: 10 + duration: 30 + payload: + - path: "tests/artillery/{{ $environment}}-opportunities.csv" + fields: + - opp_id + skipHeader: true + name: opps + - path: "tests/artillery/{{ $environment}}-search.csv" + fields: + - query + - page + - status + - agency + skipHeader: true + name: opps +scenarios: + - name: opportunities + flow: + - loop: + - get: + url: "/opportunity/{{ opp_id }}" + - think: 1 + count: 10 + over: opps + log: "/opportunity/{{ opp_id }}" + - name: search + flow: + - loop: + - get: + url: "/search?query={{ query }}&page={{ page }}&status={{ status }}" + - think: 1 + count: 10 + over: opps + log: "/opportunity/{{ opp_id }}" diff --git a/frontend/src/app/[locale]/opportunity/[id]/page.tsx b/frontend/src/app/[locale]/opportunity/[id]/page.tsx index 7005eec76..3bcf57fff 100644 --- a/frontend/src/app/[locale]/opportunity/[id]/page.tsx +++ b/frontend/src/app/[locale]/opportunity/[id]/page.tsx @@ -19,7 +19,7 @@ import OpportunityIntro from "src/components/opportunity/OpportunityIntro"; import OpportunityLink from "src/components/opportunity/OpportunityLink"; import OpportunityStatusWidget from "src/components/opportunity/OpportunityStatusWidget"; -export const revalidate = 600 // invalidate ten minutes +export const revalidate = 600; // invalidate ten minutes export async function generateMetadata({ params }: { params: { id: string } }) { const t = await getTranslations({ locale: "en" }); diff --git a/frontend/tests/e2e/opportunity.spec.ts b/frontend/tests/e2e/opportunity.spec.ts new file mode 100644 index 000000000..9a4a001ee --- /dev/null +++ b/frontend/tests/e2e/opportunity.spec.ts @@ -0,0 +1,18 @@ +/* eslint-disable testing-library/prefer-screen-queries */ +import { expect, test } from "@playwright/test"; + +test.beforeEach(async ({ page }) => { + await page.goto("/opportunity/1"); +}); + +test.afterEach(async ({ context }) => { + await context.close(); +}); + +test("has title", async ({ page }) => { + await expect(page).toHaveTitle(/^Opportunity Listing - */); +}); + +test("has page attributes", async ({ page }) => { + await expect(page.getByText("Forecasted")).toBeVisible(); +}); From d6eed6e5d820bf5164d8636e2780b51375a4050b Mon Sep 17 00:00:00 2001 From: acouch Date: Fri, 8 Nov 2024 18:31:55 -0500 Subject: [PATCH 5/5] Remove file --- frontend/at-test.yml | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 frontend/at-test.yml diff --git a/frontend/at-test.yml b/frontend/at-test.yml deleted file mode 100644 index 09686dd32..000000000 --- a/frontend/at-test.yml +++ /dev/null @@ -1,38 +0,0 @@ -config: - target: http://localhost:3000 - phases: - - arrivalCount: 10 - duration: 30 - payload: - - path: "tests/artillery/{{ $environment}}-opportunities.csv" - fields: - - opp_id - skipHeader: true - name: opps - - path: "tests/artillery/{{ $environment}}-search.csv" - fields: - - query - - page - - status - - agency - skipHeader: true - name: opps -scenarios: - - name: opportunities - flow: - - loop: - - get: - url: "/opportunity/{{ opp_id }}" - - think: 1 - count: 10 - over: opps - log: "/opportunity/{{ opp_id }}" - - name: search - flow: - - loop: - - get: - url: "/search?query={{ query }}&page={{ page }}&status={{ status }}" - - think: 1 - count: 10 - over: opps - log: "/opportunity/{{ opp_id }}"