fix: update Reader tests to include envelope

This commit is contained in:
ramvignesh-b
2026-04-21 04:44:07 +05:30
parent 4c204b0a80
commit 50bae8d2ce
2 changed files with 31 additions and 29 deletions
+6 -9
View File
@@ -1,4 +1,4 @@
import { render, screen } from "@testing-library/react";
import { render, screen, waitFor } from "@testing-library/react";
import { HttpResponse, http } from "msw";
import { MemoryRouter, Route, Routes } from "react-router-dom";
import { beforeEach, describe, expect, it, vi } from "vitest";
@@ -48,7 +48,7 @@ describe("Reader Page", () => {
).toBeInTheDocument();
});
it("should load and decrypt the letter when a valid key is provided", async () => {
it("should load and decrypt the letter when a valid key is provided and display the envelope", async () => {
const mockPublicId = "test-uuid";
const letterContent = JSON.stringify({ objects: [] });
const metadata = { recipient: "Guest" };
@@ -69,19 +69,16 @@ describe("Reader Page", () => {
}),
);
render(
const {container} = render(
<MemoryRouter initialEntries={[`/read/${mockPublicId}#${sharingKey}`]}>
<Routes>
<Route path="/read/:public_id" element={<Reader />} />
</Routes>
</MemoryRouter>,
);
// Should show loading state first
expect(screen.getByText(/Breaking the seal.../i)).toBeInTheDocument();
expect(await screen.findByText(/A sealed letter for/i)).toBeInTheDocument();
expect(screen.getAllByText(/Guest/i).length).toBeGreaterThanOrEqual(1);
await waitFor(() => {
expect(screen.getByText(/Guest/i)).toBeInTheDocument();
})
});
it("should display an error message if the server request fails", async () => {