Skip to content

Commit

Permalink
feat(add e2e): add e2e logic into github actions
Browse files Browse the repository at this point in the history
* add working logic to dashboard

* add branch specific logic

* Update templateDashboard.txt

* add cloudfront alarm

* Update serverless-compose.yml

* Update serverless.yml

* add api gateway alarm

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* Update serverless.yml

* tinkering with distrubution id

* Update serverless.yml

* Update serverless.yml

* remove cloudfront alarms

* Update serverless.yml

* adjust namespace

* Update templateDashboard.txt

* Update serverless.yml

* Update templateDashboard.txt

* Update templateDashboard.txt

* add additional alarms

* Update serverless.yml

* adding logic for validation alarms

* Update serverless.yml

* Update serverless.yml

* Update templateDashboard.txt

* Update templateDashboard.txt

* add lambda search alarm logic

* Update templateDashboard.txt

* Update templateDashboard.txt

* Update templateDashboard.txt

* Update serverless.yml

* add sns alert alarm logic

* Update serverless.yml

* adjuspacing

* update namespaces

* update namespaces

* change eval periods

* cleanup

* update threshold

* update graph

* Update templateDashboard.txt

* adjust dashboard with new metrics and graphs

* Update serverless.yml

* Update workspace setup to write to .zshenv instead of .zshrc

* Update deploy.yml

* Update index.spec.ts

* Update index.spec.ts

* adjust env

* test

* Update serverless.yml

* Update serverless.yml

* test

* Update index.spec.ts

* Update serverless.yml

* add test dir

* test

* Update serverless.yml

* non null

* Update index.spec.ts

* add vite prefix

* Update index.spec.ts

* add import

* test

* Update index.spec.ts

* Update index.spec.ts

* adding logging

* add logs

* removal local

* Update playwright.config.ts

* test

* Update index.spec.ts

* Update index.spec.ts

* test

* move file into test file

* Update index.spec.ts

* teest

* test

* Update index.spec.ts

* test

* debug

* Update deploy.yml

* Update deploy.yml

* test

* Update playwright.config.ts

* Update serverless.yml

* Update serverless.yml

* Update deploy.yml

* Update deploy.yml

* Update deploy.yml

* Update serverless.yml

* Update deploy.yml

* Update serverless.yml

* change WD

* Update deploy.yml

* trying new logic

* Update deploy.yml

* Update deploy.yml

* Update deploy.yml

* Update deploy.yml

* Update deploy.yml

* run github secret logic

* add secret logic

* test

* Update index.spec.ts

* comment

* remove env

* test

* Update index.spec.ts

* Update playwright.config.ts

* Update index.spec.ts

* run secrects logic

* Update serverless.yml

* Update index.spec.ts

* Update index.spec.ts

* uncomment

* Update index.spec.ts

* Update index.spec.ts

* add logic

* Update index.spec.ts

* Update index.spec.ts

* Update secrets-manager-lib.ts

* Update secrets-manager-lib.ts

* fixed logic

* cleanup testing logic

* Update index.spec.ts

* adjust the way we are running playwright

* updated lock file

* update logic

* run logic

* edit file

* Update package.json

* thing

* Update playwright.config.ts

* Update playwright.config.ts

* Update playwright.config.ts

* add packages

* Update package.json

* Update package.json

* Update package.json

* edit logic

* cleaned logic

* Update run.ts

* yarntest

* Update run.ts

* log logic

* Update package.json

* run pwd logic

* logic

* Update deploy.yml

* Update deploy.yml

* Update deploy.yml

* test

* remove individual browsers

* Update deploy.yml

* Update deploy.yml

* Update deploy.yml

* Update deploy.yml

* test

* Update deploy.yml

* add deps update

* Update run.ts

* Update deploy.yml

* only chrome

* test

* back to fix

* update yarn

* Update index.spec.ts

* Update index.spec.ts

* Update index.spec.ts

* cleanup

---------

Co-authored-by: Benjamin Paige <[email protected]>
  • Loading branch information
jdinh8124 and benjaminpaige authored Sep 22, 2023
1 parent 7a2fdf9 commit 50896af
Show file tree
Hide file tree
Showing 8 changed files with 702 additions and 59 deletions.
54 changes: 27 additions & 27 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,33 +108,33 @@ jobs:
- name: Test
run: yarn test-ci

