github-issue-tower-defence-management 2.15.0 → 2.17.0

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +1 -0
  3. package/bin/adapter/entry-points/cli/fleetConfig.js +30 -4
  4. package/bin/adapter/entry-points/cli/fleetConfig.js.map +1 -1
  5. package/bin/adapter/entry-points/cli/index.js +5 -1
  6. package/bin/adapter/entry-points/cli/index.js.map +1 -1
  7. package/bin/adapter/entry-points/console/ui-dist/assets/{index-BESCb69G.js → index-DKxao68k.js} +11 -11
  8. package/bin/adapter/entry-points/console/ui-dist/assets/{index-COxThJrG.css → index-DshIymWu.css} +1 -1
  9. package/bin/adapter/entry-points/console/ui-dist/index.html +2 -2
  10. package/bin/adapter/entry-points/console/webServer.js +4 -1
  11. package/bin/adapter/entry-points/console/webServer.js.map +1 -1
  12. package/package.json +1 -1
  13. package/src/adapter/entry-points/cli/fleetConfig.test.ts +63 -0
  14. package/src/adapter/entry-points/cli/fleetConfig.ts +38 -5
  15. package/src/adapter/entry-points/cli/index.ts +13 -1
  16. package/src/adapter/entry-points/console/ui/e2e/consoleScenario.spec.ts +51 -0
  17. package/src/adapter/entry-points/console/ui/e2e/consoleTestHarness.ts +4 -1
  18. package/src/adapter/entry-points/console/ui/src/features/console/components/layout/ConsoleTabList.stories.tsx +26 -0
  19. package/src/adapter/entry-points/console/ui/src/features/console/components/layout/ConsoleTabList.test.tsx +79 -0
  20. package/src/adapter/entry-points/console/ui/src/features/console/components/layout/ConsoleTabList.tsx +54 -41
  21. package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleProjectList.test.ts +24 -1
  22. package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleProjectList.ts +7 -3
  23. package/src/adapter/entry-points/console/ui/src/features/console/lib/consoleApi.ts +17 -8
  24. package/src/adapter/entry-points/console/ui/src/features/console/pages/ConsolePage.tsx +6 -1
  25. package/src/adapter/entry-points/console/ui/src/index.css +1 -1
  26. package/src/adapter/entry-points/console/ui-dist/assets/{index-BESCb69G.js → index-DKxao68k.js} +11 -11
  27. package/src/adapter/entry-points/console/ui-dist/assets/{index-COxThJrG.css → index-DshIymWu.css} +1 -1
  28. package/src/adapter/entry-points/console/ui-dist/index.html +2 -2
  29. package/src/adapter/entry-points/console/webServer.test.ts +34 -1
  30. package/src/adapter/entry-points/console/webServer.ts +6 -1
  31. package/types/adapter/entry-points/cli/fleetConfig.d.ts +3 -1
  32. package/types/adapter/entry-points/cli/fleetConfig.d.ts.map +1 -1
  33. package/types/adapter/entry-points/cli/index.d.ts.map +1 -1
  34. package/types/adapter/entry-points/console/webServer.d.ts +1 -0
  35. package/types/adapter/entry-points/console/webServer.d.ts.map +1 -1
@@ -78,6 +78,22 @@ describe('ConsoleTabList', () => {
78
78
  expect(container.querySelector('.console-tab-count-heading')).toBeNull();
79
79
  });
80
80
 
