Repository navigation
Share reusable test fixtures - #48
Merged
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
Problem
Several tests repeated the same complete public-user object and secure session configuration. If the shared shape or default configuration changed, every copy would need to be found and updated independently. That creates unnecessary maintenance and makes it easier for test setup to drift.
How it works
The web and API now each have a typed
createPublicUser()factory under their ownsrc/test/fixtures/directory. Tests can use the standard valid user or override only the field relevant to a scenario:The API also has one
testSessionConfigurationfixture used by the four tests that require the same cookie, duration, and secret settings.Why factories use overrides
Partial<PublicUser>overrides preserve a valid default object while making scenario differences visible at the call site. Tests do not need to repeat irrelevant fields just to change one property.Why API and web fixtures remain separate
The API and web factories share the authoritative
PublicUsertype from@goforlift/contracts, so TypeScript enforces the same browser-safe shape.Their actual test scenarios belong to different application boundaries and may evolve independently. Moving this small factory into a shared package would introduce cross-package test coupling and export configuration without enough reuse to justify it. The contract is shared; scenario defaults remain local.
What remains local
One-off values and data that explain the behavior of an individual test remain beside that test. This includes Google OIDC payloads, CSRF tokens, and route-specific helpers. Extracting those would hide information rather than improve maintainability.
Project convention
AGENTS.mdnow instructs future contributors and AI agents to:Verification