Make E2E tests resilient to database state with ID normalization#229
Draft
lordscarlet wants to merge 6 commits into
Draft
Make E2E tests resilient to database state with ID normalization#229lordscarlet wants to merge 6 commits into
lordscarlet wants to merge 6 commits into
Conversation
Merge from YourDeveloperFriend
Merge changes from base
- Add normalizePlayerIds() function to compareGameData() that canonicalizes player IDs before snapshot comparison, making tests portable across different database states - Regenerate golden files (build_track_after.json, create_game_after.json) with normalized canonical player IDs (1, 2, 3, ...) instead of absolute DB IDs - Enhance buildTrack WebDriver method with scroll positioning and pointer events for better test stability and React integration - Add .gitattributes to enforce LF line endings across all tracked files - Add .vscode/settings.json to lock formatter/linter behavior (Prettier, ESLint on save) This ensures: - Teammates' tests won't fail due to different database user ID sequences - Golden files remain stable and deterministic across test runs - No database wipes or cleanup scripts needed - Consistent formatting and reliable track building interactions
08da9ea to
df07627
Compare
- Add missing undoPlayerId normalization in normalizePlayerIds() function to canonicalize player IDs for portable golden file comparisons - Improve type safety: replace 'any' types with proper GameApi types and MutablePlayerData interface - Add non-null assertions after idMap.get() calls for type safety - Update build_track_after.json golden file with correct normalized undoPlayerId value (3 -> 4) - Revert to standard JSON.stringify format to preserve golden file formatting consistency This fixes a critical bug where tests would fail if undoPlayerId was present in the game state, as it wasn't being normalized during the ID mapping process.
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
I was having trouble getting the e2e tests to succeed. I believe it is because I do not have the same data as whomever wrote the tests. This PR implements ID-agnostic E2E tests that are resilient to different database states, ensuring that other contributors' tests won't fail due to different user ID sequences.
Changes
normalizePlayerIds()function tocompareGameData()that canonicalizes player IDs before snapshot comparison.gitattributesto enforce LF line endings across all tracked files.vscode/settings.jsonto lock formatter/linter behavior.gitattributesKey Benefits
Testing