81
+ it('renders the project switcher button before the first tab in the DOM', () => {
82
+ const { container } = render(
83
+ <ConsoleTabList {...baseProps} activeTab="prs" counts={counts} />,
84
+ );
85
+ const nav = container.querySelector('nav.console-tabbar');
86
+ const children = Array.from(nav?.children ?? []);
87
+ const pjnameIndex = children.findIndex((el) =>
88
+ el.classList.contains('console-tab-pjname'),
89
+ );
90
+ const firstTabIndex = children.findIndex((el) =>
91
+ el.classList.contains('console-tab'),
92
+ );
93
+ expect(pjnameIndex).toBeGreaterThanOrEqual(0);
94
+ expect(firstTabIndex).toBeGreaterThan(pjnameIndex);
95
+ });
96
+
81
97
  it('renders the Workflow Blocker tab immediately left of Awaiting Quality Check', () => {
82
98
  const { getByText } = render(
83
99
  <ConsoleTabList {...baseProps} activeTab="prs" counts={counts} />,
@@ -250,4 +266,67 @@ describe('ConsoleTabList', () => {
250
266
  );
251
267
  expect(baseElement.querySelector('.console-airplane-mode')).toBeNull();
252
268
  });
269
+
270
+ it('positions the dropdown left-anchored to the button when opened', () => {
271
+ const { getByRole, baseElement } = render(
272
+ <ConsoleTabList {...baseProps} activeTab="prs" counts={counts} />,
273
+ );
274
+ const btn = getByRole('button', { name: /acme/i });
275
+ jest.spyOn(btn, 'getBoundingClientRect').mockReturnValue({
276
+ left: 42,
277
+ right: 120,
278
+ bottom: 50,
279
+ top: 20,
280
+ width: 78,
281
+ height: 30,
282
+ x: 42,
283
+ y: 20,
284
+ toJSON: () => ({}),
285
+ } as DOMRect);
286
+ fireEvent.click(btn);
287
+ const dropdown = baseElement.querySelector(
288
+ '.console-tab-pjname-dropdown',
289
+ ) as HTMLElement;
290
+ expect(dropdown.style.left).toBe('42px');
291
+ expect(dropdown.style.right).toBe('');
292
+ });
293
+
294
+ it('renders a workflow improvement link that opens in a new tab when workflowImprovementIssueUrl is set', () => {
295
+ const url = 'https://github.com/owner/repo/issues/new?assignees=someone';
296
+ const { getByRole } = render(
297
+ <ConsoleTabList
298
+ {...baseProps}
299
+ activeTab="prs"
300
+ counts={counts}
301
+ workflowImprovementIssueUrl={url}
302
+ />,
303
+ );
304
+ const link = getByRole('link', { name: /workflow improvement/i });
305
+ expect(link).toHaveAttribute('href', url);
306
+ expect(link).toHaveAttribute('target', '_blank');
307
+ expect(link).toHaveAttribute('rel', 'noreferrer');
308
+ });
309
+
310
+ it('does not render the workflow improvement link when workflowImprovementIssueUrl is null', () => {
311
+ const { container } = render(
312
+ <ConsoleTabList
313
+ {...baseProps}
314
+ activeTab="prs"
315
+ counts={counts}
316
+ workflowImprovementIssueUrl={null}
317
+ />,
318
+ );
319
+ expect(
320
+ container.querySelector('.console-tab-workflow-improvement-link'),
321
+ ).toBeNull();
322
+ });
323
+
324
+ it('does not render the workflow improvement link when workflowImprovementIssueUrl is not provided', () => {
325
+ const { container } = render(
326
+ <ConsoleTabList {...baseProps} activeTab="prs" counts={counts} />,
327
+ );
328
+ expect(
329
+ container.querySelector('.console-tab-workflow-improvement-link'),
330
+ ).toBeNull();
331
+ });
253
332
  });
@@ -25,6 +25,7 @@ export type ConsoleTabBarProps = {
25
25
  airplaneModeFailures: string[];
26
26
  onAirplaneModeStartSync: () => void;
27
27
  onAirplaneModeTurnOff: () => void;
28
+ workflowImprovementIssueUrl?: string | null;
28
29
  };
29
30
 
