Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be94ba0520 |
No files matched your search
@@ -24,4 +24,30 @@ describe("send button", () => {
|
|||||||
fireEvent.click(await screen.findByRole("button", { name: "Enviar de novo a que já tinha ido" }));
|
fireEvent.click(await screen.findByRole("button", { name: "Enviar de novo a que já tinha ido" }));
|
||||||
await waitFor(() => expect(calls).toEqual([[["a", "b"], false], [["a"], true]]));
|
await waitFor(() => expect(calls).toEqual([[["a", "b"], false], [["a"], true]]));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("remembers the chosen destination across a remount (tab switch)", () => {
|
||||||
|
try {
|
||||||
|
window.localStorage.clear();
|
||||||
|
} catch {
|
||||||
|
/* jsdom without storage */
|
||||||
|
}
|
||||||
|
const api = {} as unknown as ApiClient;
|
||||||
|
const targets = [
|
||||||
|
{ id: "zz", name: "ZZ", kind: "ZEROZERO" },
|
||||||
|
{ id: "fpa", name: "FPA", kind: "NEXTCLOUD" },
|
||||||
|
] as unknown as DeliveryTarget[];
|
||||||
|
const view = render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<SendButton api={api} orgId="org" selection={[]} targets={targets} onQueued={() => {}} />
|
||||||
|
</MemoryRouter>,
|
||||||
|
);
|
||||||
|
fireEvent.change(screen.getByRole("combobox"), { target: { value: "fpa" } });
|
||||||
|
view.unmount();
|
||||||
|
render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<SendButton api={api} orgId="org" selection={[]} targets={targets} onQueued={() => {}} />
|
||||||
|
</MemoryRouter>,
|
||||||
|
);
|
||||||
|
expect((screen.getByRole("combobox") as HTMLSelectElement).value).toBe("fpa");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -26,7 +26,10 @@ export function SendButton(props: { api: ApiClient; orgId: string; selection: Ph
|
|||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
const [note, setNote] = useState<string | null>(null);
|
const [note, setNote] = useState<string | null>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (targets.length && !targets.some((x) => x.id === targetId)) setTargetId(targets[0]!.id);
|
if (targets.length && !targets.some((x) => x.id === targetId)) {
|
||||||
|
setTargetId(targets[0]!.id);
|
||||||
|
prefs.set(LAST_TARGET, targets[0]!.id);
|
||||||
|
}
|
||||||
}, [targets, targetId]);
|
}, [targets, targetId]);
|
||||||
useEffect(() => setAlready([]), [targetId, eventId]);
|
useEffect(() => setAlready([]), [targetId, eventId]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -84,7 +87,7 @@ export function SendButton(props: { api: ApiClient; orgId: string; selection: Ph
|
|||||||
<span className="relative flex items-center gap-1">
|
<span className="relative flex items-center gap-1">
|
||||||
{target?.kind === "ZEROZERO" && eventId && <ZerozeroGamePicker api={api} orgId={orgId} targetId={targetId} eventId={eventId} compact />}
|
{target?.kind === "ZEROZERO" && eventId && <ZerozeroGamePicker api={api} orgId={orgId} targetId={targetId} eventId={eventId} compact />}
|
||||||
{targets.length > 1 && (
|
{targets.length > 1 && (
|
||||||
<select aria-label={t.deliverTo} value={targetId} onChange={(e) => setTargetId(e.target.value)} className="h-6 max-w-[140px] border border-black bg-cell px-1 text-[12px] text-ink">
|
<select aria-label={t.deliverTo} value={targetId} onChange={(e) => { setTargetId(e.target.value); prefs.set(LAST_TARGET, e.target.value); }} className="h-6 max-w-[140px] border border-black bg-cell px-1 text-[12px] text-ink">
|
||||||
{targets.map((x) => (
|
{targets.map((x) => (
|
||||||
<option key={x.id} value={x.id}>
|
<option key={x.id} value={x.id}>
|
||||||
{x.name}
|
{x.name}
|
||||||
|
|||||||
Reference in new issue
Block a user