Skip to content

Commit

Permalink
[Issue #2622] Update opp page for ISR (#2724)
Browse files Browse the repository at this point in the history
## Summary
Fixes #2622

### Time to review: __5 mins__

## Changes proposed
- Add ISR for opp pages.
- Remove `withFeatureFlag()` from opportunity pages
  • Loading branch information
acouch authored Nov 12, 2024
1 parent 22ccd25 commit 2fb61a6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/ci-frontend-a11y.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 11 additions & 4 deletions frontend/src/app/[locale]/opportunity/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -127,5 +136,3 @@ async function OpportunityListing({ params }: { params: { id: string } }) {
</div>
);
}

export default withFeatureFlag(OpportunityListing, "showSearchV0");
18 changes: 18 additions & 0 deletions frontend/tests/e2e/opportunity.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});

0 comments on commit 2fb61a6

Please sign in to comment.