From 48ecb070ea1987f08f06285e132cdf3ace5032fc Mon Sep 17 00:00:00 2001 From: Dan Reale Date: Fri, 20 Sep 2024 09:39:37 -0400 Subject: [PATCH] added outline of tests --- .github/workflows/playwright.yml | 2 +- .github/workflows/playwright_smoke.yml | 36 ++++++++ load_tests/hearttransplant.js | 119 +++++++++++++++++++++++++ tests/E2E.spec.ts | 52 +++++++++++ 4 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/playwright_smoke.yml create mode 100644 load_tests/hearttransplant.js create mode 100644 tests/E2E.spec.ts diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index c7ad3c3..e9d1c6e 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -22,7 +22,7 @@ jobs: - name: Install Playwright Browsers run: npx playwright install --with-deps chromium - name: Run Playwright tests - run: npx playwright test + run: npx playwright test Transplant.spec.ts - uses: actions/upload-artifact@v4 if: always() with: diff --git a/.github/workflows/playwright_smoke.yml b/.github/workflows/playwright_smoke.yml new file mode 100644 index 0000000..d05dfc1 --- /dev/null +++ b/.github/workflows/playwright_smoke.yml @@ -0,0 +1,36 @@ +name: Smoke Tests +on: + push: + branches: [ main ] + workflow_dispatch: +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps chromium + - name: Run Playwright tests + run: npx playwright test E2E.spec.ts + - uses: actions/upload-artifact@v4 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 + - name: Run k6 tests + uses: grafana/k6-action@v0.3.1 + with: + filename: load_tests/hearttransplant.js + - name: Store k6 report + uses: actions/upload-artifact@v4 + if: always() + with: + name: k6-summary-report.html + path: HeartTransplant.html \ No newline at end of file diff --git a/load_tests/hearttransplant.js b/load_tests/hearttransplant.js new file mode 100644 index 0000000..80a31e3 --- /dev/null +++ b/load_tests/hearttransplant.js @@ -0,0 +1,119 @@ +import { group, check } from "k6"; +import http from "k6/http"; +import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js"; +import { textSummary } from "https://jslib.k6.io/k6-summary/0.0.4/index.js"; +import { randomItem } from "https://jslib.k6.io/k6-utils/1.2.0/index.js"; + +export const options = { + // insecureSkipTLSVerify: true, + ext: {}, + thresholds: { + http_req_failed: ["rate<0.01"], + http_req_duration: ["p(90) < 2000", "p(95) < 3000", "p(99.9) < 5000"], + checks: ["rate>0.9"], + }, + stages: [ + { target: 1, duration: "10s" }, + // { target: 2, duration: "10s" }, + // { target: 5, duration: "30s" }, + // { target: 0, duration: "10s" }, + ], +}; + +const raceData = [ + { captureDate: "2024-02-25", raceDate: "2024-02-24", track: "OP", race: "1" }, + { captureDate: "2024-02-26", raceDate: "2024-02-25", track: "OP", race: "4" }, + { + captureDate: "2024-02-25", + raceDate: "2024-02-24", + track: "AQU", + race: "6", + }, + { + captureDate: "2024-02-26", + raceDate: "2024-02-25", + track: "TAM", + race: "7", + }, + { + captureDate: "2024-02-27", + raceDate: "2024-02-26", + track: "MVD", + race: "4", + }, +]; + +export function handleSummary(data) { + return { + "HeartTransplant.html": htmlReport(data), + "HeartTransplant.json": JSON.stringify(data), + stdout: textSummary(data, { indent: " ", enableColors: true }), + }; +} + +export default function () { + const randomRace = randomItem(raceData); + + let response; + + group("Home Page", function () { + response = http.get( + "https://myhorsestable.netlify.app/kentuckyderby?_data=routes%2Fkentuckyderby._index" + ); + check(response, { + "Get Derby Data": (r) => r.status === 200, + }); + }); + + group("Today Page", function () { + response = http.get( + "https://myhorsestable.netlify.app/kentuckyderby?_data=routes%2Fkentuckyderby._index" + ); + check(response, { + "Get Derby Data": (r) => r.status === 200, + }); + + // Wait list types + // 1a + // 1b + // 2 + // 7 + }); + + group("Yesterdays Page", function () { + response = http.get( + "https://myhorsestable.netlify.app/kentuckyderby?_data=routes%2Fkentuckyderby._index" + ); + check(response, { + "Get Derby Data": (r) => r.status === 200, + }); + }); + + group("Any Days Page", function () { + response = http.get( + "https://myhorsestable.netlify.app/kentuckyderby?_data=routes%2Fkentuckyderby._index" + ); + check(response, { + "Get Derby Data": (r) => r.status === 200, + }); + }); + + group("Region Charts Page", function () { + response = http.get( + "https://myhorsestable.netlify.app/kentuckyderby?_data=routes%2Fkentuckyderby._index" + ); + check(response, { + "Get Derby Data": (r) => r.status === 200, + }); + // do this for each region + }); + + group("USA Charts Page", function () { + response = http.get( + "https://myhorsestable.netlify.app/kentuckyderby?_data=routes%2Fkentuckyderby._index" + ); + check(response, { + "Get Derby Data": (r) => r.status === 200, + }); + }); +} diff --git a/tests/E2E.spec.ts b/tests/E2E.spec.ts new file mode 100644 index 0000000..a5d95f5 --- /dev/null +++ b/tests/E2E.spec.ts @@ -0,0 +1,52 @@ +import { test, expect } from "@playwright/test"; + +test.describe("End To End Tests", () => { + test("Today Page", async () => { + // go to todays page + // verify date format for todays date + // change each wait list status and make sure the data is loaded and lable is updated + // make sure the data refresh dates text is showing + // make sure the region text is showing + }); + test("Yesterday Page", async () => { + // go to yesterday page + // check the date. + }); + test("USA Charts", async () => { + // go to usa charts page and make sure all charts load and are visible + }); + test("Region Charts", async () => { + // go to specific region chart from today page and make sure each chart is visible + }); + test("Verify Region Info Popovers", async () => { + // go to todays page + // click icon and make sure list is visible + // click icon and make sure list is not visible + // verify all states for each region when the list is open + }); + test("Favorite/Unfavorite Region", async () => { + // go to todays page + // favorite a region + // unfavorite a region + // check start icon + // check text color + }); + test("Verify Center Count", async () => { + // get count from the database + // for a specific day verify the center count + // make sure count for today is not zero + }); + test("Verify Center Count Todays Page", async () => { + // get count from the database + // go to todays page + // make sure count for today matches the db + }); + test("Verify Region Counts and Trends", async () => { + // for a specific day, check all region counts and trends + // do this for each wait list type, 1a, 1b, 2, 7 and check all numbers + }); + test("Verify Footer Elements", async () => { + // buy me a coffe + // email link + }); +});