160 lines
5.5 KiB
JavaScript
160 lines
5.5 KiB
JavaScript
const assert = require("node:assert/strict");
|
|
const path = require("node:path");
|
|
const { writeFileSync } = require("node:fs");
|
|
const { chromium } = require(
|
|
require.resolve("playwright", {
|
|
paths: [path.resolve(__dirname, "../../../../job-tracker-ui")],
|
|
}),
|
|
);
|
|
const base = process.env.JOBJAKT_GALLERY_URL || "http://127.0.0.1:4327";
|
|
|
|
async function verify() {
|
|
const browser = await chromium.launch();
|
|
const results = [];
|
|
try {
|
|
for (const concept of "ABCDE") {
|
|
for (const width of [1440, 390]) {
|
|
const lang = width === 390 ? "nb" : "en";
|
|
const theme = width === 390 ? "dark" : "light";
|
|
const page = await browser.newPage({
|
|
viewport: { width, height: 900 },
|
|
});
|
|
const errors = [];
|
|
page.on("pageerror", (error) => errors.push(error.message));
|
|
await page.goto(
|
|
base +
|
|
"/?concept=" +
|
|
concept +
|
|
"&screen=discover&lang=" +
|
|
lang +
|
|
"&theme=" +
|
|
theme,
|
|
);
|
|
await page.locator("#country").selectOption("Norway");
|
|
await page.locator("#search").fill("Electrician");
|
|
await page
|
|
.locator("#jobResults")
|
|
.getByRole("link", { name: "Electrician", exact: true })
|
|
.click();
|
|
assert.equal(await page.locator("main h1").innerText(), "Electrician");
|
|
assert.match(
|
|
await page.locator("main .heading").innerText(),
|
|
/North Coast Energy · Trondheim, Norway/,
|
|
);
|
|
await page.locator('[data-action="save"]').click();
|
|
await page.locator("#notes").fill("Ask about the field team.");
|
|
await page.locator('[data-action="saveNotes"]').click();
|
|
await page.locator('[data-action="cv"]').click();
|
|
assert.match(
|
|
await page.locator("main .heading").innerText(),
|
|
/North Coast Energy/,
|
|
);
|
|
await page.locator("#summary").fill("Field electrician CV.");
|
|
assert.equal(
|
|
await page.locator("#summaryPreview").innerText(),
|
|
"Field electrician CV.",
|
|
);
|
|
await page.locator("#screen").selectOption("detail");
|
|
await page.locator('[data-action="apply"]').click();
|
|
await page.locator('[data-action="follow"]').click();
|
|
await page
|
|
.locator("main")
|
|
.getByRole("link", { name: /North Coast Energy/ })
|
|
.click();
|
|
assert.equal(await page.locator("main h1").innerText(), "Electrician");
|
|
assert.equal(
|
|
await page.locator("#notes").inputValue(),
|
|
"Ask about the field team.",
|
|
);
|
|
await page.locator("#screen").selectOption("calendar");
|
|
await page.locator('[data-action="month"]').click();
|
|
await page
|
|
.locator(".calendar")
|
|
.getByRole("link", { name: "North Coast Energy" })
|
|
.click();
|
|
assert.equal(await page.locator("main h1").innerText(), "Electrician");
|
|
await page.locator("#screen").selectOption("applications");
|
|
await page.locator('[data-action="board"]').click();
|
|
const column = page
|
|
.locator(".board section")
|
|
.filter({
|
|
has: page.getByRole("heading", {
|
|
name: lang === "en" ? "Applied" : "Søkt",
|
|
exact: true,
|
|
}),
|
|
});
|
|
await column
|
|
.getByRole("link", { name: "Electrician", exact: true })
|
|
.click();
|
|
assert.equal(
|
|
await page.locator("#notes").inputValue(),
|
|
"Ask about the field team.",
|
|
);
|
|
await page.locator("#screen").selectOption("discover");
|
|
await page.locator("#country").selectOption("Denmark");
|
|
await page.locator("#search").fill("supervisor");
|
|
await page
|
|
.locator("#jobResults")
|
|
.getByRole("link", { name: "Front-of-house supervisor", exact: true })
|
|
.click();
|
|
assert.equal(await page.locator("#notes").inputValue(), "");
|
|
assert.equal(
|
|
await page.locator("main h1").innerText(),
|
|
"Front-of-house supervisor",
|
|
);
|
|
await page.locator('[data-action="cv"]').click();
|
|
assert.match(
|
|
await page.locator("main .heading").innerText(),
|
|
/Harbour House/,
|
|
);
|
|
assert.notEqual(
|
|
await page.locator("#summary").inputValue(),
|
|
"Field electrician CV.",
|
|
);
|
|
assert.deepEqual(errors, []);
|
|
results.push({ concept, width, lang, theme, passed: true });
|
|
await page.close();
|
|
}
|
|
}
|
|
const page = await browser.newPage();
|
|
await page.goto(base + "/compare.html");
|
|
for (const screen of [
|
|
"home",
|
|
"cv",
|
|
"discover",
|
|
"error",
|
|
"empty",
|
|
"loading",
|
|
]) {
|
|
await page.locator("#screen").selectOption(screen);
|
|
for (const link of await page.locator(".pair a").all()) {
|
|
assert.equal(
|
|
(
|
|
await page.request.get(
|
|
new URL(await link.getAttribute("href"), base).href,
|
|
)
|
|
).status(),
|
|
200,
|
|
);
|
|
}
|
|
}
|
|
await page.goto(
|
|
base + "/?concept=unknown&screen=constructor&theme=invalid",
|
|
);
|
|
assert.equal(await page.getByRole("heading", { level: 1 }).count(), 1);
|
|
writeFileSync(
|
|
path.join(__dirname, "selected-job-validation.json"),
|
|
JSON.stringify({ results, comparisonImageResponses: 60 }, null, 2) + "\n",
|
|
);
|
|
console.log(
|
|
results.length + " selected-job journeys and 60 comparison images passed",
|
|
);
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
}
|
|
verify().catch((error) => {
|
|
console.error(error);
|
|
process.exitCode = 1;
|
|
});
|