Skip to content

Commit

Permalink
Merge pull request #15713 from CDCgov/deployment/2024-08-27
Browse files Browse the repository at this point in the history
Deployment of 2024-08-27
  • Loading branch information
brick-green authored Aug 27, 2024
2 parents 9be6785 + 2792eb4 commit c702a68
Show file tree
Hide file tree
Showing 83 changed files with 2,176 additions and 2,074 deletions.
6 changes: 3 additions & 3 deletions .github/actions/sonarcloud/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:
steps:
- name: Run Default SonarCloud Scan
if: inputs.scan-level == 'default'
uses: sonarsource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92
uses: sonarsource/sonarcloud-github-action@eb211723266fe8e83102bac7361f0a05c3ac1d1b
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
SONAR_TOKEN: ${{ inputs.sonar-token }}
Expand All @@ -32,7 +32,7 @@ runs:
- name: Run Frontend SonarCloud Scan
if: inputs.scan-level == 'frontend'
uses: sonarsource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92
uses: sonarsource/sonarcloud-github-action@eb211723266fe8e83102bac7361f0a05c3ac1d1b
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
SONAR_TOKEN: ${{ inputs.sonar-token }}
Expand All @@ -50,7 +50,7 @@ runs:
- name: Run Backend SonarCloud Scan
if: inputs.scan-level == 'backend'
uses: sonarsource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92
uses: sonarsource/sonarcloud-github-action@eb211723266fe8e83102bac7361f0a05c3ac1d1b
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
SONAR_TOKEN: ${{ inputs.sonar-token }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
sp-creds: ${{ secrets.SERVICE_PRINCIPAL_CREDS }}
tf-auth: true
- name: Use specific version of Terraform
uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
with:
terraform_version: 1.7.4
terraform_wrapper: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/destroy_demo_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Use specific version of Terraform
uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
with:
terraform_version: 1.7.4
terraform_wrapper: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/frontend_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ jobs:
name: E2E tests
needs: lint
runs-on: ubuntu-latest
# Keep shards under 6 minutes (1 minute dedicated to playwright install, 5 to tests)
timeout-minutes: 7
# Keep shards under 10 minutes
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_to_azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Use specific version of Terraform
uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
with:
terraform_version: 1.7.4
terraform_wrapper: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- name: "Get changed files with yaml"
id: changed-files-yaml
uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c
uses: tj-actions/changed-files@40853de9f8ce2d6cfdc73c1b96f14e22ba44aec4
with:
files_yaml: |
frontend:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate_terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Check Out Changes
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Use specific version of Terraform
uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
with:
terraform_version: 1.7.4
terraform_wrapper: false
Expand All @@ -48,7 +48,7 @@ jobs:
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Run Checkov action
uses: bridgecrewio/checkov-action@d69ef3767bfe92c3ac1416abfa48eb95378dd17f
uses: bridgecrewio/checkov-action@4fa90328619ebe2a5396c7f16308c17a7a4b5dc3
with:
directory: operations/app/terraform
skip_check: CKV_AZURE_139,CKV_AZURE_137,CKV_AZURE_103,CKV_AZURE_104,CKV_AZURE_102,CKV_AZURE_130,CKV_AZURE_121,CKV_AZURE_67,CKV_AZURE_56,CKV_AZURE_17,CKV_AZURE_63,CKV_AZURE_18,CKV_AZURE_88,CKV_AZURE_65,CKV_AZURE_13,CKV_AZURE_66,CKV_AZURE_33,CKV_AZURE_35,CKV_AZURE_36,CKV_AZURE_98,CKV2_AZURE_1,CKV2_AZURE_15,CKV2_AZURE_21,CKV_AZURE_213,CKV_AZURE_59,CKV2_AZURE_33,CKV2_AZURE_32,CKV2_AZURE_28,CKV_AZURE_206,CKV_AZURE_42,CKV_AZURE_110,CKV_AZURE_109,CKV_AZURE_166,CKV2_AZURE_38,CKV2_AZURE_40,CKV2_AZURE_41,CKV_AZURE_235
1 change: 1 addition & 0 deletions frontend-react/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ module.exports = {
// TODO: investigate these for reconsideration or per-module ignoring
"playwright/no-conditional-in-test": ["off"],
"playwright/no-force-option": ["off"],
"playwright/expect-expect": ["off"],
},
},
],
Expand Down
67 changes: 54 additions & 13 deletions frontend-react/e2e/helpers/internal-links.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,58 @@
import { Page } from "@playwright/test";

