Skip to content

Commit 0c52a6b

Browse files
authored
fix: work through the follow-up lists and mask Signal Forms secrets in signal graphs (#438)
1 parent b10969d commit 0c52a6b

79 files changed

Lines changed: 3913 additions & 643 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,16 @@ jobs:
9696
run: pnpm test:axe
9797

9898
# The e2e jobs below are slow, so they run only when the package, the panel, the SSR demo, the
99-
# tools docs (e2e:mcp reads them) or the scripts and fixtures they use change. A diff that cannot
100-
# be computed (a new branch, a force push) runs them.
99+
# tools docs (e2e:mcp reads them) or the scripts and fixtures they use change. The engines-floor
100+
# job runs only when what the packed package is built from changes. A diff that cannot be
101+
# computed (a new branch, a force push) runs them all.
101102
changes:
102103
name: Changed paths
103104
runs-on: ubuntu-latest
104105
timeout-minutes: 5
105106
outputs:
106107
e2e: ${{ steps.diff.outputs.e2e }}
108+
package: ${{ steps.diff.outputs.package }}
107109
steps:
108110
- uses: actions/checkout@v7
109111
with:
@@ -121,6 +123,61 @@ jobs:
121123
else
122124
echo "e2e=true" >> "$GITHUB_OUTPUT"
123125
fi
126+
# What the packed package is built from: the package, the panel it bundles and the toolchain.
127+
packed=(packages/devtools app package.json pnpm-lock.yaml pnpm-workspace.yaml .nvmrc
128+
.github/actions/setup .github/workflows/ci.yml)
129+
if git diff --quiet "$BASE" HEAD -- "${packed[@]}"; then
130+
echo "package=false" >> "$GITHUB_OUTPUT"
131+
else
132+
echo "package=true" >> "$GITHUB_OUTPUT"
133+
fi
134+
135+
# The source tests can't run on 22.12 (Node runs .ts files only from 22.18, and the build tools
136+
# need newer versions), so this job checks the packed package there instead.
137+
engines-floor:
138+
name: Packed package on Node.js 22.12
139+
needs: changes
140+
if: needs.changes.outputs.package == 'true'
141+
runs-on: ubuntu-latest
142+
timeout-minutes: 20
143+
steps:
144+
- uses: actions/checkout@v7
145+
with:
146+
persist-credentials: false
147+
148+
- uses: ./.github/actions/setup
149+
150+
# `prepack` builds the library and the panel first, on the `.nvmrc` version.
151+
- name: Pack the package
152+
run: pnpm --filter @pangular-inspector/devtools pack --pack-destination "$RUNNER_TEMP/pack"
153+
154+
# The engines floor: the lowest version `engines.node` in packages/devtools/package.json allows.
155+
# Keep the two in step.
156+
- uses: actions/setup-node@v7
157+
with:
158+
node-version: 22.12.0
159+
160+
- name: Install the tarball into an empty project
161+
working-directory: ${{ runner.temp }}
162+
run: |
163+
mkdir floor
164+
cd floor
165+
npm init -y > /dev/null
166+
npm install --no-audit --no-fund "$RUNNER_TEMP"/pack/*.tgz
167+
168+
# The Node.js entry points from `exports` in packages/devtools/package.json. The browser
169+
# entries (overlay, popup and the hooks) need a DOM. `http` is left out too: it imports
170+
# the optional Angular peers, which load in plain Node.js only with `@angular/compiler`
171+
# (JIT), and the app's build bundles it.
172+
- name: Run the CLI and load the entry points
173+
working-directory: ${{ runner.temp }}/floor
174+
run: |
175+
node --version
176+
npx pangular --version
177+
for entry in '' /devframe /config /cli /hub /ssr /vite; do
178+
node -e "import('@pangular-inspector/devtools$entry')"
179+
done
180+
node -e "require('@pangular-inspector/devtools/hub')"
124181
125182
e2e-security:
126183
name: Security e2e

‎app/src/__tests__/analog-inspector-pages.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,41 @@ describe('Analog route filter', () => {
110110
expect(box.value).toBe('');
111111
});
112112
});
113+
114+
describe('Analog open pages', () => {
115+
afterEach(() => {
116+
document.body.innerHTML = '';
117+
});
118+
119+
it('marks pages in named outlets with the outlet name', async () => {
120+
const route = (file: string) => ({
121+
id: file,
122+
fullPath: '/',
123+
file,
124+
kind: 'page' as const,
125+
params: [],
126+
children: [],
127+
});
128+
const fixture = await render(
129+
client({
130+
state: {
131+
pages: [
132+
{
133+
pageId: 'A',
134+
url: '/inbox(sidebar:chat)',
135+
chain: [
136+
{ path: '/inbox', file: '/src/app/pages/inbox.page.ts' },
137+
{ path: '/chat', file: '/src/app/pages/chat.page.ts', outlet: 'sidebar' },
138+
],
139+
},
140+
],
141+
},
142+
}),
143+
);
144+
const inspector = fixture.componentInstance;
145+
expect(inspector.openText(route('/src/app/pages/inbox.page.ts'))).toBe('open');
146+
expect(inspector.isOpen(route('/src/app/pages/chat.page.ts'))).toBe(true);
147+
expect(inspector.openText(route('/src/app/pages/chat.page.ts'))).toBe('open in sidebar');
148+
expect(inspector.isOpen(route('/src/app/pages/about.page.ts'))).toBe(false);
149+
});
150+
});

‎app/src/__tests__/app-shell.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,18 @@ describe('App tab bar', () => {
305305
expect(now.filter((b) => b.tabIndex === 0)).toEqual([now[2]]);
306306
fixture.destroy();
307307
});
308+
309+
it('puts the scrolling content in the Tab order with a name, and still focuses it from code', async () => {
310+
connection.answers = [true];
311+
const fixture = TestBed.createComponent(App);
312+
document.body.appendChild(host(fixture));
313+
await settle(fixture);
314+
315+
const main = host(fixture).querySelector<HTMLElement>('main')!;
316+
expect(main.tabIndex).toBe(0);
317+
expect(main.getAttribute('aria-label')).toBeTruthy();
318+
main.focus();
319+
expect(document.activeElement).toBe(main);
320+
fixture.destroy();
321+
});
308322
});

‎app/src/__tests__/cd-recording-status.test.ts‎

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,13 @@ describe('CdRecording status', () => {
7474
pageId: 'p1',
7575
on: true,
7676
});
77-
expect(live()).toBe('Recording started.');
77+
// The server took the request; the page has not said it records yet.
78+
expect(live()).not.toContain('started');
79+
expect(visible()).toBe('Starting…');
7880

7981
await show(true, 3);
8082
expect(live()).toBe('Recording started.');
83+
expect(visible()).toBe('Recording. 3 cycles so far.');
8184

8285
await click('Stop recording');
8386
// The page's last report still brings cycles: the total waits for it.
@@ -89,20 +92,51 @@ describe('CdRecording status', () => {
8992
expect(live()).toBe('Cleared the recorded cycles.');
9093
});
9194

92-
it('announces the count it has when the last report does not come', async () => {
93-
await show(true, 2);
95+
/** Clicks with fake timers, so the confirmation wait can run out. */
96+
async function clickAndWait(text: string, ms: number) {
9497
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });
9598
try {
96-
button('Stop recording').click();
99+
button(text).click();
97100
await vi.advanceTimersByTimeAsync(0);
98101
fixture.detectChanges();
99-
expect(live()).not.toContain('stopped');
100-
await vi.advanceTimersByTimeAsync(3000);
102+
const before = live();
103+
await vi.advanceTimersByTimeAsync(ms);
101104
fixture.detectChanges();
102-
expect(live()).toBe('Recording stopped. 2 cycles recorded.');
105+
return before;
103106
} finally {
104107
vi.useRealTimers();
105108
}
109+
}
110+
111+
it('says the page did not confirm when no report shows the recording on', async () => {
112+
const before = await clickAndWait('Record', 3000);
113+
expect(before).not.toContain('started');
114+
const failed =
115+
'The page did not confirm that the recording started. The tab may be in the background, closed or reloading.';
116+
expect(live()).toBe(failed);
117+
expect(visible()).toBe(failed);
118+
// The page still reports no recording, so the button still offers Record.
119+
expect(button('Record')).toBeTruthy();
120+
expect(button('Stop recording')).toBeUndefined();
121+
});
122+
123+
it('announces the start once a late report confirms it', async () => {
124+
await clickAndWait('Record', 3000);
125+
expect(live()).toContain('did not confirm');
126+
await show(true, 1);
127+
expect(live()).toBe('Recording started.');
128+
expect(visible()).toBe('Recording. 1 cycle so far.');
129+
expect(button('Stop recording')).toBeTruthy();
130+
});
131+
132+
it('says the page did not confirm when the report after Stop does not come', async () => {
133+
await show(true, 2);
134+
const before = await clickAndWait('Stop recording', 3000);
135+
expect(before).not.toContain('stopped');
136+
expect(live()).toBe(
137+
'The page did not confirm that the recording stopped. The tab may be in the background, closed or reloading.',
138+
);
139+
expect(button('Stop recording')).toBeTruthy();
106140
});
107141

