Skip to content

Commit db9c906

Browse files
committed
added tests
1 parent 7c85fe9 commit db9c906

File tree

6 files changed

+317
-1
lines changed

6 files changed

+317
-1
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 webpack server
33+
run: npx webpack serve &
34+
35+
- name: start backend
36+
run: npm run start-json-server &
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: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { chromium } from "playwright";
2+
import { setTimeout } from "timers/promises";
3+
import { test } from "uvu";
4+
import * as assert from "uvu/assert";
5+
6+
let browser;
7+
let context;
8+
let page;
9+
10+
test.before(async () => {
11+
browser = await chromium.launch({
12+
use: { timezoneId: "Etc/UTC" },
13+
});
14+
context = await browser.newContext();
15+
});
16+
17+
test.before.each(async () => {
18+
page = await context.newPage();
19+
});
20+
21+
test.after.each(async () => {
22+
await page.close();
23+
});
24+
25+
test.after(async () => {
26+
await browser.close();
27+
await context.close();
28+
});
29+
30+
test("Solved Issue #1: Company Names are Present", async () => {
31+
await page.goto("http://localhost:8080");
32+
await setTimeout(250);
33+
34+
var text = await page.$eval("body > table > tbody > tr:nth-child(2) > td:nth-child(1)", (el) => el.textContent);
35+
assert.type(text, "string");
36+
assert.is(text, "Fusion LLC");
37+
38+
var text = await page.$eval("body > table > tbody > tr:nth-child(3) > td:nth-child(1)", (el) => el.textContent);
39+
assert.type(text, "string");
40+
assert.is(text, "Techopolis Ltd.");
41+
42+
var text = await page.$eval("body > table > tbody > tr:nth-child(4) > td:nth-child(1)", (el) => el.textContent);
43+
assert.type(text, "string");
44+
assert.is(text, "Code learning LLC");
45+
});
46+
47+
test("Solved Issue #2: display dates in 24-hour time format", async () => {
48+
await page.goto("http://localhost:8080");
49+
await setTimeout(250);
50+
51+
var text = await page.$eval("body > table > tbody > tr:nth-child(2) > td:nth-child(3)", (el) => el.textContent);
52+
assert.type(text, "string");
53+
assert.is(text, "03:41");
54+
55+
var text = await page.$eval("body > table > tbody > tr:nth-child(3) > td:nth-child(3)", (el) => el.textContent);
56+
assert.type(text, "string");
57+
assert.is(text, "08:45");
58+
59+
var text = await page.$eval("body > table > tbody > tr:nth-child(4) > td:nth-child(3)", (el) => el.textContent);
60+
assert.type(text, "string");
61+
assert.is(text, "12:45");
62+
});
63+
64+
test("Solved Issue #3: display revenue numbers in a human readable format", async () => {
65+
await page.goto("http://localhost:8080");
66+
await setTimeout(250);
67+
68+
var text = await page.$eval("body > table > tbody > tr:nth-child(2) > td:nth-child(4)", (el) => el.textContent);
69+
assert.type(text, "string");
70+
assert.is(text, "17 000 000");
71+
72+
var text = await page.$eval("body > table > tbody > tr:nth-child(3) > td:nth-child(4)", (el) => el.textContent);
73+
assert.type(text, "string");
74+
assert.is(text, "7 375 294");
75+
76+
var text = await page.$eval("body > table > tbody > tr:nth-child(4) > td:nth-child(4)", (el) => el.textContent);
77+
assert.type(text, "string");
78+
assert.is(text, "100 000");
79+
});
80+
81+
test("Solved Issue #4: make table look prettier", async () => {
82+
await page.goto("http://localhost:8080");
83+
await setTimeout(250);
84+
85+
var headerColor = await page.$eval("tr:first-of-type", (el) =>
86+
getComputedStyle(el).getPropertyValue("background-color")
87+
);
88+
assert.is(headerColor, "rgb(173, 216, 230)");
89+
90+
var tableBorderColor = await page.$eval("body > table", (el) =>
91+
getComputedStyle(el).getPropertyValue("border-color")
92+
);
93+
assert.is(tableBorderColor, "rgb(173, 216, 230)");
94+
});
95+
96+
test.run();

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ yarn-error.log*
5959

6060

6161
# Dependency directories
62-
node_modules/
62+
**node_modules**
6363
jspm_packages/
6464

6565
# Optional npm cache directory

0 commit comments

Comments
 (0)