Skip to content

Fix SF /_atomic mock for ?waitForIndex=true; rename test fixture username#4707

Merged
habdelra merged 2 commits intomainfrom
fix-sf-atomic-mock-waitforindex
May 7, 2026
Merged

Fix SF /_atomic mock for ?waitForIndex=true; rename test fixture username#4707
habdelra merged 2 commits intomainfrom
fix-sf-atomic-mock-waitforindex

Conversation

@habdelra
Copy link
Copy Markdown
Contributor

@habdelra habdelra commented May 7, 2026

Summary

  • Fix 204 No Content failure on shard 1/3 of SF Node tests. The ?waitForIndex=true opt-in landed in 9444b82 makes the factory entrypoint append a query string to the /_atomic POST URL when syncing the seed batch. The integration mock checked request.url === '/testuser/personal/_atomic' (exact match), so the new URL fell through to the generic POST handler and got 204 No Content. The sync client expects 201 → reported Atomic upload failed: 204 No Content, factory:go exited 1, and pnpm test:node failed at factory-entrypoint integration > factory:go --debug prints a structured JSON summary. Switched the handler to startsWith('/testuser/personal/_atomic'), consistent with the other handlers already in this mock.
  • Rename test fixture username from hassan to testuser across 5 SF test files (34 occurrences). The fixture had a real teammate's name baked into Matrix user IDs, account-data paths, and realm URLs; testuser is neutral.
  • This was failing every shard 1 run on main since the merge — not flake. Failure example: https://github.com/cardstack/boxel/actions/runs/25493597169/job/74808011882

Test plan

  • pnpm test:node in packages/software-factory passes locally (440 pass, 0 fail) before and after the rename
  • Software Factory CI shard 1/3 turns green

habdelra and others added 2 commits May 7, 2026 08:33
The recent ?waitForIndex=true opt-in adds a query string to the
/_atomic POST URL when the factory entrypoint syncs the seed batch.
The integration mock's exact-string match against
'/hassan/personal/_atomic' no longer matches, so the request fell
through to the generic POST handler, which returned 204 No Content.
The sync client expects 201, surfaced "Atomic upload failed: 204
No Content", and the factory:go subprocess exited 1 — failing every
shard 1 run of pnpm test:node since 9444b82.

Switch to a startsWith check so the handler accepts both the
plain URL and the ?waitForIndex=true form, matching the pattern
used by the other /hassan/personal/* handlers in this mock.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The integration mock and a few sibling tests hardcoded 'hassan' as
the Matrix user / realm owner across user IDs, account-data paths,
and realm URLs. Swap to the neutral 'testuser' so the fixture
doesn't read like it belongs to a real teammate.

No behavior change — the username is just the test fixture.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@habdelra habdelra changed the title Match /_atomic with query string in factory-entrypoint mock Fix SF /_atomic mock for ?waitForIndex=true; rename test fixture username May 7, 2026
@habdelra habdelra requested review from a team and Copilot May 7, 2026 12:55
Copy link
Copy Markdown
Contributor

@jurgenwerk jurgenwerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Software Factory Node integration test mock to correctly handle /_atomic requests that include query strings (e.g. ?waitForIndex=true), and renames the SF test fixture username to a neutral testuser to avoid embedding a real teammate’s name in test data.

Changes:

  • Update the integration test realm mock to match POST /_atomic via startsWith(...) so query strings don’t fall through to the generic handler.
  • Rename fixture username usages from hassantestuser across Software Factory test files.
  • Update expected owner usernames / realm URLs in unit and integration tests to reflect the renamed fixture.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/software-factory/tests/factory-target-realm.test.ts Updates test profile + expected realm URLs/owner username to testuser.
packages/software-factory/tests/factory-entrypoint.test.ts Updates fixture realm/owner username assertions to testuser.
packages/software-factory/tests/factory-entrypoint.integration.test.ts Fixes /_atomic mock matching to allow query strings; renames all mocked URLs/user IDs to testuser.
packages/software-factory/tests/factory-agent-schema-boundary.test.ts Updates agent context fixture targetRealm to testuser.
packages/software-factory/tests/factory-agent-claude-code.test.ts Updates agent context fixture targetRealm to testuser.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@habdelra habdelra merged commit bdd265f into main May 7, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants