feat(jobs): complete workspace draft parity
CI and Deploy / test (pull_request) Successful in 5m4s
CI and Deploy / deploy (pull_request) Has been skipped

This commit is contained in:
cesnimda
2026-08-15 17:34:32 +02:00
parent 3b86ea2da0
commit deed948183
28 changed files with 676 additions and 131 deletions
+112
View File
@@ -45,6 +45,118 @@ test("a saved job can be created through the reviewed UI flow", async ({ page })
await expect(page.getByText(title, { exact: true })).toBeVisible();
});
test("the dedicated application workspace survives deep links, long data and unsaved navigation", async ({ page }) => {
const suffix = Date.now().toString();
const companyName = `Application Workspace Company With A Deliberately Long Name ${suffix}`;
const title = `Principal Platform Reliability Engineer For Distributed Customer Systems ${suffix}`;
await login(page);
const headers = await csrfHeader(page);
let companyResponse = await page.request.post(`${apiUrl}/companies`, {
headers,
data: { name: companyName, location: "Oslo and remote across Europe", source: "direct" },
});
for (let attempt = 0; attempt < 2 && !companyResponse.ok(); attempt += 1) {
await page.waitForTimeout(250);
companyResponse = await page.request.post(`${apiUrl}/companies`, {
headers,
data: { name: companyName, location: "Oslo and remote across Europe", source: "direct" },
});
}
const company = await companyResponse.json();
expect(companyResponse.ok(), `company create failed: ${companyResponse.status()} ${JSON.stringify(company)}`).toBeTruthy();
const jobData = {
jobTitle: title,
companyId: company.id,
status: "Applied",
location: "Oslo and remote across Europe",
salary: null,
salaryMin: null,
salaryMax: null,
salaryCurrency: null,
salaryPeriod: null,
nextAction: "Prepare a concise application answer",
followUpAt: null,
notes: "Ask about platform ownership and the incident response rotation.",
description: `Build reliable distributed systems. ${"Long responsibility text ".repeat(80)} https://example.test/${"very-long-path-segment/".repeat(12)}`,
translatedDescription: null,
descriptionLanguage: "en",
tags: JSON.stringify([".NET", "Kubernetes", "Incident response"]),
deadline: null,
coverLetterText: null,
jobUrl: "https://example.test/jobs/platform-reliability",
dateApplied: new Date().toISOString(),
feedbackRequestedAt: null,
source: "direct",
countryCode: "NO",
};
let jobResponse = await page.request.post(`${apiUrl}/jobapplications`, { headers, data: jobData });
for (let attempt = 0; attempt < 2 && !jobResponse.ok(); attempt += 1) {
await page.waitForTimeout(250);
jobResponse = await page.request.post(`${apiUrl}/jobapplications`, { headers, data: jobData });
}
expect(jobResponse.ok()).toBeTruthy();
const job = await jobResponse.json();
await page.goto("/jobs");
const applicationRow = page.getByRole("row", { name: new RegExp(`Open ${title}`, "i") });
await applicationRow.focus();
await page.keyboard.press("Enter");
await expect(page).toHaveURL(new RegExp(`/jobs/${job.id}$`));
await expect(page.getByRole("heading", { name: title })).toBeVisible();
await page.goBack();
await expect(page).toHaveURL(/\/jobs$/);
await page.goForward();
await expect(page).toHaveURL(new RegExp(`/jobs/${job.id}$`));
const workspaceNav = page.getByRole("navigation", { name: "Workspace sections" });
await workspaceNav.getByRole("button", { name: "Cover Letter", exact: true }).click();
await expect(page).toHaveURL(new RegExp(`/jobs/${job.id}\\?section=cover-letter$`));
await page.getByLabel("Application answer").fill("A reviewed answer that must not be lost.");
await workspaceNav.getByRole("button", { name: "Match", exact: true }).click();
await expect(page.getByRole("dialog", { name: "Unsaved application changes" })).toBeVisible();
await page.getByRole("button", { name: "Keep editing" }).click();
await expect(page.getByLabel("Application answer")).toHaveValue("A reviewed answer that must not be lost.");
await page.getByRole("button", { name: "Save application drafts" }).click();
await expect(page.getByText("Unsaved changes")).toHaveCount(0);
await page.evaluate(() => window.localStorage.setItem("jobtracker.themeMode", "light"));
await page.reload();
for (const width of [375, 768, 1440]) {
await page.setViewportSize({ width, height: 900 });
await expect(page.getByRole("heading", { name: title })).toBeVisible();
const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
expect(overflow).toBeLessThanOrEqual(1);
}
await page.evaluate(() => window.localStorage.setItem("jobtracker.themeMode", "dark"));
await page.reload();
await expect(page.getByLabel("Application answer")).toHaveValue("A reviewed answer that must not be lost.");
await expect(page.locator("html")).toHaveAttribute("data-color-scheme", "dark");
for (const width of [375, 768, 1440]) {
await page.setViewportSize({ width, height: 900 });
await expect(page.getByRole("heading", { name: title })).toBeVisible();
const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
expect(overflow).toBeLessThanOrEqual(1);
}
await workspaceNav.getByRole("button", { name: "Job Details", exact: true }).click();
await expect(page).toHaveURL(new RegExp(`/jobs/${job.id}\\?section=job-details$`));
await expect(page.getByText("Ask about platform ownership and the incident response rotation.")).toBeVisible();
await expect(page.getByText("<<<APPLICATION_ANSWER_DRAFT>>>")).toHaveCount(0);
await page.getByRole("button", { name: "Back to applications" }).click();
await expect(page).toHaveURL(/\/jobs$/);
await expect(page.getByRole("row", { name: new RegExp(`Open ${title}`, "i") })).toBeFocused();
await page.goto("/jobs/2147483647");
await expect(page.getByRole("alert").filter({ hasText: /Not Found|Could not open this application/i })).toBeVisible();
await expect(page.getByRole("button", { name: "Back to applications" })).toBeVisible();
});
test("Career Workspace loads from the authenticated application shell", async ({ page }) => {
await login(page);
await page.goto("/career");