export const ELC =
"https://www.cdc.gov/epidemiology-laboratory-capacity/php/about/";
export const ELC = "https://www.cdc.gov/epidemiology-laboratory-capacity/php/about/";

export async function clickOnInternalLink(
locator: string,
dataTestId: string,
linkName: string,
page: Page,
) {
await page
.locator(locator)
.getByTestId(dataTestId)
.getByRole("link", { name: linkName })
.click();
export async function clickOnInternalLink(locator: string, dataTestId: string, linkName: string, page: Page) {
await page.locator(locator).getByTestId(dataTestId).getByRole("link", { name: linkName }).click();
}

export interface SideNavItem {
name: string;
path: string;
}

export const aboutSideNav = [
{
name: "About",
path: "/about",
},
{
name: "Our network",
path: "/about/our-network",
},
{
name: "Product roadmap",
path: "/about/roadmap",
},
{
name: "News",
path: "/about/news",
},
{
name: "Case studies",
path: "/about/case-studies",
},
{
name: "Security",
path: "/about/security",
},
{
name: "Release notes",
path: "/about/release-notes",
},
];

export const gettingStartedSideNav = [
{
name: "Getting started",
path: "/getting-started",
},
{
name: "Sending data",
path: "/getting-started/sending-data",
},
{
name: "Receiving data",
path: "/getting-started/receiving-data",
},
];
102 changes: 50 additions & 52 deletions frontend-react/e2e/pages/BasePage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SideNavItem } from "../helpers/internal-links";
import { selectTestOrg } from "../helpers/utils";
import appInsightsConfig from "../mocks/appInsightsConfig.json" assert { type: "json" };
import { Locator, Page, Request, Response, Route, TestArgs } from "../test";
import { expect, Locator, Page, Request, Response, Route, TestArgs } from "../test";

export type RouteHandlers = Record<string, Parameters<Page["route"]>[1]>;
export type MockRouteCache = Record<string, RouteFulfillOptions>;
Expand All @@ -12,25 +13,12 @@ export interface BasePageProps {
heading?: Locator;
}

export type RouteFulfillOptions = Exclude<
Parameters<Route["fulfill"]>[0],
undefined
> & { isMock?: boolean };
export type RouteFulfillOptionsFn = (
request: Request,
) => Promise<RouteFulfillOptions> | RouteFulfillOptions;
export type RouteFulfillOptions = Exclude<Parameters<Route["fulfill"]>[0], undefined> & { isMock?: boolean };
export type RouteFulfillOptionsFn = (request: Request) => Promise<RouteFulfillOptions> | RouteFulfillOptions;
export type RouteHandlerFn = (route: Route, request: Request) => Promise<void>;
export type RouteHandlerFulfillOptions =
| RouteFulfillOptions
| RouteFulfillOptionsFn;
export type RouteHandlerFulfillEntry = [
url: string,
fulfillOptions: RouteHandlerFulfillOptions,
];
export type ResponseHandlerEntry = [
url: string,
handler: (response: Response) => Promise<void> | void,
];
export type RouteHandlerFulfillOptions = RouteFulfillOptions | RouteFulfillOptionsFn;
export type RouteHandlerFulfillEntry = [url: string, fulfillOptions: RouteHandlerFulfillOptions];
export type ResponseHandlerEntry = [url: string, handler: (response: Response) => Promise<void> | void];
export type RouteHandlerEntry = [url: string, handler: RouteHandlerFn];

