mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-01 19:25:10 +02:00
Revert "fix: snapshot -i auto-detects dropdown/popover interactive elements (#844)"
This reverts commit 542e7836d0.
This commit is contained in:
Vendored
-61
@@ -1,61 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test Page - Dropdown/Autocomplete</title>
|
||||
<style>
|
||||
.search-container { position: relative; width: 300px; }
|
||||
.search-input { width: 100%; padding: 8px; }
|
||||
.dropdown-portal {
|
||||
position: fixed;
|
||||
top: 60px;
|
||||
left: 20px;
|
||||
z-index: 9999;
|
||||
background: white;
|
||||
border: 1px solid #ccc;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||||
width: 300px;
|
||||
}
|
||||
.dropdown-item {
|
||||
padding: 8px 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.dropdown-item:hover { background: #f0f0f0; }
|
||||
.dropdown-item-no-cursor {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Dropdown Test</h1>
|
||||
|
||||
<div class="search-container">
|
||||
<input type="text" class="search-input" placeholder="Search for someone..." id="search" aria-label="Search">
|
||||
</div>
|
||||
|
||||
<!-- Simulates a React portal / floating-ui popover -->
|
||||
<div class="dropdown-portal" id="dropdown-portal" data-floating-ui-portal>
|
||||
<!-- Items with cursor:pointer but NO ARIA roles (common pattern) -->
|
||||
<div class="dropdown-item" onclick="selectItem('alice')">Alice Johnson - Acme Corp</div>
|
||||
<div class="dropdown-item" onclick="selectItem('bob')">Bob Smith - Beta Inc</div>
|
||||
<div class="dropdown-item" onclick="selectItem('carol')">Carol Davis - Gamma LLC</div>
|
||||
|
||||
<!-- Items WITH role="option" (well-built component) -->
|
||||
<div class="dropdown-item" role="option" onclick="selectItem('dave')">Dave Wilson - Delta Co</div>
|
||||
|
||||
<!-- Item with no cursor, no onclick, just text (should NOT be captured) -->
|
||||
<div class="dropdown-item-no-cursor" id="static-text">No results? Try a different search.</div>
|
||||
</div>
|
||||
|
||||
<!-- Standard interactive elements (should appear in ARIA tree normally) -->
|
||||
<button id="submit-btn">Submit</button>
|
||||
<a href="/test">Normal Link</a>
|
||||
|
||||
<script>
|
||||
function selectItem(name) {
|
||||
document.getElementById('search').value = name;
|
||||
document.getElementById('dropdown-portal').style.display = 'none';
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -386,77 +386,6 @@ describe('Cursor-interactive', () => {
|
||||
// And cursor-interactive section
|
||||
expect(result).toContain('cursor-interactive');
|
||||
});
|
||||
|
||||
test('snapshot -i alone also includes cursor-interactive elements', async () => {
|
||||
await handleWriteCommand('goto', [baseUrl + '/cursor-interactive.html'], bm);
|
||||
const result = await handleMetaCommand('snapshot', ['-i'], bm, shutdown);
|
||||
// -i now auto-enables -C
|
||||
expect(result).toContain('[button]');
|
||||
expect(result).toContain('[link]');
|
||||
expect(result).toContain('cursor-interactive');
|
||||
expect(result).toContain('@c');
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Dropdown/Popover Detection ─────────────────────────────────
|
||||
|
||||
describe('Dropdown/popover detection', () => {
|
||||
test('snapshot -i auto-enables cursor scan and finds dropdown items', async () => {
|
||||
await handleWriteCommand('goto', [baseUrl + '/dropdown.html'], bm);
|
||||
const result = await handleMetaCommand('snapshot', ['-i'], bm, shutdown);
|
||||
// Should find standard interactive elements
|
||||
expect(result).toContain('[button]');
|
||||
expect(result).toContain('[link]');
|
||||
expect(result).toContain('[textbox]');
|
||||
// Should also find cursor-interactive dropdown items
|
||||
expect(result).toContain('cursor-interactive');
|
||||
expect(result).toContain('@c');
|
||||
expect(result).toContain('Alice Johnson');
|
||||
expect(result).toContain('Bob Smith');
|
||||
});
|
||||
|
||||
test('dropdown items in floating container are tagged as popover-child', async () => {
|
||||
await handleWriteCommand('goto', [baseUrl + '/dropdown.html'], bm);
|
||||
const result = await handleMetaCommand('snapshot', ['-i'], bm, shutdown);
|
||||
expect(result).toContain('popover-child');
|
||||
});
|
||||
|
||||
test('dropdown items with role="option" in portal are captured', async () => {
|
||||
await handleWriteCommand('goto', [baseUrl + '/dropdown.html'], bm);
|
||||
const result = await handleMetaCommand('snapshot', ['-i'], bm, shutdown);
|
||||
// Dave Wilson has role="option" — should be captured even though it has a role
|
||||
expect(result).toContain('Dave Wilson');
|
||||
});
|
||||
|
||||
test('static text in dropdown without interactivity is NOT captured', async () => {
|
||||
await handleWriteCommand('goto', [baseUrl + '/dropdown.html'], bm);
|
||||
const result = await handleMetaCommand('snapshot', ['-i'], bm, shutdown);
|
||||
// "No results? Try a different search." has no cursor:pointer, no onclick, no tabindex
|
||||
expect(result).not.toContain('No results');
|
||||
});
|
||||
|
||||
test('@c ref from dropdown is clickable', async () => {
|
||||
await handleWriteCommand('goto', [baseUrl + '/dropdown.html'], bm);
|
||||
const snap = await handleMetaCommand('snapshot', ['-i'], bm, shutdown);
|
||||
// Find a @c ref for Alice
|
||||
const aliceLine = snap.split('\n').find(l => l.includes('@c') && l.includes('Alice'));
|
||||
if (aliceLine) {
|
||||
const refMatch = aliceLine.match(/@(c\d+)/);
|
||||
if (refMatch) {
|
||||
const result = await handleWriteCommand('click', [`@${refMatch[1]}`], bm);
|
||||
expect(result).toContain('Clicked');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('snapshot -C still works standalone without -i', async () => {
|
||||
await handleWriteCommand('goto', [baseUrl + '/dropdown.html'], bm);
|
||||
const result = await handleMetaCommand('snapshot', ['-C'], bm, shutdown);
|
||||
expect(result).toContain('cursor-interactive');
|
||||
expect(result).toContain('Alice Johnson');
|
||||
// Without -i, should include non-interactive ARIA elements too
|
||||
expect(result).toContain('[heading]');
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Snapshot Error Paths ───────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user