chore(repo): cover subdir and dependency watcher rebuilds#459
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fixtures/templates/props/preview-props.tsx)fixtures/components/text.tsx) and verifying template rebuild outputRefs #458
Greptile Summary
This PR extends the
watchersmoke test with two new steps: editing a template in a subdirectory (preview-props.tsx,batman→robin) and editing an imported dependency (text.tsx,component test→component test updated) to verify downstream template rebuilds. The test is refactored from a single hard-coded block into a data-driven loop over awatcherCasesarray, andwriteFileis replaced with anopen/writeFile/truncatesequence that avoids the extra bytes left over when shorter content overwrites a larger file.WatcherCaseentries and loops over all three cases insidetest.step, withwaitForPreviewBuildproviding a deterministic fence before each iframe assertion, removing the brittlereloadPreviewretry loop.replaceFileContentsopens the file inr+mode, writes the new content, then callstruncate(Buffer.byteLength(content, 'utf8'))to strip any trailing bytes from a shorter replacement — correctly handling both shrink and growth cases.finallyblock restores the original file and waits for the preview build to settle before the next step mutates a different file.Confidence Score: 4/5
Safe to merge once the open fixture-string issue in the dependency watcher case is resolved; the rest of the refactor is well-structured.
The dependency watcher case uses beforeContent 'component test' and afterContent 'component test updated', where the before value is a strict prefix of the after value. This relationship makes the pre-condition guard, the finally settle wait, and the restore logic unreliable for that step. The two new cases are the core contribution of the PR, so this affects the test's ability to reliably verify the behaviour it was written to exercise.
test/smoke-v2/tests/smoke-v2.test.ts — specifically the beforeContent/afterContent values in the third WatcherCase entry and the corresponding fixture file fixtures/components/text.tsx.
Important Files Changed
Sequence Diagram
sequenceDiagram participant T as Test (watcher step) participant FS as Filesystem participant W as File Watcher participant B as Preview Build (*.js) participant P as Playwright Page T->>P: page.goto(getTemplateUrl(templateSlug)) T->>P: assert iframe srcdoc contains beforeContent T->>FS: replaceFileContents(targetFile, contents.replace(before, after)) FS-->>W: file change event W->>B: rebuild previewBuildFile T->>B: waitForPreviewBuild(previewBuildFile, afterContent) [poll 60s] B-->>T: afterContent found T->>P: assert iframe srcdoc contains afterContent (HMR update) Note over T,P: optional snapshot if snapshotName set T->>FS: replaceFileContents(targetFile, contents) [finally: restore] FS-->>W: file change event W->>B: rebuild previewBuildFile T->>B: waitForPreviewBuild(previewBuildFile, beforeContent) [finally: settle]Reviews (4): Last reviewed commit: "test(smoke-v2): assert watcher updates w..." | Re-trigger Greptile