Skip to content

refactor(tests): share spec and story fixtures, and fail stories with invalid markup - #1447

Open
askov wants to merge 9 commits into
solana-foundation:masterfrom
hoodieshq:refactor/shared-fixtures
Open

askov wants to merge 9 commits into
solana-foundation:masterfrom
hoodieshq:refactor/shared-fixtures

Conversation

@askov

@askov askov commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Moves fixtures and mocks that specs and stories rebuilt by hand into shared builders, and fails a story whose markup is not valid HTML.

Changes

  • Fails a Storybook story when parsing its rendered HTML again builds a different DOM.
  • Sets the nextjs parameters once in the Storybook preview, and removes the per-story nextjs and viewport parameters.
  • Adds rpc-errors, swr-idle, address-stub and stubFetch to app/__tests__ for specs to share.
  • Adds the makeInstruction, compileV0Message and makeAccount builders, and moves the parsed transaction builders to the transaction-data entity.
  • Builds the receipt fixtures from seeded keys in app/features/receipt/__fixtures__/transactions.ts, so every spec run uses the same addresses.
  • Moves fixtures that a slice's specs and stories both rebuilt into the slice's __fixtures__ module.
  • Adds the instructionCardDecorators, withOgImageFrame and withTransaction story decorators.
  • Imports base story args into responsive stories instead of copying them.
  • Exports groupVerificationSources from use-verification-sources.ts, so the badge stories use the hook's grouping.
  • Merges the second BaseRawAccountRows story file into the shared one, and removes unused fixtures and decorators.

Behavior Changes

  • Some responsive stories now render their base story's data instead of their own values.

Type of change

  • Other (please describe): Refactor of specs and stories

Screenshots

Testing

  • The token verification badge lists the same sources. Open the USDC mint page and hover the verification badge in the page header. Expect the same sources as on production.
  • A story with invalid markup fails. Add a <div> inside a <tbody> to any story, and run pnpm exec vitest --project storybook run <story file>. Expect the story to fail with The HTML parser builds a different DOM from the story markup. On master, the story passes.

Related Issues

Closes HOO-2279

Closes HOO-1659

Checklist

  • My code follows the project's style guidelines
  • All checks pass locally (pnpm test, pnpm lint, pnpm typecheck)
  • I have run build:info script to update build information

Additional Notes

  • The PR adds 2,856 lines and deletes 8,732. Outside specs, stories and fixtures, it changes use-verification-sources.ts, receipt-page.tsx, app/features/metadata/mocks.ts and eslint.config.mjs.
  • The PR has one commit per step, so it reads commit by commit.
  • bench/BUILD.md does not change.

@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown

@askov is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

React logs each DOM nesting warning once per page, so a check built on
the warning misses later stories. The preview parses each story's DOM
again and fails the story when the parser builds a different tree.
Moves the valid RawAccountRows stories into BaseRawAccountRows.
Stories repeated the `appDirectory` and `INITIAL_VIEWPORTS` parameters.
The preview sets them once, and Storybook deep-merges story parameters
over the preview's.
Specs built the same RPC errors, idle SWR module and fetch stubs inline.
Adds `rpc-errors`, `swr-idle` and `address-stub` to `app/__tests__`, and
`stubFetch` to `rpc-fetch`.
Specs and stories encoded instruction data, messages and accounts by hand.
Adds `makeInstruction`, `compileV0Message` and `makeAccount`, and moves
the parsed transaction builders to the transaction-data entity.
Fifteen mock files repeated the same parsed transaction shape with
random keys. `__fixtures__/transactions.ts` builds them from seeded
keys, so every run uses the same addresses.
Specs and stories in several slices built the same data inline.
Exports `groupVerificationSources` so the badge stories group sources
with the hook's own logic.
Stories wrapped instruction cards and OG images in the same providers by
hand. Adds `instructionCardDecorators`, `withOgImageFrame` and
`withTransaction`, and moves repeated args to the story meta.
Responsive stories copied the args of their base stories. They import
the base file and spread its args, so both render the same data.
@askov
askov force-pushed the refactor/shared-fixtures branch from b892a5f to 4b9459b Compare November 27, 2026 08:59
@askov
askov marked this pull request as ready for review November 27, 2026 10:25
@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5 · The PR appears safe to merge, with a non-blocking improvement to how markup errors are reported.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes mainly reach the shared specs and Storybook workflow across Explorer features.

The PR appears safe to merge, with a non-blocking improvement to how markup errors are reported.

Findings

  1. P2 Markup errors become slow ▶

Summary

Shares builders, fixtures, and decorators across specs and stories.

  • Storybook stories fail when parsing changes their rendered markup.
  • Specs and stories share fixture builders for common example data.
  • Storybook stories share common setup and provider decorators.
  • Token verification badge stories use the hook’s source-grouping rules.

Reviews (1) · Last reviewed commit: "test(storybook): reuse base story args i..." · Reviewed by Greptile

Comment on lines +139 to +142
if (reparsed.innerHTML === rendered) return;

let at = 0;
while (rendered[at] === reparsed.innerHTML[at]) at++;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Markup errors become slow

On a markup mismatch, the loop reads reparsed.innerHTML once for every matching character. Each read serializes the whole body again. An invalid element near the end of a large story can therefore make the check disproportionately slow. Save reparsed.innerHTML once and reuse that string for the comparison, loop, and error message.

This branch has not been deployed

No deployments
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.

1 participant