Repository navigation
refactor(tests): share spec and story fixtures, and fail stories with invalid markup #1447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
askov
wants to merge
9
commits into
solana-foundation:master
Choose a base branch
from
hoodieshq:refactor/shared-fixtures
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4cee278
test(storybook): fail stories whose markup is not valid HTML
askov 86c9a5c
test: remove dead fixtures, redundant logger mocks and div decorators
askov da94a31
test(storybook): set nextjs and viewport parameters in the preview
askov 1590d52
test: share RPC error, SWR and fetch stubs between specs
askov 275e8bb
test: share instruction, transaction and account builders
askov e10bf65
test(receipt): build receipt fixtures in one seeded module
askov 4a001df
test: move repeated slice fixtures into __fixtures__ modules
askov f66ec59
test(storybook): share instruction card and OG image decorators
askov 4b9459b
test(storybook): reuse base story args in responsive stories
askov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
|
|
||
| export function makeInstruction({ | ||
| data = [], | ||
| keys = [], | ||
| programId, | ||
| writable = false, | ||
| }: { | ||
| data?: Uint8Array | number[]; | ||
| keys?: PublicKey[]; | ||
| programId: PublicKey | string; | ||
| writable?: boolean; | ||
| }): TransactionInstruction { | ||
| return new TransactionInstruction({ | ||
| data: Buffer.from(data), | ||
| keys: keys.map(pubkey => ({ isSigner: false, isWritable: writable, pubkey })), | ||
| programId: new PublicKey(programId), | ||
| }); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import type { PublicKey } from '@solana/web3.js'; | ||
|
|
||
| export function Address({ pubkey, fallbackText }: { pubkey: PublicKey; fallbackText?: string }) { | ||
| return <span data-testid="address">{fallbackText ?? pubkey.toBase58()}</span>; | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR, SolanaError } from '@solana/kit'; | ||
| import { expect } from 'vitest'; | ||
|
|
||
| export function httpError(statusCode: number) { | ||
| return new SolanaError(SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR, { | ||
| headers: new Headers(), | ||
| message: `HTTP ${statusCode}`, | ||
| statusCode, | ||
| }); | ||
| } | ||
|
|
||
| export function connectionFailure(code: string) { | ||
| const cause = Object.assign(new Error(`${code} on connect`), { code }); | ||
| return Object.assign(new TypeError('fetch failed'), { cause }); | ||
| } | ||
|
|
||
| export function reported(extras: Record<string, unknown>) { | ||
| return expect.objectContaining({ sentry: true, sentryExtras: expect.objectContaining(extras) }); | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { vi } from 'vitest'; | ||
|
|
||
| export const idleSwrModule = { | ||
| default: vi.fn(() => ({ | ||
| data: undefined, | ||
| error: undefined, | ||
| isLoading: false, | ||
| isValidating: false, | ||
| mutate: vi.fn(), | ||
| })), | ||
| }; |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a markup mismatch, the loop reads
reparsed.innerHTMLonce 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. Savereparsed.innerHTMLonce and reuse that string for the comparison, loop, and error message.