# e2e:
# timeout-minutes: 5
# runs-on: ubuntu-20.04
# needs:
# - deploy
# env:
# baseurl: ${{ needs.deploy.outputs.app-url }}
# if: ${{ github.ref != 'refs/heads/production' }}
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Setup
# uses: ./.github/actions/setup
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v2
# with:
# role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
# aws-region: us-east-1
# role-duration-seconds: 10800
# - name: Run e2e tests
# run: run e2e
# - uses: actions/upload-artifact@v3
# if: always()
# with:
# name: playwright-report
# path: src/services/ui/playwright-report/
# retention-days: 30
e2e:
timeout-minutes: 5
runs-on: ubuntu-20.04
needs:
- deploy
env:
baseurl: ${{ needs.deploy.outputs.app-url }}
if: ${{ github.ref != 'refs/heads/production' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
role-duration-seconds: 10800
- name: Run e2e tests
run: run e2e
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: src/services/ui/playwright-report/
retention-days: 30

cfn-nag:
runs-on: ubuntu-20.04
Expand Down
1 change: 1 addition & 0 deletions src/libs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"@aws-sdk/client-cognito-identity-provider": "^3.350.0",
"@aws-sdk/client-dynamodb": "^3.281.0",
"@aws-sdk/credential-provider-node": "^3.369.0",
"@aws-sdk/client-secrets-manager": "^3.410.0",
"@aws-sdk/util-dynamodb": "^3.281.0",
"@opensearch-project/opensearch": "^2.3.0",
"@types/aws4": "^1.11.3",
Expand Down
29 changes: 29 additions & 0 deletions src/libs/secrets-manager-lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
SecretsManagerClient,
GetSecretValueCommand,
ListSecretsCommand,
} from "@aws-sdk/client-secrets-manager";

export const getSecretsValue = async (region: string, secretId: string) => {
const client = new SecretsManagerClient({ region });
const input = { SecretId: secretId };
const command = new GetSecretValueCommand(input);

try {
const response = await client.send(command);
const result = response.SecretString ?? "";
return result;
} catch (e) {
console.log("ERROR getting secrets value", JSON.stringify(e, null, 2));
}
};

export const doesSecretExist = async (region: string, secretId: string) => {
const client = new SecretsManagerClient({ region });
const input = { Filters: [{ Key: "name", Values: [secretId] }] };
const command = new ListSecretsCommand(input);
const { SecretList } = await client.send(command);

if (SecretList) return SecretList.some((secret) => secret.Name === secretId);
else return;
};
35 changes: 25 additions & 10 deletions src/services/ui/e2e/tests/home/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
import * as Libs from "../../../../../libs/secrets-manager-lib";
import { test, expect } from "@playwright/test";
import { testUsers } from "e2e/utils/users";
const stage =
process.env.STAGE_NAME === "production" || process.env.STAGE_NAME === "val"
? process.env.STAGE_NAME
: "default";
const secretId = `${process.env.PROJECT}/${stage}/bootstrapUsersPassword`;

const password = process.env.BOOTSTRAP_USERS_PW!;
const password = (await Libs.getSecretsValue(
process.env.REGION_A as string,
secretId
)) as string;

test("has title", async ({ page }) => {
await page.goto("/");
await expect(page).toHaveTitle(/CMS MAKO/);
});

test("see frequesntly asked questions header when in faq page", async ({ page }) => {
test("see frequently asked questions header when in faq page", async ({
page,
}) => {
await page.goto("/");
await page.getByRole("link", { name: "FAQ" }).click();
await page.getByRole("link", { name: "FAQ" }).first().click();

const foundFaqHeading = await page.getByRole("heading", { name: "Frequently Asked Questions" }).isVisible();
const foundFaqHeading = await page
.getByRole("heading", { name: "Frequently Asked Questions" })
.isVisible();
expect(foundFaqHeading).toBeTruthy();
});

test("see dahsboard link when log in", async ({ page }) => {
test("see dashboard link when log in", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "Sign In" }).click();
await page.getByRole("textbox", { name: "[email protected]" }).type(testUsers.state);
await page
.getByRole("textbox", { name: "[email protected]" })
.type(testUsers.state);
await page.getByRole("textbox", { name: "Password" }).type(password);
await page.getByRole("button", { name: "submit" }).click();
await page.getByRole("link", { name: "Dashboard" }).click();

const dashboardLinkVisible = await page.getByRole("link", { name: "Dashboard" }).isVisible();
const dashboardLinkVisible = await page
.getByRole("link", { name: "Dashboard" })
.isVisible();
expect(dashboardLinkVisible).toBeTruthy();
});

Expand All @@ -34,7 +51,5 @@ test("failed incorrect login username", async ({ page }) => {
await page.getByRole("textbox", { name: "[email protected]" }).type(".");
await page.getByRole("textbox", { name: "Password" }).type(password);
await page.getByRole("button", { name: "submit" }).click();
await page.getByRole("paragraph").isVisible();
const invalidInputTest = await page.$("p:has-text(\"The username or password you entered is invalid\")");
expect(invalidInputTest).toBeTruthy();
await page.locator("#loginErrorMessage").first().isVisible();
});
2 changes: 1 addition & 1 deletion src/services/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"zod": "^3.21.4"
},
"devDependencies": {
"@playwright/test": "^1.34.0",
"@playwright/test": "^1.38.0",
"@tailwindcss/typography": "^0.5.10",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
Expand Down
1 change: 0 additions & 1 deletion src/services/ui/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { defineConfig, devices } from "@playwright/test";

import dotenv from "dotenv";
import path from "path";
import { fileURLToPath } from "url";
Expand Down
1 change: 0 additions & 1 deletion src/services/ui/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ custom:
VITE_COGNITO_USER_POOL_CLIENT_DOMAIN=${param:CognitoUserPoolClientDomain}
VITE_COGNITO_REDIRECT_SIGNIN=${param:ApplicationEndpointUrl}
VITE_COGNITO_REDIRECT_SIGNOUT=${param:ApplicationEndpointUrl}
BOOTSTRAP_USERS_PW=${param:BootstrapUsersPassword}
""" > .env.local
yarn build
deploy:finalize: |
Expand Down
Loading

0 comments on commit 50896af

Please sign in to comment.