import { describe, expect, test } from 'vitest';
import { extractInteractiveElements } from '@/lib/generation/scene-generator';
describe('extractInteractiveElements', () => {
test('returns empty string on empty input', () => {
expect(extractInteractiveElements('')).toBe('');
});
test('collects real element ids so widget actions can select from them', () => {
const html = `
0
Reset
...
`;
const inventory = extractInteractiveElements(html);
expect(inventory).toContain('Elements with id:');
expect(inventory).toContain('#score-val');
expect(inventory).toContain('#reset-btn');
expect(inventory).toContain('aria-label="Reset the game"');
expect(inventory).toContain('#active-zone');
expect(inventory).toContain('role=region');
expect(inventory).toContain('#angle-slider');
expect(inventory).toContain('type=range');
expect(inventory).toContain('name=angle');
expect(inventory).toContain('Notable classes:');
expect(inventory).toContain('.pairing-rules');
expect(inventory).toContain('.dropzone');
});
test('captures procedural-skill data-step-id attributes', () => {
const html = `
Complete
`;
const inventory = extractInteractiveElements(html);
expect(inventory).toContain('#step-1-row');
expect(inventory).toContain('data-step-id="step-1"');
expect(inventory).toContain('#step-1-control');
expect(inventory).toContain('#step-2-row');
expect(inventory).toContain('data-step-id="step-2"');
});
test('ignores contents of
`;
const inventory = extractInteractiveElements(html);
expect(inventory).toContain('#real-id');
expect(inventory).toContain('.real-class');
expect(inventory).not.toContain('#should-not-appear');
expect(inventory).not.toContain('.fake-class');
expect(inventory).not.toContain('not-a-real-id');
// The