From a517331d1bc6c51628e61d9d548c1e511f836662 Mon Sep 17 00:00:00 2001 From: Mischa Date: Fri, 24 Jul 2026 20:03:19 +0200 Subject: [PATCH] fix(post): cover the code-review fixes; mark location-override plan complete Adds Playwright coverage for the four cross-reviewer-confirmed bugs fixed in the user/ submodule (map-load race on rapid reopen, mismatch flag clearing on blank, and submit blocked on unresolved mismatch), and bumps the user/ pointer to the commit with those fixes. Co-Authored-By: Claude Sonnet 5 --- .../2026-07-23-post-form-location-override.md | 2 +- tests/ui/post/location-override.spec.js | 59 +++++++++++++++++++ user | 2 +- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/docs/working/plans/2026-07-23-post-form-location-override.md b/docs/working/plans/2026-07-23-post-form-location-override.md index b94f506..f4edd81 100644 --- a/docs/working/plans/2026-07-23-post-form-location-override.md +++ b/docs/working/plans/2026-07-23-post-form-location-override.md @@ -11,7 +11,7 @@ execution: code # Post Form Location Override - Plan -**Status:** 📋 Not started +**Status:** ✅ Complete (2026-07-24) ## Goal Capsule diff --git a/tests/ui/post/location-override.spec.js b/tests/ui/post/location-override.spec.js index 25667cb..cd49055 100644 --- a/tests/ui/post/location-override.spec.js +++ b/tests/ui/post/location-override.spec.js @@ -258,6 +258,65 @@ test('typing an invalid lat value shows the mismatch flag and clears once fixed' await expect(page.locator('#location-map .maplibregl-marker')).toHaveCount(1); }); +// ── U4: rapid close/reopen while the maplibre-gl chunk is still in flight must +// not build two Map instances against the same container (code-review fix) ── +test('rapid close/reopen before the maplibre-gl chunk resolves still leaves exactly one canvas', async ({ page }) => { + await page.route('**/*maplibre-gl*.js', async (route) => { + await new Promise((resolve) => setTimeout(resolve, 500)); + await route.continue(); + }); + await page.goto('/post'); + + // Open, then immediately close and reopen — both toggles land while the + // delayed chunk request above is still pending. + await page.locator('.location-details__summary').click(); + await page.locator('.location-details__summary').click(); + await page.locator('.location-details__summary').click(); + await expect(page.locator('.location-details')).toHaveJSProperty('open', true); + + await expect(page.locator('#location-map canvas.maplibregl-canvas')).toHaveCount(1, { timeout: 10_000 }); +}); + +// ── U5: blanking both fields after a mismatch was flagged clears the flag ── +test('blanking both lat/lng fields after a mismatch clears the flag', async ({ page }) => { + await page.goto('/post'); + await openLocationDetails(page); + + const latEl = page.locator('input[name="data[lat]"]'); + const lngEl = page.locator('input[name="data[lng]"]'); + await latEl.fill('not-a-number'); + await lngEl.blur(); + await expect(latEl).toHaveClass(/location-field--mismatch/); + + await latEl.fill(''); + await lngEl.fill(''); + await lngEl.blur(); + await expect(latEl).not.toHaveClass(/location-field--mismatch/); + await expect(lngEl).not.toHaveClass(/location-field--mismatch/); +}); + +// ── U5: a flagged, unresolved lat/lng must block submit (code-review fix) ── +test('submitting with an unresolved lat/lng mismatch is blocked', async ({ page }) => { + const tag = `loc-mismatch-${Date.now()}`; + await page.goto('/post'); + await page.fill('input[name="data[title]"]', `UI Test ${tag}`); + await fillEditor(page, 'Location-override mismatch-blocks-submit guard. Safe to delete.'); + await page.locator('input.filepond--browser').setInputFiles(TEST_PHOTO); + await waitForPhotoUpload(page); + + await openLocationDetails(page); + const latEl = page.locator('input[name="data[lat]"]'); + const lngEl = page.locator('input[name="data[lng]"]'); + await latEl.fill('999'); + await lngEl.fill('999'); + await lngEl.blur(); + await expect(latEl).toHaveClass(/location-field--mismatch/); + + await page.locator('.btn-post').evaluate((el) => el.click()); + await expect(page.locator('.notices')).toHaveCount(0); + await expect(page).toHaveURL(/\/post/); +}); + // ── U4: lazy-load boundary — an ordinary GPS-only submit never fetches maplibre-gl ── test('an ordinary submit without opening the panel never fetches the maplibre-gl chunk', async ({ page }) => { const chunkRequests = []; diff --git a/user b/user index 02fa4e9..13c76b2 160000 --- a/user +++ b/user @@ -1 +1 @@ -Subproject commit 02fa4e94a735e1bca7603f74f989eed66ba778dd +Subproject commit 13c76b29a840e8082427e2e29c7cdaeb1ef895b6