30
31
  export const ConsoleTabList = ({
@@ -45,11 +46,12 @@ export const ConsoleTabList = ({
45
46
  airplaneModeFailures,
46
47
  onAirplaneModeStartSync,
47
48
  onAirplaneModeTurnOff,
49
+ workflowImprovementIssueUrl = null,
48
50
  }: ConsoleTabBarProps) => {
49
51
  const [isDropdownOpen, setIsDropdownOpen] = useState(false);
50
52
  const [dropdownPos, setDropdownPos] = useState<{
51
53
  top: number;
52
- right: number;
54
+ left: number;
53
55
  } | null>(null);
54
56
  const buttonRef = useRef<HTMLButtonElement>(null);
55
57
  const dropdownRef = useRef<HTMLDivElement>(null);
@@ -77,7 +79,7 @@ export const ConsoleTabList = ({
77
79
  const rect = buttonRef.current.getBoundingClientRect();
78
80
  setDropdownPos({
79
81
  top: rect.bottom + 4,
80
- right: window.innerWidth - rect.right,
82
+ left: rect.left,
81
83
  });
82
84
  }
83
85
  setIsDropdownOpen((prev) => !prev);
@@ -85,44 +87,6 @@ export const ConsoleTabList = ({
85
87
 
86
88
  return (
87
89
  <nav aria-label="Console tabs" className="console-tabbar">
88
- {CONSOLE_TABS.filter((tab) => {
89
- const count = counts[tab.name] ?? 0;
90
- return count > 0 || tab.name === activeTab;
91
- }).map((tab) => {
92
- const count = counts[tab.name] ?? 0;
93
- const isActive = tab.name === activeTab;
94
- return (
95
- <a
96
- key={tab.name}
97
- href={tabHref(tab.name)}
98
- className="console-tab"
99
- data-active={isActive ? 'true' : undefined}
100
- aria-current={isActive ? 'page' : undefined}
101
- onClick={(event) => {
102
- if (
103
- event.defaultPrevented ||
104
- event.button !== 0 ||
105
- event.metaKey ||
106
- event.ctrlKey ||
107
- event.shiftKey ||
108
- event.altKey
109
- ) {
110
- return;
111
- }
112
- event.preventDefault();
113
- onSelectTab(tab.name);
114
- }}
115
- >
116
- <span className="console-tab-label">{tab.label}</span>
117
- <span
118
- className="console-tab-badge"
119
- data-zero={count === 0 ? 'true' : undefined}
120
- >
121
- {count}
122
- </span>
123
- </a>
124
- );
125
- })}
126
90
  {pjcode !== null && (
127
91
  <div className="console-tab-pjname">
128
92
  <button
@@ -149,7 +113,7 @@ export const ConsoleTabList = ({
149
113
  style={{
150
114
  position: 'fixed',
151
115
  top: dropdownPos.top,
152
- right: dropdownPos.right,
116
+ left: dropdownPos.left,
153
117
  }}
154
118
  >
155
119
  {pjcodes.map((code) => (
@@ -172,6 +136,44 @@ export const ConsoleTabList = ({
172
136
  )}
173
137
  </div>
174
138
  )}
139
+ {CONSOLE_TABS.filter((tab) => {
140
+ const count = counts[tab.name] ?? 0;
141
+ return count > 0 || tab.name === activeTab;
142
+ }).map((tab) => {
143
+ const count = counts[tab.name] ?? 0;
144
+ const isActive = tab.name === activeTab;
145
+ return (
146
+ <a
147
+ key={tab.name}
148
+ href={tabHref(tab.name)}
149
+ className="console-tab"
150
+ data-active={isActive ? 'true' : undefined}
151
+ aria-current={isActive ? 'page' : undefined}
152
+ onClick={(event) => {
153
+ if (
154
+ event.defaultPrevented ||
155
+ event.button !== 0 ||
156
+ event.metaKey ||
157
+ event.ctrlKey ||
158
+ event.shiftKey ||
159
+ event.altKey
160
+ ) {
161
+ return;
162
+ }
163
+ event.preventDefault();
164
+ onSelectTab(tab.name);
165
+ }}
166
+ >
167
+ <span className="console-tab-label">{tab.label}</span>
168
+ <span
169
+ className="console-tab-badge"
170
+ data-zero={count === 0 ? 'true' : undefined}
171
+ >
172
+ {count}
173
+ </span>
174
+ </a>
175
+ );
176
+ })}
175
177
  {generatedAt !== null && airplaneModeStatus !== 'on' && (
176
178
  <span
177
179
  className="console-tab-geninfo"
@@ -183,6 +185,17 @@ export const ConsoleTabList = ({
183
185
  {settingsButton !== undefined && (
184
186
  <span className="console-tab-settings">{settingsButton}</span>
185
187
  )}
188
+ {workflowImprovementIssueUrl !== null && (
189
+ <a
190
+ href={workflowImprovementIssueUrl}
191
+ target="_blank"
192
+ rel="noreferrer"
193
+ className="console-tab-workflow-improvement-link"
194
+ aria-label="Open workflow improvement issue"
195
+ >
196
+ ⚡
197
+ </a>
198
+ )}
186
199
  {airplaneModeEnabled && (
187
200
  <ConsoleAirplaneModeButton
188
201
  status={airplaneModeStatus}
@@ -6,7 +6,7 @@ describe('useConsoleProjectList', () => {
6
6
  jest.restoreAllMocks();
7
7
  });
8
8
 
9
- it('starts in loading state with empty pjcodes and no error', () => {
9
+ it('starts in loading state with empty pjcodes, null workflowImprovementIssueUrl and no error', () => {
10
10
  global.fetch = jest.fn(
11
11
  () => new Promise(() => undefined),
12
12
  ) as unknown as typeof fetch;
@@ -14,6 +14,7 @@ describe('useConsoleProjectList', () => {
14
14
  const { result } = renderHook(() => useConsoleProjectList());
15
15
  expect(result.current.isLoading).toBe(true);
16
16
  expect(result.current.pjcodes).toEqual([]);
17
+ expect(result.current.workflowImprovementIssueUrl).toBeNull();
17
18
  expect(result.current.error).toBeNull();
18
19
  });
19
20
 
@@ -29,6 +30,28 @@ describe('useConsoleProjectList', () => {
29
30
  expect(result.current.isLoading).toBe(false);
30
31
  });
31
32
  expect(result.current.pjcodes).toEqual(['acme', 'beta']);
33
+ expect(result.current.workflowImprovementIssueUrl).toBeNull();
34
+ expect(result.current.error).toBeNull();
35
+ });
36
+
37
+ it('populates workflowImprovementIssueUrl when the server returns it', async () => {
38
+ global.fetch = jest.fn(async () => ({
39
+ ok: true,
40
+ status: 200,
41
+ json: async () => ({
42
+ pjcodes: ['acme'],
43
+ workflowImprovementIssueUrl: 'https://github.com/owner/repo/issues/new',
44
+ }),
45
+ })) as unknown as typeof fetch;
46
+
47
+ const { result } = renderHook(() => useConsoleProjectList());
48
+ await waitFor(() => {
49
+ expect(result.current.isLoading).toBe(false);
50
+ });
51
+ expect(result.current.pjcodes).toEqual(['acme']);
52
+ expect(result.current.workflowImprovementIssueUrl).toBe(
53
+ 'https://github.com/owner/repo/issues/new',
54
+ );
32
55
  expect(result.current.error).toBeNull();
33
56
  });
34
57
 
@@ -3,12 +3,15 @@ import { fetchProjectList } from '../lib/consoleApi';
3
3
 
4
4
  export type ConsoleProjectListState = {
5
5
  pjcodes: string[];
6
+ workflowImprovementIssueUrl: string | null;
6
7
  isLoading: boolean;
7
8
  error: Error | null;
8
9
  };
9
10
 
10
11
  export const useConsoleProjectList = (): ConsoleProjectListState => {
11
12
  const [pjcodes, setPjcodes] = useState<string[]>([]);
13
+ const [workflowImprovementIssueUrl, setWorkflowImprovementIssueUrl] =
14
+ useState<string | null>(null);
12
15
  const [isLoading, setIsLoading] = useState(true);
13
16
  const [error, setError] = useState<Error | null>(null);
14
17
 
@@ -18,9 +21,10 @@ export const useConsoleProjectList = (): ConsoleProjectListState => {
18
21
  setError(null);
19
22
 
20
23
  fetchProjectList()
21
- .then((list) => {
24
+ .then((result) => {
22
25
  if (!cancelled) {
23
- setPjcodes(list);
26
+ setPjcodes(result.pjcodes);
27
+ setWorkflowImprovementIssueUrl(result.workflowImprovementIssueUrl);
24
28
  setIsLoading(false);
25
29
  }
26
30
  })
@@ -36,5 +40,5 @@ export const useConsoleProjectList = (): ConsoleProjectListState => {
36
40
  };
37
41
  }, []);
38
42
 
39
- return { pjcodes, isLoading, error };
43
+ return { pjcodes, workflowImprovementIssueUrl, isLoading, error };
40
44
  };
@@ -482,7 +482,12 @@ export const postConsoleReorderStory = async (
482
482
  }
483
483
  };
484
484
 
485
- export const fetchProjectList = async (): Promise<string[]> => {
485
+ export type ProjectListResponse = {
486
+ pjcodes: string[];
487
+ workflowImprovementIssueUrl: string | null;
488
+ };
489
+
490
+ export const fetchProjectList = async (): Promise<ProjectListResponse> => {
486
491
  const response = await fetch('/api/projects');
487
492
  if (!response.ok) {
488
493
  throw new Error(`HTTP ${response.status}`);
@@ -493,13 +498,17 @@ export const fetchProjectList = async (): Promise<string[]> => {
493
498
  typeof payload !== 'object' ||
494
499
  Array.isArray(payload)
495
500
  ) {
496
- return [];
501
+ return { pjcodes: [], workflowImprovementIssueUrl: null };
497
502
  }
498
503
  const record = payload as Record<string, unknown>;
499
- if (!Array.isArray(record.pjcodes)) {
500
- return [];
501
- }
502
- return record.pjcodes.filter(
503
- (entry): entry is string => typeof entry === 'string',
504
- );
504
+ const pjcodes = Array.isArray(record.pjcodes)
505
+ ? record.pjcodes.filter(
506
+ (entry): entry is string => typeof entry === 'string',
507
+ )
508
+ : [];
509
+ const workflowImprovementIssueUrl =
510
+ typeof record.workflowImprovementIssueUrl === 'string'
511
+ ? record.workflowImprovementIssueUrl
512
+ : null;
513
+ return { pjcodes, workflowImprovementIssueUrl };
505
514
  };
@@ -101,7 +101,11 @@ export const ConsolePage = () => {
101
101
  toggleDraftTimerMode,
102
102
  changeDraftMinutes,
103
103
  } = useConsoleTimerSettings();
104
- const { pjcodes, isLoading: isLoadingPjcodes } = useConsoleProjectList();
104
+ const {
105
+ pjcodes,
106
+ workflowImprovementIssueUrl,
107
+ isLoading: isLoadingPjcodes,
108
+ } = useConsoleProjectList();
105
109
  const { isTimerExpired } = useConsoleProjectTimer(pjcode);
106
110
  const overlayState = useConsoleOverlay(pjcode ?? OVERLAY_NAMESPACE_FALLBACK);
107
111
 
@@ -664,6 +668,7 @@ export const ConsolePage = () => {
664
668
  airplaneModeFailures={airplaneMode.failures}
665
669
  onAirplaneModeStartSync={airplaneMode.startSync}
666
670
  onAirplaneModeTurnOff={airplaneMode.turnOff}
671
+ workflowImprovementIssueUrl={workflowImprovementIssueUrl}
667
672
  />
668
673
  {activeTab === 'stories' ? (
669
674
  <ConsoleStoryList
@@ -100,7 +100,6 @@ body {
100
100
  }
101
101
 
102
102
  .console-tab-pjname {
103
- margin-left: auto;
104
103
  align-self: center;
105
104
  padding: 0 8px;
106
105
  }
@@ -158,6 +157,7 @@ body {
158
157
  }
159
158
 
160
159
  .console-tab-geninfo {
160
+ margin-left: auto;
161
161
  align-self: center;
162
162
  padding: 0 4px;
163
163
  color: #8b949e;