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