v4: /follow/playlists opens the followed playlists' feed, and a page's test opens it through the app's routes — the path was a 404 since the two views of the followed feed became pages: the route table held each feed tab as an exact path, /follow, so /follow/playlists fell to /:handle/*, which read "follow" as a category and "playlists" as a tab it hasn't. /music/follow/playlists, which goes through that route, worked. The tabs' routes now take what follows them (/${tab}/*), which Feed already reads and refuses when it names no view.
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 57s
Build and Deploy Static Documentation Site / build-and-push (push) Successful in 28s

No test saw it because each page's test mounted the page on a route pattern of its own, a copy of App's, with stand-in pages where a redirect lands: Index's parsed the path itself, and passed on one the app doesn't serve. renderPage (src/test/render.tsx) now opens a URL through AppRoutes, which App.tsx exports for it, inside the real providers, and every page's test uses it: the page is the one the app routes that URL to, behind its guard, and a redirect is checked by the path it lands on. An entry may be a location, to arrive with the state a link hands over. Every page being loaded with its route, the first query after opening one waits. src/test/App.test.tsx tests the table itself: the paths that are a feed, those that are not found, those that send a guest to sign in and back, and those that send a signed-in user home.

The profile's test held /@ann/dumps/x to be a path the profile answers as not found, which only its own pattern made true: in the app it is a dump's page. It now asks for /@ann/dumps/x/y. The tests of the two guards still mount them around a stand-in child, being tests of the guard alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
khannurien
2026-10-10 19:59:52 +00:00
parent cbb770bff8
commit 3e15e9a4f2
20 changed files with 263 additions and 290 deletions

View File

@@ -1,19 +1,13 @@
import { describe, expect, test } from "vitest";
import { screen } from "@testing-library/react";
import { screen, waitFor } from "@testing-library/react";
import { userEvent } from "@testing-library/user-event";
import { Route } from "react-router";
import { ResetPassword } from "../../pages/ResetPassword.tsx";
import { calls, fail, route } from "../fetch.ts";
import { renderWithContexts } from "../render.tsx";
import { currentPath, renderPage } from "../render.tsx";
describe("ResetPassword", () => {
function setup(search = "?token=rst") {
const user = userEvent.setup();
renderWithContexts(<ResetPassword />, {
route: `/reset-password${search}`,
path: "/reset-password",
extraRoutes: <Route path="/login" element={<p>login page</p>} />,
});
renderPage(`/reset-password${search}`);
return user;
}
@@ -21,7 +15,7 @@ describe("ResetPassword", () => {
route("POST /api/password-resets", () => ({}));
const user = setup("");
await user.type(
screen.getByPlaceholderText("Your email address"),
await screen.findByPlaceholderText("Your email address"),
" a@b.c {Enter}",
);
await screen.findByText(/you'll receive a reset link/);
@@ -38,7 +32,7 @@ describe("ResetPassword", () => {
route("POST /api/password-resets", () => fail("Internal error", 500));
const user = setup("");
await user.type(
screen.getByPlaceholderText("Your email address"),
await screen.findByPlaceholderText("Your email address"),
"a@b.c{Enter}",
);
expect(await screen.findByRole("alert")).toHaveTextContent(
@@ -50,7 +44,10 @@ describe("ResetPassword", () => {
test("the two passwords must match", async () => {
const user = setup();
await user.type(screen.getByPlaceholderText("New password"), "longenough");
await user.type(
await screen.findByPlaceholderText("New password"),
"longenough",
);
await user.type(
screen.getByPlaceholderText("Confirm new password"),
"different",
@@ -64,7 +61,10 @@ describe("ResetPassword", () => {
test("sets the password, then offers login", async () => {
route("PUT /api/password-resets/:token", () => ({}));
const user = setup();
await user.type(screen.getByPlaceholderText("New password"), "longenough");
await user.type(
await screen.findByPlaceholderText("New password"),
"longenough",
);
await user.type(
screen.getByPlaceholderText("Confirm new password"),
"longenough{Enter}",
@@ -76,7 +76,7 @@ describe("ResetPassword", () => {
newPassword: "longenough",
});
await user.click(screen.getByRole("button", { name: "Go to login" }));
expect(screen.getByText("login page")).toBeInTheDocument();
await waitFor(() => expect(currentPath()).toBe("/login"));
});
test("an expired token is reported", async () => {
@@ -85,7 +85,10 @@ describe("ResetPassword", () => {
() => fail("Reset link expired", 400),
);
const user = setup();
await user.type(screen.getByPlaceholderText("New password"), "longenough");
await user.type(
await screen.findByPlaceholderText("New password"),
"longenough",
);
await user.type(
screen.getByPlaceholderText("Confirm new password"),
"longenough{Enter}",