Skip to content
28 changes: 22 additions & 6 deletions tests/facility/settings/devices/deviceServiceHistory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,27 @@ test.describe("Device Service History", () => {
.first()
.click();

// Scope all edit-sheet interactions to its dialog to avoid strict-mode
// violations when the Add sheet is still in the DOM during its close animation.
const editSheet = page.getByRole("dialog", {
name: "Edit Service Record",
});
await expect(editSheet).toBeVisible({ timeout: 10000 });
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

const pastYear = new Date().getFullYear() - 1;
await page
await editSheet
.locator('[data-slot="form-item"]')
.filter({ hasText: "Service Date" })
.locator('[data-slot="popover-trigger"]')
.click();
await page.locator(".rdp-years_dropdown").selectOption(pastYear.toString());
await page.locator('[role="gridcell"]:not([data-outside])').first().click();

await page.getByRole("textbox", { name: "Notes *" }).fill(updatedNotes);
await editSheet
.getByRole("textbox", { name: "Notes *" })
.fill(updatedNotes);

await page.getByRole("button", { name: "Update" }).click();
await editSheet.getByRole("button", { name: "Update" }).click();

const updatedCard = page
.locator('[data-slot="card"]')
Expand Down Expand Up @@ -183,14 +192,21 @@ test.describe("Device Service History", () => {
.first()
.click();

const updateButton = page.getByRole("button", { name: "Update" });
// Scope all edit-sheet interactions to its dialog to avoid strict-mode
// violations when the Add sheet is still in the DOM during its close animation.
const editSheet = page.getByRole("dialog", {
name: "Edit Service Record",
});
await expect(editSheet).toBeVisible({ timeout: 10000 });

const updateButton = editSheet.getByRole("button", { name: "Update" });
await expect(updateButton).toBeDisabled();

await page.getByRole("textbox", { name: "Notes *" }).fill(updatedNotes);
await editSheet.getByRole("textbox", { name: "Notes *" }).fill(updatedNotes);

await expect(updateButton).toBeEnabled();

await page.getByRole("textbox", { name: "Notes *" }).fill(notes);
await editSheet.getByRole("textbox", { name: "Notes *" }).fill(notes);

await expect(updateButton).toBeDisabled();
});
Expand Down
Loading