Skip to content

Commit 1c1ef16

Browse files
committed
init tests
1 parent 794d6a5 commit 1c1ef16

File tree

5 files changed

+275
-0
lines changed

5 files changed

+275
-0
lines changed

.github/workflows/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
/test-results/
3+
/playwright-report/
4+
/playwright/.cache/

.github/workflows/main.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: JobSimulator.dev Test Checker
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
jobs:
17+
test:
18+
runs-on: ubuntu-latest
19+
container:
20+
image: mcr.microsoft.com/playwright:v1.31.0-focal
21+
steps:
22+
- uses: actions/checkout@v3
23+
- uses: actions/setup-node@v3
24+
with:
25+
node-version: 18
26+
- name: Install dependencies
27+
run: npm ci && cd .github/workflows && npm ci && cd ../..
28+
29+
- name: build app
30+
run: npx webpack
31+
32+
- name: start frontend
33+
run: npm run dev:frontend &
34+
35+
- name: start backend
36+
run: npm run dev:backend &
37+
38+
- name: Run Tests
39+
run: node .github/workflows/test.js

.github/workflows/package-lock.json

Lines changed: 169 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"type": "module",
3+
"devDependencies": {
4+
"playwright": "^1.31.1",
5+
"uvu": "^0.5.6"
6+
},
7+
"scripts": {}
8+
}

.github/workflows/test.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { chromium } from "playwright";
2+
import { test } from "uvu";
3+
import * as assert from "uvu/assert";
4+
5+
let browser;
6+
let context;
7+
let page;
8+
9+
test.before(async () => {
10+
browser = await chromium.launch({
11+
use: { timezoneId: "Etc/UTC" },
12+
});
13+
context = await browser.newContext();
14+
});
15+
16+
test.before.each(async () => {
17+
page = await context.newPage();
18+
});
19+
20+
test.after.each(async () => {
21+
await page.close();
22+
});
23+
24+
test.after(async () => {
25+
await browser.close();
26+
await context.close();
27+
});
28+
29+
test("Solved Issue #1: Sort By Price and Release Date", async () => {
30+
await page.goto("http://localhost:3000");
31+
32+
// Open Sort Menu
33+
await page.getByRole("button", { name: "Sort" }).click();
34+
35+
// Sort by Price
36+
await page.getByRole("menuitem", { name: "Price" }).click();
37+
var firstItemName = await page.$eval(
38+
"#root > main > div:nth-child(2) > div > div > a:nth-child(1) > h3",
39+
(el) => el.innerText
40+
);
41+
assert.is(firstItemName, "Focus Paper Refill");
42+
43+
// Open Sort Menu
44+
await page.getByRole("button", { name: "Sort" }).click();
45+
46+
// Sort by Newest
47+
await page.getByRole("menuitem", { name: "Newest" }).click();
48+
var firstItemName = await page.$eval(
49+
"#root > main > div:nth-child(2) > div > div > a:nth-child(1) > h3",
50+
(el) => el.innerText
51+
);
52+
assert.is(firstItemName, "Zip Tote Basket");
53+
});
54+
55+
test.run();

0 commit comments

Comments
 (0)