fix(notifications): a notice's button is said when shown, like its text
An action label was translated when the notice was raised, so after a language switch a live toast or center row read in one language with its button in the other. The access-requests nudge no longer re-issues on a switch for it. New tests: the button and a server refusal follow a switch.
This commit is contained in:
@@ -15,8 +15,11 @@ vi.mock("react-i18next", async (importOriginal) => ({
|
||||
}));
|
||||
const { notify } = vi.hoisted(() => ({
|
||||
notify: vi.fn(
|
||||
(_n: { level: string; message: NotifText; action?: { label: string; onClick: () => void } }) =>
|
||||
0,
|
||||
(_n: {
|
||||
level: string;
|
||||
message: NotifText;
|
||||
action?: { label: NotifText; onClick: () => void };
|
||||
}) => 0,
|
||||
),
|
||||
}));
|
||||
vi.mock("../../lib/notifications", async (importOriginal) => ({
|
||||
@@ -149,7 +152,7 @@ describe("usePlexPlaylistEdits · the removal", () => {
|
||||
expect(toast.message).toEqual(
|
||||
msg("plex.playlist.removedToast", { title: raw("Show · Season 1") }),
|
||||
);
|
||||
expect(toast.action!.label).toBe("common.undo");
|
||||
expect(toast.action!.label).toEqual(msg("common.undo"));
|
||||
act(() => toast.action!.onClick());
|
||||
await waitFor(() => expect(add).toHaveBeenCalledTimes(1));
|
||||
expect(add).toHaveBeenCalledWith(5, ["2", "4"], [1, 3]);
|
||||
|
||||
@@ -13,7 +13,7 @@ import { reinsertAt } from "../../lib/reinsert";
|
||||
* Split from `PlexPlaylistView` so the failure paths are reachable from a test: the reorder is
|
||||
* driven by a dnd-kit drag, and neither of its sensors activates under jsdom. */
|
||||
export function usePlexPlaylistEdits(playlistId: number) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const { i18n } = useTranslation();
|
||||
const qc = useQueryClient();
|
||||
const [busy, setBusy] = useState(false);
|
||||
// The rows' titles are in the reader's language, so the cache entry is per language — and ONE
|
||||
@@ -112,7 +112,7 @@ export function usePlexPlaylistEdits(playlistId: number) {
|
||||
level: "success",
|
||||
message: msg("plex.playlist.removedToast", { title }),
|
||||
action: {
|
||||
label: t("common.undo"),
|
||||
label: msg("common.undo"),
|
||||
onClick: () =>
|
||||
void qc
|
||||
.fetchQuery({
|
||||
|
||||
Reference in New Issue
Block a user