Skip to content

Commit 4282834

Browse files
committed
test(app-shell): read the stage from the header tag and the owner from the meta line
The default record page draws no path bar and no strip, so the 29935 pins read the stage from the header's stage tag, and the 28909 pins find the owner in the meta line at both widths. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgTcbvQNTSr6ij3TMW7
1 parent 9de0873 commit 4282834

2 files changed

Lines changed: 33 additions & 35 deletions

File tree

‎ui/packages/app-shell/src/views/RecordDetailView.phoneOwnerLine-28909.test.tsx‎

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
* harness), with `owner_id` declared 5th in `highlightFields`, behind four
1313
* non-text highlights (so the phone subtitle takes none of them):
1414
*
15-
* - at 390 px the phone header draws four highlights after its subtitle, so
16-
* the owner is not in the strip and the meta line names it;
17-
* - at 1440 px the strip draws all five, the owner among them, and the meta
18-
* line leaves it out (objectstack#28868, the owner once).
15+
* - until objectstack#35891 the phone header drew four highlights (the
16+
* owner past them, so the meta line named it) and the desktop strip all
17+
* five (the strip named the owner, the meta line did not);
18+
* - the default page draws no strip now, so at 390 px and at 1440 px the
19+
* meta line names the owner.
1920
*/
2021

2122
import * as React from 'react';
@@ -138,17 +139,15 @@ function mountPage() {
138139
);
139140
}
140141

