Skip to content

Commit badc83d

Browse files
author
DavidQ
committed
Fix accordion initialization and edge case behavior in Preview Generator V2 - PR_26126_048-preview-generator-v2-accordion_edge_cases
1 parent f9645da commit badc83d

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
PR_26126_048 Preview Generator V2 accordion edge cases
2+
3+
Scope
4+
- Updated Preview Generator V2 Playwright coverage only.
5+
- No runtime tool behavior was changed.
6+
- No samples, schemas, or start_of_day files were modified.
7+
8+
Edge-case audit
9+
- Browser measurement verified all accordion sections initialize open with matching aria-expanded and icon state.
10+
- Browser measurement verified all accordion sections respond on first click.
11+
- Browser measurement verified collapsed content height is zero and display is none.
12+
- Browser measurement verified reopened sections restore visible content.
13+
- Browser measurement verified Paths or IDs restores its flex/stretch behavior after reopening.
14+
- Browser measurement verified Status, Paths or IDs, and Last Generated Image behave correctly.
15+
16+
Playwright coverage added
17+
- The shared accordion test helper now verifies initial open state before clicking.
18+
- The helper verifies icon state before collapse, after collapse, and after reopen.
19+
- The helper verifies content hidden state and display state after collapse/reopen.
20+
- The helper verifies collapsed content height is zero.
21+
- The helper verifies collapsed section flex resolves to header-only sizing.
22+
- The helper verifies collapsed section height is smaller than its expanded height.
23+
24+
Validation
25+
- node --check tests/playwright/PreviewGeneratorV2Baseline.spec.mjs passed.
26+
- npm run test:workspace-v2 passed.
27+
- Result: 3 passed.
28+
- Confirmed no samples, schemas, or start_of_day changes.
29+
- Search found no Preview Generator V2 references to accordionV2.js, mountAccordionV2, or setAccordionV2Open.
30+
31+
Full samples smoke test
32+
- Skipped intentionally.
33+
- Reason: this PR is a targeted Preview Generator V2 accordion edge-case coverage pass and does not modify sample JSON, sample launch code, or shared sample runtime behavior.
34+
35+
Manual validation
36+
- Open tools/preview-generator-v2/index.html.
37+
- On first click, collapse each accordion and confirm it immediately closes.
38+
- Confirm no hidden content leaves a visible gap.
39+
- Reopen Status, Paths or IDs, and Last Generated Image and confirm each restores its expected layout.

tests/playwright/PreviewGeneratorV2Baseline.spec.mjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,45 @@ async function expectAccordionToggles(page, contentId) {
113113
const header = page.locator(`.accordion-v2__header[aria-controls="${contentId}"]`);
114114
const content = page.locator(`#${contentId}`);
115115
const icon = header.locator(".accordion-v2__icon");
116+
const readLayout = async () => await page.evaluate((id) => {
117+
const contentEl = document.getElementById(id);
118+
const section = contentEl.closest(".accordion-v2");
119+
return {
120+
sectionHeight: section.getBoundingClientRect().height,
121+
contentHeight: contentEl.getBoundingClientRect().height,
122+
sectionFlex: getComputedStyle(section).flex,
123+
contentDisplay: getComputedStyle(contentEl).display,
124+
contentHidden: contentEl.hidden
125+
};
126+
}, contentId);
127+
116128
await expect(header).toBeVisible();
117129
await expect(content).toBeVisible();
130+
await expect(header).toHaveAttribute("aria-expanded", "true");
131+
await expect(icon).toHaveAttribute("data-accordion-v2-icon-state", "open");
132+
const expandedLayout = await readLayout();
133+
expect(expandedLayout.contentHidden).toBe(false);
134+
expect(expandedLayout.contentDisplay).not.toBe("none");
118135

119136
await header.click();
120137
await expect(content).toBeHidden();
121138
await expect(header).toHaveAttribute("aria-expanded", "false");
122139
await expect(icon).toHaveAttribute("data-accordion-v2-icon-state", "closed");
140+
const collapsedLayout = await readLayout();
141+
expect(collapsedLayout.contentHidden).toBe(true);
142+
expect(collapsedLayout.contentDisplay).toBe("none");
143+
expect(collapsedLayout.contentHeight).toBe(0);
144+
expect(collapsedLayout.sectionHeight).toBeLessThan(expandedLayout.sectionHeight);
145+
expect(collapsedLayout.sectionFlex).toContain("0 0");
123146

124147
await header.click();
125148
await expect(content).toBeVisible();
126149
await expect(header).toHaveAttribute("aria-expanded", "true");
127150
await expect(icon).toHaveAttribute("data-accordion-v2-icon-state", "open");
151+
const reopenedLayout = await readLayout();
152+
expect(reopenedLayout.contentHidden).toBe(false);
153+
expect(reopenedLayout.contentDisplay).not.toBe("none");
154+
expect(reopenedLayout.contentHeight).toBeGreaterThan(0);
128155
}
129156

130157
async function expectPathsOrIdsAccordionToggles(page) {

0 commit comments

Comments
 (0)