From 2fb61a6e577552fe91ce5fc0edcaa933efa1cee2 Mon Sep 17 00:00:00 2001 From: Aaron Couch Date: Tue, 12 Nov 2024 16:07:13 -0500 Subject: [PATCH] [Issue #2622] Update opp page for ISR (#2724) ## Summary Fixes #2622 ### Time to review: __5 mins__ ## Changes proposed - Add ISR for opp pages. - Remove `withFeatureFlag()` from opportunity pages --- .github/workflows/ci-frontend-a11y.yml | 14 ++++++++------ .../src/app/[locale]/opportunity/[id]/page.tsx | 15 +++++++++++---- frontend/tests/e2e/opportunity.spec.ts | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+), 10 deletions(-) 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 b7ed6613c..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,6 +46,14 @@ 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 diff --git a/frontend/src/app/[locale]/opportunity/[id]/page.tsx b/frontend/src/app/[locale]/opportunity/[id]/page.tsx index 4431140a6..3bcf57fff 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"; @@ -20,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); @@ -41,6 +42,10 @@ export async function generateMetadata({ params }: { params: { id: string } }) { return meta; } +export function generateStaticParams() { + return []; +} + function emptySummary() { return { additional_info_url: null, @@ -77,7 +82,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 +136,3 @@ async function OpportunityListing({ params }: { params: { id: string } }) { ); } - -export default withFeatureFlag(OpportunityListing, "showSearchV0"); 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(); +});