test: use testids instead of text queries for unit tests (#5)
CI / Generate Certificates (push) Successful in 28s
CI / Frontend CI (push) Successful in 1m3s
CI / E2E Tests (push) Has been cancelled
CI / Backend CI (push) Has been cancelled

Co-authored-by: me <ramvignesh-b@github.com>
Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
2026-05-07 23:54:12 +00:00
parent 7e53229308
commit d625cbb1fb
12 changed files with 220 additions and 223 deletions
+4 -6
View File
@@ -1,4 +1,4 @@
import { render, screen, waitFor } from "@testing-library/react";
import { render, screen } from "@testing-library/react";
import { HttpResponse, http } from "msw";
import { MemoryRouter, Route, Routes, useLocation } from "react-router-dom";
import { beforeEach, describe, expect, it, vi } from "vitest";
@@ -76,9 +76,7 @@ describe("Reader Page", () => {
</Routes>
</MemoryRouter>,
);
await waitFor(() => {
expect(screen.getByText(/Guest/i)).toBeInTheDocument();
});
expect(await screen.findByTestId("envelope-recipient")).toHaveTextContent(/Guest/i);
});
it("should display an error message if the server request fails", async () => {
@@ -100,8 +98,8 @@ describe("Reader Page", () => {
);
expect(
await screen.findByText(/Failed to load letter/i),
).toBeInTheDocument();
await screen.findByTestId("log-modal-message"),
).toHaveTextContent(/Failed to load letter/i);
});
it("should navigate to the login page with redirect url when the letter has no sharing key and the user is not logged in", async () => {