github-issue-tower-defence-management 1.143.5 → 1.143.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/bin/adapter/entry-points/console/ui-dist/assets/index-DDQKZmBM.js +81 -0
- package/bin/adapter/entry-points/console/ui-dist/index.html +1 -1
- package/package.json +1 -1
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleTabData.test.ts +41 -2
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleTabData.ts +44 -28
- package/src/adapter/entry-points/console/ui-dist/assets/index-DDQKZmBM.js +81 -0
- package/src/adapter/entry-points/console/ui-dist/index.html +1 -1
- package/bin/adapter/entry-points/console/ui-dist/assets/index-fTEmrrJ-.js +0 -81
- package/src/adapter/entry-points/console/ui-dist/assets/index-fTEmrrJ-.js +0 -81
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>TDPM Console</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-DDQKZmBM.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-CKX2ny-z.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleTabData.test.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { renderHook, waitFor } from '@testing-library/react';
|
|
1
|
+
import { act, renderHook, waitFor } from '@testing-library/react';
|
|
2
2
|
import { CONSOLE_TABS } from '../logic/types';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
CONSOLE_TAB_REFRESH_INTERVAL_MS,
|
|
5
|
+
useConsoleTabData,
|
|
6
|
+
} from './useConsoleTabData';
|
|
4
7
|
|
|
5
8
|
describe('useConsoleTabData', () => {
|
|
6
9
|
beforeEach(() => {
|
|
@@ -38,6 +41,42 @@ describe('useConsoleTabData', () => {
|
|
|
38
41
|
);
|
|
39
42
|
});
|
|
40
43
|
|
|
44
|
+
it('drops an item that disappeared from the snapshot after the refresh interval', async () => {
|
|
45
|
+
jest.useFakeTimers();
|
|
46
|
+
let closed = false;
|
|
47
|
+
const fetchMock = jest.fn(async (url: string) => ({
|
|
48
|
+
ok: true,
|
|
49
|
+
status: 200,
|
|
50
|
+
json: async () => ({
|
|
51
|
+
pjcode: 'umino',
|
|
52
|
+
generatedAt: '2026-06-19T00:00:00.000Z',
|
|
53
|
+
statusOptions: [],
|
|
54
|
+
storyColors: {},
|
|
55
|
+
items:
|
|
56
|
+
url.includes('/prs/') && !closed
|
|
57
|
+
? [{ number: 1, itemId: 'PVTI_1', projectItemId: 'PVTI_1' }]
|
|
58
|
+
: [],
|
|
59
|
+
}),
|
|
60
|
+
}));
|
|
61
|
+
global.fetch = fetchMock as unknown as typeof fetch;
|
|
62
|
+
|
|
63
|
+
const { result } = renderHook(() => useConsoleTabData('umino'));
|
|
64
|
+
await waitFor(() => {
|
|
65
|
+
expect(result.current.snapshots.prs?.items.length).toBe(1);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
closed = true;
|
|
69
|
+
await act(async () => {
|
|
70
|
+
jest.advanceTimersByTime(CONSOLE_TAB_REFRESH_INTERVAL_MS);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
await waitFor(() => {
|
|
74
|
+
expect(result.current.snapshots.prs?.items.length).toBe(0);
|
|
75
|
+
});
|
|
76
|
+
expect(fetchMock.mock.calls.length).toBe(CONSOLE_TABS.length * 2);
|
|
77
|
+
jest.useRealTimers();
|
|
78
|
+
});
|
|
79
|
+
|
|
41
80
|
it('surfaces an error when a tab fetch fails', async () => {
|
|
42
81
|
const fetchMock = jest.fn(async () => ({
|
|
43
82
|
ok: false,
|
|
@@ -66,6 +66,28 @@ const emptySnapshots = (): Record<
|
|
|
66
66
|
const buildListUrl = (pjcode: string, tab: ConsoleTabName): string =>
|
|
67
67
|
`/projects/${pjcode}/${tab}/list.json`;
|
|
68
68
|
|
|
69
|
+
export const CONSOLE_TAB_REFRESH_INTERVAL_MS = 60000;
|
|
70
|
+
|
|
71
|
+
const fetchSnapshots = async (
|
|
72
|
+
pjcode: string,
|
|
73
|
+
): Promise<Record<ConsoleTabName, ConsoleTabSnapshot | null>> => {
|
|
74
|
+
const entries = await Promise.all(
|
|
75
|
+
CONSOLE_TABS.map(async (tab) => {
|
|
76
|
+
const response = await fetch(buildListUrl(pjcode, tab.name));
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
throw new Error(`HTTP ${response.status}`);
|
|
79
|
+
}
|
|
80
|
+
const payload: unknown = await response.json();
|
|
81
|
+
return [tab.name, parseSnapshot(payload)] as const;
|
|
82
|
+
}),
|
|
83
|
+
);
|
|
84
|
+
const next = emptySnapshots();
|
|
85
|
+
for (const [name, snapshot] of entries) {
|
|
86
|
+
next[name] = snapshot;
|
|
87
|
+
}
|
|
88
|
+
return next;
|
|
89
|
+
};
|
|
90
|
+
|
|
69
91
|
export const useConsoleTabData = (
|
|
70
92
|
pjcode: string | null,
|
|
71
93
|
): ConsoleTabDataState => {
|
|
@@ -88,37 +110,31 @@ export const useConsoleTabData = (
|
|
|
88
110
|
};
|
|
89
111
|
}
|
|
90
112
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
.catch((cause: unknown) => {
|
|
113
|
-
if (cancelled) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
setError(cause instanceof Error ? cause.message : String(cause));
|
|
117
|
-
setIsLoading(false);
|
|
118
|
-
});
|
|
113
|
+
const load = (): void => {
|
|
114
|
+
fetchSnapshots(pjcode)
|
|
115
|
+
.then((next) => {
|
|
116
|
+
if (cancelled) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
setSnapshots(next);
|
|
120
|
+
setError(null);
|
|
121
|
+
setIsLoading(false);
|
|
122
|
+
})
|
|
123
|
+
.catch((cause: unknown) => {
|
|
124
|
+
if (cancelled) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
128
|
+
setIsLoading(false);
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
load();
|
|
133
|
+
const timer = setInterval(load, CONSOLE_TAB_REFRESH_INTERVAL_MS);
|
|
119
134
|
|
|
120
135
|
return () => {
|
|
121
136
|
cancelled = true;
|
|
137
|
+
clearInterval(timer);
|
|
122
138
|
};
|
|
123
139
|
}, [pjcode]);
|
|
124
140
|
|