141-
/** The strip and the meta line, once both are drawn. */
142-
async function stripAndMetaLine(): Promise<{ strip: HTMLElement; metaLine: HTMLElement }> {
142+
/** The meta line, once the record has loaded. */
143+
async function metaLineLoaded(): Promise<HTMLElement> {
143144
return waitFor(
144145
() => {
145-
const strip = document.querySelector('[data-highlights-face]') as HTMLElement | null;
146146
const metaLine = document.querySelector('[data-testid="record-meta-footer"]') as HTMLElement | null;
147-
expect(strip).toBeTruthy();
148147
expect(metaLine).toBeTruthy();
149-
// The record has loaded: the strip shows its values.
150-
expect(strip!.textContent).toContain('mira@atlas.test');
151-
return { strip: strip!, metaLine: metaLine! };
148+
// The record has loaded: its values are on the page.
149+
expect(document.body.textContent).toContain('mira@atlas.test');
150+
return metaLine!;
152151
},
153152
{ timeout: 5000 },
154153
);
@@ -180,24 +179,22 @@ afterEach(() => {
180179
});
181180

182181
describe('the owner at every width, once (objectstack#28909)', () => {
183-
it('on a phone: owner_id declared 5th is past the header\'s four, so the meta line names the owner', async () => {
182+
// Until objectstack#35891 the default page drew a strip of the declared
183+
// highlights: four on a phone (the owner past them, so the meta line named
184+
// it) and all five on a desktop (the strip named the owner, the meta line
185+
// did not). The default page draws no strip now, at any width, so the meta
186+
// line names the owner at both.
187+
it.each([
188+
['a phone', 390],
189+
['a desktop', 1440],
190+
])('on %s: no strip, and the meta line names the owner', async (_face, width) => {
191+
setWidth(width);
184192
mountPage();
185-
const { strip, metaLine } = await stripAndMetaLine();
186-
// The phone header: four highlights, the owner not among them.
187-
expect(strip.children).toHaveLength(4);
188-
expect(strip.textContent).not.toContain('Ada Admin');
193+
const metaLine = await metaLineLoaded();
194+
expect(document.querySelector('[data-highlights-face]')).toBeNull();
189195
const owner = ownerEntry(metaLine);
190196
expect(owner).toBeTruthy();
191197
expect(owner!.textContent).toContain('Ada Admin');
192-
});
193-
194-
it('on a desktop: the strip names the owner and the meta line does not', async () => {
195-
setWidth(1440);
196-
mountPage();
197-
const { strip, metaLine } = await stripAndMetaLine();
198-
expect(strip.children).toHaveLength(5);
199-
expect(strip.textContent).toContain('Ada Admin');
200-
expect(ownerEntry(metaLine)).toBeNull();
201198
// The rest of the meta line is still drawn.
202199
expect(metaLine.querySelector('[data-record-meta-id]')!.textContent).toBe('r-1');
203200
});

‎ui/packages/app-shell/src/views/RecordDetailView.updateActionRefresh-29935.test.tsx‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,13 @@ function headerCtaLabels(): string[] {
222222
}
223223

224224
/**
225-
* The header path bar's current stage, as each rendering of it (wide and
226-
* narrow) names it to assistive tech.
225+
* The stage the header's stage tag reads, as each rendering of it names it.
226+
* Until objectstack#35891 this read the path bar's current step; the default
227+
* page draws no path bar now, and the stage is the tag beside the name.
227228
*/
228229
function currentStages(): string[] {
229-
return Array.from(document.querySelectorAll('[role="listitem"][aria-current="step"]'))
230-
.map((el) => el.getAttribute('aria-label') ?? '');
230+
return Array.from(document.querySelectorAll('[data-record-stage-tag]'))
231+
.map((el) => (el.textContent ?? '').trim());
231232
}
232233

233234
function actionPosts(): string[] {
@@ -283,10 +284,10 @@ afterEach(() => {
283284
});
284285

285286
describe('objectstack#29935 — a declared update action reflects its write on the record page', () => {
286-
it('full page: after the 200 the page re-reads, the path bar reads Resolved and the Resolve button is gone', async () => {
287+
it('full page: after the 200 the page re-reads, the stage tag reads Resolved and the Resolve button is gone', async () => {
287288
const dataSource = await mount([resolveTicket], 'page');
288289
expect(headerCtaLabels()).toContain('Resolve');
289-
await waitFor(() => expect(currentStages()).toContain('Open, current stage'));
290+
await waitFor(() => expect(currentStages()).toContain('Open'));
290291
const readsBefore = dataSource.findOne.mock.calls.length;
291292

292293
await click('Resolve');
@@ -295,22 +296,22 @@ describe('objectstack#29935 — a declared update action reflects its write on t
295296
await waitFor(() => expect(toast.success).toHaveBeenCalledWith('Ticket resolved.', expect.anything()));
296297
await waitFor(() => expect(dataSource.findOne.mock.calls.length).toBeGreaterThan(readsBefore));
297298
await waitFor(() => expect(headerCtaLabels()).not.toContain('Resolve'));
298-
await waitFor(() => expect(currentStages()).toContain('Resolved, current stage'));
299-
expect(currentStages()).not.toContain('Open, current stage');
299+
await waitFor(() => expect(currentStages()).toContain('Resolved'));
300+
expect(currentStages()).not.toContain('Open');
300301
});
301302

302303
it('drawer: the same click re-reads the record and the Open list it came from drops it', async () => {
303304
const dataSource = await mount([resolveTicket], 'drawer');
304305
const openList = () => Array.from(screen.getByTestId('open-list').querySelectorAll('li')).map((li) => li.textContent);
305306
await waitFor(() => expect(openList()).toEqual([RECORD_ID, OTHER_ID]));
306-
await waitFor(() => expect(currentStages()).toContain('Open, current stage'));
307+
await waitFor(() => expect(currentStages()).toContain('Open'));
307308
const readsBefore = dataSource.findOne.mock.calls.length;
308309

309310
await click('Resolve');
310311

311312
await waitFor(() => expect(dataSource.findOne.mock.calls.length).toBeGreaterThan(readsBefore));
312313
await waitFor(() => expect(headerCtaLabels()).not.toContain('Resolve'));
313-
await waitFor(() => expect(currentStages()).toContain('Resolved, current stage'));
314+
await waitFor(() => expect(currentStages()).toContain('Resolved'));
314315
await waitFor(() => expect(openList()).toEqual([OTHER_ID]));
315316
});
316317

0 commit comments

Comments
 (0)