108142
it('announces a repeated message again', async () => {

‎app/src/__tests__/component-tree-defer.test.ts‎

Lines changed: 114 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { TestBed } from '@angular/core/testing';
22
import type { DevframeRpcClient } from 'devframe/client';
3-
import { afterEach, describe, expect, it } from 'vitest';
3+
import { afterEach, describe, expect, it, vi } from 'vitest';
44
import { ComponentTree } from '../pages/component-tree';
55

6-
function client(pages: Record<string, unknown>): DevframeRpcClient {
6+
function client(
7+
pages: Record<string, unknown>,
8+
call: (...args: unknown[]) => Promise<unknown> = () => Promise.resolve([]),
9+
): DevframeRpcClient {
710
const rpc = {
8-
call: () => Promise.resolve([]),
11+
call,
912
callEvent: () => Promise.resolve(),
1013
sharedState: (name: string) =>
1114
Promise.resolve({
@@ -19,6 +22,7 @@ function client(pages: Record<string, unknown>): DevframeRpcClient {
1922
describe('defer blocks', () => {
2023
afterEach(() => {
2124
document.body.innerHTML = '';
25+
vi.useRealTimers();
2226
});
2327

2428
it('style the state badge apart from the empty-state box', async () => {
@@ -120,4 +124,111 @@ describe('defer blocks', () => {
120124
expect(await pill(page())).toBe('2');
121125
expect(await pill(page(true))).toBe('2+');
122126
});
127+
128+
it('shows the notes the agent tool prints, the @error block and the block times', async () => {
129+
const hour = 3_600_000;
130+
// Fix the panel clock so the ages stay exact; timers stay real for the waits.
131+
vi.useFakeTimers({ toFake: ['Date'] });
132+
vi.setSystemTime(1_700_000_000_000);
133+
// The page's clock runs an hour ahead of the panel's.
134+
const pageNow = Date.now() + hour;
135+
const block = (id: string, extra: Record<string, unknown>) => ({
136+
id,
137+
owner: { id: 'c1', name: 'App', tag: 'app-root' },
138+
state: 'complete',
139+
hydration: 'not-configured',
140+
triggers: ['on idle'],
141+
rootIds: [],
142+
since: pageNow,
143+
hasErrorBlock: false,
144+
...extra,
145+
});
146+
const page = {
147+
pageId: 'p1',
148+
roots: [{ id: 'c1', name: 'App', tag: 'app-root', children: [] }],
149+
count: 1,
150+
detail: null,
151+
reportedAt: 1000,
152+
clockOffset: -hour,
153+
deferBlocks: [
154+
block('d1', { state: 'error', hasErrorBlock: true }),
155+
block('d2', { state: 'placeholder', since: pageNow - 30_000 }),
156+
block('d3', { state: 'placeholder', since: pageNow - 2_000 }),
157+
block('d4', { hydration: 'dehydrated', triggers: ['hydrate on viewport'] }),
158+
block('d5', {
159+
state: 'loading',
160+
loading: { minimumTime: 1000, afterTime: 100 },
161+
placeholder: { minimumTime: 500 },
162+
}),
163+
],
164+
};
165+
const fixture = TestBed.createComponent(ComponentTree);
166+
fixture.componentRef.setInput('rpc', client({ p1: page }));
167+
for (let i = 0; i < 3; i++) {
168+
await new Promise((resolve) => setTimeout(resolve));
169+
await fixture.whenStable();
170+
}
171+
const rows = Array.from(
172+
(fixture.nativeElement as HTMLElement).querySelectorAll<HTMLElement>('.defer-row'),
173+
);
174+
const flags = (row: HTMLElement) =>
175+
Array.from(row.querySelectorAll('.flag')).map((el) => el.textContent?.trim());
176+
expect(flags(rows[0]!)).toEqual(['failed', '@error block']);
177+
expect(rows[0]!.querySelector('.note-failed')?.getAttribute('title')).toBe('failed to load');
178+
// 30 s on the page's clock, not an hour and 30 s.
179+
expect(flags(rows[1]!)).toEqual(['stuck 30s']);
180+
expect(rows[1]!.querySelector('.note-stuck')?.getAttribute('title')).toBe(
181+
'on its placeholder for 30s',
182+
);
183+
expect(flags(rows[2]!)).toEqual([]);
184+
expect(flags(rows[3]!)).toEqual(['dehydrated']);
185+
expect(rows[4]!.querySelector('.timings')?.textContent?.trim()).toBe(
186+
'placeholder min 500ms · loading after 100ms, min 1s',
187+
);
188+
expect(rows[0]!.querySelector('.timings')).toBeNull();
189+
fixture.destroy();
190+
});
191+
192+
it('highlights every root element of a block in one request', async () => {
193+
const call = vi.fn((..._args: unknown[]) => Promise.resolve([] as unknown));
194+
const block = (id: string, rootIds: string[]) => ({
195+
id,
196+
owner: { id: 'c1', name: 'App', tag: 'app-root' },
197+
state: 'complete',
198+
hydration: 'not-configured',
199+
triggers: [],
200+
rootIds,
201+
});
202+
const page = {
203+
pageId: 'p1',
204+
roots: [{ id: 'c1', name: 'App', tag: 'app-root', children: [] }],
205+
count: 1,
206+
detail: null,
207+
reportedAt: 1000,
208+
deferBlocks: [block('d1', ['e1', 'e2']), block('d2', ['e3']), block('d3', [])],
209+
};
210+
const fixture = TestBed.createComponent(ComponentTree);
211+
fixture.componentRef.setInput('rpc', client({ p1: page }, call));
212+
for (let i = 0; i < 3; i++) {
213+
await new Promise((resolve) => setTimeout(resolve));
214+
await fixture.whenStable();
215+
}
216+
const rows = (fixture.nativeElement as HTMLElement).querySelectorAll('.defer-row');
217+
const highlights = () =>
218+
call.mock.calls.filter((args) => args[0] === 'request-page-highlight').map((args) => args[1]);
219+
call.mockClear();
220+
for (const row of Array.from(rows)) {
221+
row.dispatchEvent(new Event('mouseenter'));
222+
row.dispatchEvent(new Event('mouseleave'));
223+
}
224+
expect(highlights()).toEqual([
225+
{ pageId: 'p1', ids: ['e1', 'e2'] },
226+
null,
227+
{ pageId: 'p1', id: 'e3' },
228+
null,
229+
{ pageId: 'p1', id: 'c1' },
230+
null,
231+
]);
232+
fixture.destroy();
233+
});
123234
});

0 commit comments

Comments
 (0)