Repository navigation
fix(scan): triage sweep across open issues #437
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
12efb38
fix(scan): use "could have" instead of "could of" in optimize prompts
aidenybai 05b06f0
chore(scan): lower published bundle target from esnext to es2019
aidenybai 07015a9
fix(scan): correct production-environment detection + scaffold new op…
aidenybai cb8e2cb
fix(scan): make OffscreenCanvas worker CSP-safe + add opt-out
aidenybai 6535684
feat(scan): add safeArea option + allow text selection inside toolbar
aidenybai 7d5ad75
refactor(scan): dedupe isFinitePositive / isPlainObject across utils
aidenybai 8cd91fb
refactor(scan): rename isFinitePositive -> isFiniteNonNegative
aidenybai 22b8f46
fix(scan): apply correct safeArea edge to physical side in RTL
aidenybai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| interface FakeRenderer { | ||
| bundleType?: number; | ||
| rendererPackageName?: string; | ||
| } | ||
|
|
||
| interface FakeRDTHook { | ||
| renderers: Map<number, FakeRenderer>; | ||
| } | ||
|
|
||
| const sharedHook: FakeRDTHook = { renderers: new Map() }; | ||
|
|
||
| vi.mock('bippy', () => { | ||
| return { | ||
| detectReactBuildType: (renderer: FakeRenderer) => | ||
| renderer.bundleType === 0 ? 'production' : 'development', | ||
| getRDTHook: () => sharedHook, | ||
| getType: () => null, | ||
| isInstrumentationActive: () => false, | ||
| }; | ||
| }); | ||
|
|
||
| const importFreshGetIsProduction = async () => { | ||
| vi.resetModules(); | ||
| const mod = (await import('~core/index')) as typeof import('~core/index'); | ||
| return mod.getIsProduction; | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| sharedHook.renderers.clear(); | ||
| }); | ||
|
|
||
| describe('getIsProduction', () => { | ||
| it('returns null when no React renderer has registered yet', async () => { | ||
| const getIsProduction = await importFreshGetIsProduction(); | ||
| expect(getIsProduction()).toBeNull(); | ||
| }); | ||
|
|
||
| it('returns true when every registered renderer is production', async () => { | ||
| const getIsProduction = await importFreshGetIsProduction(); | ||
| sharedHook.renderers.set(1, { bundleType: 0 }); | ||
| expect(getIsProduction()).toBe(true); | ||
| }); | ||
|
|
||
| it('returns false when at least one renderer is non-production', async () => { | ||
| const getIsProduction = await importFreshGetIsProduction(); | ||
| sharedHook.renderers.set(1, { bundleType: 0 }); | ||
| sharedHook.renderers.set(2, { bundleType: 1 }); | ||
| expect(getIsProduction()).toBe(false); | ||
| }); | ||
|
|
||
| it('does not cache `true` — a later dev renderer flips the result', async () => { | ||
| // Regression guard for #402: the Next.js dev overlay registers a | ||
| // production React build first, then the user's dev React arrives a | ||
| // tick later. Caching `true` on the first call would lock us out. | ||
| const getIsProduction = await importFreshGetIsProduction(); | ||
| sharedHook.renderers.set(1, { bundleType: 0 }); | ||
| expect(getIsProduction()).toBe(true); | ||
|
|
||
| sharedHook.renderers.set(2, { bundleType: 1 }); | ||
| expect(getIsProduction()).toBe(false); | ||
| }); | ||
|
|
||
| it('caches `false` permanently once a dev renderer has been seen', async () => { | ||
| const getIsProduction = await importFreshGetIsProduction(); | ||
| sharedHook.renderers.set(1, { bundleType: 1 }); | ||
| expect(getIsProduction()).toBe(false); | ||
|
|
||
| sharedHook.renderers.clear(); | ||
| sharedHook.renderers.set(2, { bundleType: 0 }); | ||
| expect(getIsProduction()).toBe(false); | ||
| }); | ||
| }); |
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,2 @@ | ||
| export const isFinitePositive = (value: unknown): value is number => | ||
| typeof value === 'number' && Number.isFinite(value) && value >= 0; | ||
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,4 @@ | ||
| export const isPlainObject = ( | ||
| value: unknown, | ||
| ): value is Record<string, unknown> => | ||
| Boolean(value) && typeof value === 'object' && !Array.isArray(value); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.