Added a Delete button to each row of the Links page with an in-page… #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "osf/68-delete-a-link-verification-of-176-182"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What was done
." once at the top, above the table.POST /links/<code>/deleteendpoint that removes the record and redirects back to the Links page with the deleted code in the query string.e2e/links.spec.tscovering the confirm-delete and cancel-delete paths.npm teststarts its own embedded Postgres when noDATABASE_URLis set — no external database needed to run the unit tests.How to review
npm test— all unit tests pass, including the new delete, endpoint, and page-rendering tests; no external Postgres setup is needed.npx playwright install chromiumand thennpm run test:e2e— both new browser tests (confirm-delete and cancel) pass.DATABASE_URL(or runscripts/services.mjsfirst for an embedded Postgres), thennpm start, and open http://localhost:3000/links in a browser.." appears at the top, and visiting the deleted code shows the 404 page.src/pages.tsfor the delete button and in-page confirmation, andsrc/server.tsfor the new endpoint.Code review
Reviewed the link-deletion change (the deleteLink db statement, POST /links/
/delete answering 303 to /links?deleted=, the in-row confirmation UI, and its unit/e2e tests) against the proposal, delta specs and tasks. Found and fixed four bugs: the author stylesheet ruleform { display: flex }overrode the UA[hidden]style so every 'Delete this link?' prompt was visible on load and Cancel could not hide it (verified in a real browser; fixed withform[hidden] { display: none; }); both new e2e tests derived the origin from about:blank before first navigation, yielding invalid 'null/...' URLs; the e2e test asserted whole-table row counts against a shared DB that holds other rows; and two unit tests asserted 303 from a fetch that follows redirects. After the fixes: tsc clean, 48/48 unit tests pass, 10/10 e2e tests pass (including the 390px/1280px no-horizontal-scroll checks), playwright --list registers all 24 tests, and openspec validate --strict passes.Fixed before the commit
src/pages.ts:16: The author ruleform { display: flex; }overrides the UA[hidden] { display: none; }(author origin beats UA origin regardless of specificity), so every row's 'Delete this link?' prompt (form.del-prompt) rendered visible on load and Cancel could not hide it — the spec's in-page confirmation scenarios did not hold in a real browser. Verified empirically: a live chromium run reported the form with hidden="" as visible and the e2e cancel test failed on not.toBeVisible(). Fixed by addingform[hidden] { display: none; }to STYLES; e2e then passes.e2e/links.spec.ts:81: Both new e2e tests computedorigin = new URL(page.url()).originbefore any navigation; the page starts at about:blank, whose origin is the string 'null', so the URL to shorten was 'null/links?stamp=...' and the form answered 'not a valid URL' — both tests failed in shortenViaForm before reaching the delete UI (lines 81 and 142). Fixed by addingawait page.goto('/')at the top of both tests, matching the file's existing test pattern.e2e/links.spec.ts:94: The delete test assertedpage.locator('tbody tr')toHaveCount(2) (and later toHaveCount(1) for the remaining row), but the Links page lists every stored link: four rows from earlier tests in the same file (no cleanup between tests) plus rows from shorten.spec.ts and follow.spec.ts, which run in parallel workers against the same Postgres — the counts were wrong on every run. Fixed by scoping both assertions to the test's two stamped rows (a .or() of the two hasText locators) while keeping the newest-first ordering check.test/server.test.ts:257: Two new tests asserted expect(del.status).toBe(303) onfetch(url, { method: 'POST' })withoutredirect: 'manual'; Node's fetch follows the 303 to GET /links?deleted=(200), so both unit tests failed (lines 257 and 300). Fixed by addingredirect: 'manual', as the sibling 'removes the stored record' test already did.Tests
All 11 scenarios of
let-a-link-be-deleted-from-shortcut-the-6r94hshave a tagged test.The test lint found, in the run's tests on the last check:
Recorded, not decided
test/global-setup.ts:1B7: no relative import: this file asserts on things it constructed itself, which is the measured 'asserted on my own mock' failureBraid run
let-a-link-be-deleted-from-shortcut-the-6r94hs(44 steps)cff298572cOpened by Braid.
Let a link be deleted from Shortcut.to Added a Delete button to each row of the Links page with an in-page…cff298572c23428d028b