export interface GotoRouteHandlerOptions {
Expand Down Expand Up @@ -70,10 +58,7 @@ export abstract class BasePage {
readonly heading: Locator;
readonly footer: Locator;

constructor(
{ url, title, heading }: BasePageProps,
testArgs: BasePageTestArgs,
) {
constructor({ url, title, heading }: BasePageProps, testArgs: BasePageTestArgs) {
this.page = testArgs.page;
this.url = url;
this.title = title;
Expand All @@ -94,9 +79,7 @@ export abstract class BasePage {
return this._mockError;
}

set mockError(
err: boolean | number | RouteHandlerFulfillOptions | undefined,
) {
set mockError(err: boolean | number | RouteHandlerFulfillOptions | undefined) {
if (err == null || err === false) {
this._mockError = undefined;
return;
Expand Down Expand Up @@ -151,6 +134,39 @@ export abstract class BasePage {
);
}

async testHeader() {
await expect(this.page).toHaveTitle(this.title);
await expect(this.heading).toBeVisible();
}

async testCard(card: { name: string }) {
const cardHeader = this.page.locator(".usa-card__header", {
hasText: card.name,
});

await expect(cardHeader).toBeVisible();
}

async testSidenav(navItems: SideNavItem[]) {
const sideNav = this.page.getByTestId("sidenav");

for (const navItem of navItems) {
const link = sideNav.locator(`a`, { hasText: navItem.name });

await expect(link).toBeVisible();
await expect(link).toHaveAttribute("href", navItem.path);
}
}

async testFooter() {
await expect(this.page.locator("footer")).toBeAttached();
await this.page.locator("footer").scrollIntoViewIfNeeded();
await expect(this.page.locator("footer")).toBeInViewport();
await expect(this.page.getByTestId("govBanner")).not.toBeInViewport();
await this.page.evaluate(() => window.scrollTo(0, 0));
await expect(this.page.getByTestId("govBanner")).toBeInViewport();
}

/**
* Used to select the test org if logged-in user is Admin and the isTestOrg prop is set to true.
* This is needed for smoke tests since they use live data.
Expand Down Expand Up @@ -210,19 +226,11 @@ export abstract class BasePage {
const wrapped = items.map(([url, _fulfillOptions]) => {
const fn = async (request: Request) => {
const fulfillOptions =
typeof _fulfillOptions === "function"
? await _fulfillOptions(request)
: _fulfillOptions;
typeof _fulfillOptions === "function" ? await _fulfillOptions(request) : _fulfillOptions;
const mockErrorFulfillOptions =
typeof this.mockError === "function"
? await this.mockError(request)
: this.mockError;
const mockCacheFulfillOptions = this.getMockCacheFulfillOptions(
url,
fulfillOptions,
);
const mockOverrideFulfillOptions =
mockErrorFulfillOptions ?? mockCacheFulfillOptions;
typeof this.mockError === "function" ? await this.mockError(request) : this.mockError;
const mockCacheFulfillOptions = this.getMockCacheFulfillOptions(url, fulfillOptions);
const mockOverrideFulfillOptions = mockErrorFulfillOptions ?? mockCacheFulfillOptions;

return {
isMock: true,
Expand All @@ -233,9 +241,7 @@ export abstract class BasePage {
});

wrapped.forEach(([url, fn]) =>
this.mockRouteHandlers.set(url, async (route, req) =>
route.fulfill(await fn(req)),
),
this.mockRouteHandlers.set(url, async (route, req) => route.fulfill(await fn(req))),
);

return wrapped;
Expand All @@ -244,15 +250,10 @@ export abstract class BasePage {
/**
* Helper function to convert RouteHandlerFulfillEntries to RouteHandlerEntries.
*/
createRouteHandlers(
items: RouteHandlerFulfillEntry[],
): RouteHandlerEntry[] {
createRouteHandlers(items: RouteHandlerFulfillEntry[]): RouteHandlerEntry[] {
return items.map(([url, _fulfill]) => {
const handler = async (route: Route, request: Request) => {
const fulfill =
typeof _fulfill === "function"
? await _fulfill(request)
: _fulfill;
const fulfill = typeof _fulfill === "function" ? await _fulfill(request) : _fulfill;

return route.fulfill(fulfill);
};
Expand Down Expand Up @@ -302,10 +303,7 @@ export abstract class BasePage {
* Get or warm the cache for a particular mock URL's fulfillOptions. This
* allows for dynamic options to persist across page reloads for consistency.
*/
getMockCacheFulfillOptions(
url: string,
fulfillOptions: RouteFulfillOptions,
) {
getMockCacheFulfillOptions(url: string, fulfillOptions: RouteFulfillOptions) {
const cache = this._mockRouteCache[url];
if (!cache) {
this._mockRouteCache[url] = fulfillOptions;
Expand Down
40 changes: 0 additions & 40 deletions frontend-react/e2e/pages/about-side-navigation.ts

This file was deleted.

Loading

0 comments on commit c702a68

Please sign in to comment.