test(e2e): split multi-Expect It + drop bare sleep (bookshelf-tr2i) #531
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bd-bookshelf-tr2i"
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?
Summary
Itblock inmetadata_compare_cover_screenshot_test.go(which had 4Expectcalls) into 4 single-ExpectItblocks, each sharing the sameBeforeEach/JustBeforeEachper project convention (one Expect per It).time.Sleep(200 * time.Millisecond)"layout settle" — DOM injection viaMustEvalis synchronous andMustElementalready gates on presence; the wall-clock sleep was redundant and a flake risk.BeforeEach/JustBeforeEachstructure: setup (nav, DOM inject, screenshot) inBeforeEach; width reads inJustBeforeEach; assertions inIt.Test plan
make build— compiles cleanlyCloses bead bookshelf-tr2i on merge.
Security Review — bookshelf-tr2i (PR #531)
Scope:
e2e/browser/metadata_compare_cover_screenshot_test.goonly.Checks performed:
uploadMetadataCoverScreenshotToPRcall, unchanged.NoSandboxnot referenced; launcher config is untouched.Itblock intoBeforeEach."Cover Thumbnail Test Book") and integer IDs. No user-controlled or externally sourced data flows into shell commands or HTML template contexts.ExpectperIt,DeferCleanupover baredefer, removal of a wall-clocktime.Sleep). No assertion is removed — the four assertions from the originalItare preserved across four newItblocks. TheBeforeEach/JustBeforeEachsplit is correct per project conventions./tmp/...): Pre-existing pattern, unchanged in risk profile. Fixed-name suffix is process-indexed (GinkgoParallelProcess()), preventing parallel-test clobber.Findings: None.
REVIEW VERDICT: 0 blocker, 0 major, 0 minor
Code Review — bookshelf-tr2i
Reviewed:
git diff origin/main...origin/bd-bookshelf-tr2iPhase 0: DEMO verification
No DEMO block. This is a test-hygiene refactor (no new behavior); no runnable demo is applicable. Proceeding directly to code quality.
Phase 1: Spec compliance
All three bead requirements met:
Itsplit into 4 single-ExpectItswith sharedBeforeEach/JustBeforeEach✓time.Sleep(200ms)removed ✓BeforeEach/JustBeforeEachstructure added ✓Phase 2: Code quality
Structure:
BeforeEachis pure setup: page creation,DeferCleanup,seedBook,setAuthCookies, navigation, DOM injection viaMustEval,MustElementpresence wait, screenshot + upload. Correct.JustBeforeEachcaptures the twogetBoundingClientRect()width readings. Correct separation.Itblocks each have exactly 1Expect. Correct.Sleep removal safety:
MustEvalis a synchronous round-trip (JS runs to completion before the Go call returns).MustElement("[data-mf-modal]")confirms DOM presence before the width-readingMustEvalcalls inJustBeforeEach.getBoundingClientRect()is itself synchronous JS — the browser's layout engine computes it before returning. The 200ms sleep was not masking a real async gate; its removal does not introduce a race.DeferCleanupvsdefer:The old code used
defer page.MustClose()inside a singleIt. The new code correctly usesDeferCleanup(page.MustClose)insideBeforeEach— the Ginkgo-idiomatic way to ensure cleanup runs after eachItwhen setup lives inBeforeEach. Improvement.Imports:
"time"removed (no longer used)."github.com/go-rod/rod"added and used for the*rod.Pagetype in the outervarblock. Clean.bookIDscoping:bookIDis correctly kept as avar bookID int64local toBeforeEachsince it is only needed within that block to construct the navigation URL.Findings
No blockers, majors, or minors.
REVIEW VERDICT: 0 blocker, 0 major, 0 minor
a07e29d1ed2206945ac7