mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
test(browser): leave no state behind for the next case
Await the form's explicit unmount: an unmount left running overlaps the next render's act, and React then commits nothing for the rest of the file. Return to the newest history entry after stepping back, so the next case's push adds an entry instead of replacing the forward one.
This commit is contained in:
1 parent
54d0647a6d
commit
4f7802ba28
2 files changed
+9
-1
No files matched your search
@@ -289,7 +289,10 @@ describe("<MeasurementForm> type", () => {
|
||||
await first.screen.getByLabelText("Value (kg)").fill("80");
|
||||
await first.save.click();
|
||||
await expect.poll(() => first.onSuccess.mock.calls.length).toBe(1);
|
||||
first.screen.unmount();
|
||||
// Awaited: the unmount runs inside `act`, and one left running overlaps
|
||||
// the next render's `act`, after which React commits nothing for the
|
||||
// rest of the file (every later case finds an empty container).
|
||||
await first.screen.unmount();
|
||||
|
||||
const { screen } = await mount();
|
||||
await expect
|
||||
|
||||
@@ -242,6 +242,11 @@ describe("useUrlFilterSync with FilterBar", () => {
|
||||
window.history.back();
|
||||
await expectSearch("?type=WEIGHT");
|
||||
await expect.element(pill("Type: Weight")).toBeInTheDocument();
|
||||
// Back to the newest entry. Left one step behind, the page keeps a
|
||||
// forward entry, and the next case's push replaces it instead of adding
|
||||
// one: `history.length` stays put and its count of entries is off by one.
|
||||
window.history.forward();
|
||||
await expectSearch("?type=PULSE");
|
||||
});
|
||||
|
||||
it("keeps the state in memory and the address untouched with syncToUrl off", async () => {
|
||||
|
||||
Reference in new issue
Block a user