-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocuments.spec.ts
More file actions
63 lines (52 loc) · 1.68 KB
/
documents.spec.ts
File metadata and controls
63 lines (52 loc) · 1.68 KB
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
/**
* Document upload and management E2E tests.
*/
import { test, expect } from "@playwright/test";
import path from "path";
import { registerUser } from "./helpers/auth";
test.describe("Documents", () => {
test.beforeEach(async ({ page }) => {
await registerUser(page);
});
test("upload a text file as resume and see it in the list", async ({
page,
}) => {
await page.goto("/documents");
// Select resume type (default) and upload
const fileInput = page.locator('input[type="file"]');
await fileInput.setInputFiles(
path.join(__dirname, "fixtures", "sample.txt"),
);
// Wait for success toast
await expect(page.getByText(/uploaded.*successfully/i)).toBeVisible({
timeout: 10000,
});
// File should appear in the list
await expect(page.getByText("sample.txt", { exact: true })).toBeVisible();
});
test("delete a document removes it from the list", async ({ page }) => {
await page.goto("/documents");
// Upload first
const fileInput = page.locator('input[type="file"]');
await fileInput.setInputFiles(
path.join(__dirname, "fixtures", "sample.txt"),
);
await expect(page.getByText(/uploaded.*successfully/i)).toBeVisible({
timeout: 10000,
});
// Click delete button
await page
.getByRole("button", { name: /delete/i })
.first()
.click();
// Confirm in dialog
const confirmButton = page.getByRole("button", { name: /confirm|delete/i });
if (await confirmButton.isVisible()) {
await confirmButton.click();
}
// File should be removed
await expect(page.getByText("sample.txt", { exact: true })).toBeHidden({
timeout: 5000,
});
});
});