Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/webapp/src/lib/stores/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ describe('settings store', () => {
validChainIds.set([1, 42161]);
expect(get(selectedChainIds)).toEqual([1, 42161]);
});

it('seeds selectedChainIds with all validChainIds when selectedChainIds is empty', () => {
// Fresh user: no prior chain selection.
// When the client discovers which chains are available, select them all so
// orders are visible without requiring a wallet connection first.
validChainIds.set([1, 137, 42161]);

expect(get(selectedChainIds)).toEqual([1, 137, 42161]);
});

it('does not re-seed selectedChainIds when validChainIds updates and selectedChainIds is already set', () => {
// Returning user: their explicit selection must not be clobbered when
// validChainIds is refreshed (e.g. after a re-init).
selectedChainIds.set([1, 42161]);

validChainIds.set([1, 137, 42161]);

// 137 must NOT be auto-added; user chose 1 and 42161.
expect(get(selectedChainIds)).toEqual([1, 42161]);
});
});

describe('selectedChainIds localStorage persistence', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/webapp/src/lib/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const validChainIds = writable<number[]>([]);
validChainIds.subscribe((valid) => {
if (valid.length > 0) {
selectedChainIds.update((current) => {
if (current.length === 0) return [...valid];
const filtered = current.filter((id) => valid.includes(id));
return filtered.length !== current.length ? filtered : current;
});
Expand Down
Loading