Skip to content

Commit 571978f

Browse files
authored
Merge branch 'main' into fix/chromatic-timeout-settings
2 parents 47a6a31 + 8db869b commit 571978f

31 files changed

Lines changed: 932 additions & 239 deletions

.github/workflows/best-practices.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Best Practices
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
check:
59
runs-on: ubuntu-latest

.github/workflows/check-types.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Type Check
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
type-check:
59
runs-on: ubuntu-latest

.github/workflows/chromatic.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: 'Chromatic'
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
chromatic:
59
runs-on: ubuntu-latest

.github/workflows/nix-flake-check.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Nix Flake Check
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
nix-flake:
59
name: Nix Flake Check

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Tests
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
test:
59
runs-on: ubuntu-latest

.storybook/chrome-mock.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="chrome" />
22
import { version } from '../package.json';
3+
import deepEqual from 'fast-deep-equal/es6';
34

45
type ListenerFunction = (
56
changes: { [key: string]: chrome.storage.StorageChange },
@@ -18,13 +19,13 @@ function createMockStorageArea(areaName: chrome.storage.AreaName) {
1819
if (Array.isArray(keys)) {
1920
return keys.reduce(
2021
(acc, key) => {
21-
acc[key] = data[key];
22+
acc[key] = structuredClone(data[key]);
2223
return acc;
2324
},
2425
{} as Record<string, any>
2526
);
2627
}
27-
if (typeof keys === 'string') return { [keys]: data[keys] };
28+
if (typeof keys === 'string') return { [keys]: structuredClone(data[keys]) };
2829
return keys;
2930
},
3031
async getBytesInUse() {
@@ -40,11 +41,20 @@ function createMockStorageArea(areaName: chrome.storage.AreaName) {
4041
}
4142
},
4243
async set(items: { [key: string]: any }) {
43-
for (const key in items) {
44+
let hasUpdates = false;
45+
const updates: Record<string, chrome.storage.StorageChange> = {};
46+
for (const [key, newValue] of Object.entries(items)) {
4447
const oldValue = data[key];
45-
data[key] = JSON.parse(JSON.stringify(items[key]));
48+
if (!deepEqual(newValue, oldValue)) {
49+
hasUpdates = true;
50+
data[key] = structuredClone(newValue);
51+
updates[key] = { oldValue, newValue };
52+
}
53+
}
54+
55+
if (hasUpdates) {
4656
for (const listener of allListeners.values()) {
47-
listener({ [key]: { oldValue, newValue: data[key] } }, areaName);
57+
listener(structuredClone(updates), areaName);
4858
}
4959
}
5060
},

.storybook/fetch-mock.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Must load before any module that calls fetch() (e.g. GitHubStatsService) evaluates.
2+
// GitHubStatsService hits the real GitHub API on mount; in Chromatic's sandboxed
3+
// browser that request hangs/fails with no network access, timing out story capture.
4+
const realFetch = globalThis.fetch;
5+
6+
const MOCKED_HOSTS = ['github.cachedapi.com', 'api.github.com'];
7+
8+
function resolveUrl(input: RequestInfo | URL): string {
9+
if (typeof input === 'string') return input;
10+
if (input instanceof URL) return input.href;
11+
return input.url;
12+
}
13+
14+
globalThis.fetch = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
15+
const url = resolveUrl(input);
16+
17+
if (MOCKED_HOSTS.some(host => url.includes(host))) {
18+
return new Response(JSON.stringify([]), {
19+
status: 200,
20+
headers: { 'Content-Type': 'application/json' },
21+
});
22+
}
23+
24+
return realFetch(input, init);
25+
};

.storybook/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { StorybookConfig } from '@storybook/react-vite';
22

33
const config: StorybookConfig = {
44
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
5-
addons: ['@storybook/addon-designs', '@chromatic-com/storybook'],
5+
addons: ['@storybook/addon-docs', '@storybook/addon-designs', '@chromatic-com/storybook'],
66
framework: {
77
name: '@storybook/react-vite',
88
options: {

.storybook/preview.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// Must be first importsets up globalThis.chrome before any other module evaluates
1+
// Must be first importsset up globalThis.chrome/fetch before any other module evaluates
22
import './chrome-mock';
3+
import './fetch-mock';
34

45
import { UserScheduleStore } from '@shared/storage/UserScheduleStore';
56
import type { Preview } from '@storybook/react-vite';

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,9 @@ Special thanks to the developers and contributors behind these amazing tools and
218218
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Longhorn-Developers/UT-Registration-Plus&type=Date" />
219219
</picture>
220220
</a>
221+
222+
## Contributors
223+
224+
<a href="https://github.com/Longhorn-Developers/UT-Registration-Plus/graphs/contributors">
225+
<img src="https://contrib.rocks/image?repo=Longhorn-Developers/UT-Registration-Plus&columns=24&max=480" />
226+
</a>

0 commit comments

Comments
 (0)