Simon Clematide
feat: release v1.0.0 with restrained interface and versioning
1c44eff
Raw History Blame Contribute Delete
9.08 kB
async (page) => {
await page.goto('http://127.0.0.1:7871');
const active = () => page.locator('[role="tabpanel"]:visible');
if (await page.getByRole('tab', {name:'About', exact:true}).getAttribute('aria-selected') !== 'true') throw Error('About must open first');
await page.getByRole('tab', {name:'Parse', exact:true}).click();
async function checkSentenceStyle() {
const sentence = active().getByRole('textbox', {name:'Sentence', exact:true});
const style = await sentence.evaluate(el => ({fontSize:getComputedStyle(el).fontSize, lineHeight:getComputedStyle(el).lineHeight, tag:el.tagName}));
if (style.fontSize !== '24px' || style.lineHeight !== '36px' || style.tag !== 'INPUT') throw Error('Sentence must retain prominent single-line styling: ' + JSON.stringify(style));
}
await checkSentenceStyle();
const featsCheckbox = active().locator('input[type="checkbox"]');
if (!await featsCheckbox.count()) throw Error('Expected morphological features checkbox');
async function analyze(count, expected, button) {
await active().getByRole('button', {name:button, exact:true}).click();
await page.waitForFunction(({count, expected}) => {
const panel = Array.from(document.querySelectorAll('[role="tabpanel"]')).find(el => el.getBoundingClientRect().height > 0);
const frames = Array.from(panel.querySelectorAll('iframe[id^="vis-"]'));
return frames.length === count && frames.every(f => f.contentWindow.visualizerDiagnostics?.stage === 'ready' && f.contentWindow.visualizerDiagnostics.zoom === 1.4 && f.contentDocument.getElementById('zoom-controls').hidden && f.contentDocument.querySelector('#vis svg')?.textContent.includes(expected));
}, {count, expected}, {timeout:60000});
}
// 1. Single Parse mode
await analyze(1, 'They', 'Parse');
const help = active().locator('iframe[id^="vis-"]').contentFrame().locator('.ud-help');
if (await help.getAttribute('open') === null) throw Error('Help should start expanded');
const helpLabels = await help.locator('a[href^="https://universaldependencies.org/"]').allTextContents();
if (helpLabels.sort().join(',') !== 'NOUN,PRON,VERB,nsubj,obj,root') throw Error('Help contains unused labels: ' + helpLabels);
const words = active().locator('iframe[id^="vis-"]').contentFrame().locator('.grew-words');
const queries = await words.locator('a').evaluateAll(links => links.map(link => {
const url = new URL(link.href);
return {word:link.textContent, corpus:url.searchParams.get('corpus'), request:url.searchParams.get('request')};
}));
if (queries.map(q=>q.word).join(',') !== 'books,buy,They' || queries.some(q=>q.corpus !== 'UD_English-EWT@2.18' || q.request !== 'pattern { X [form=' + JSON.stringify(q.word) + '] }')) throw Error('Incorrect word queries: ' + JSON.stringify(queries));
// 2. Compare mode
await page.getByRole('tab', {name:'Compare', exact:true}).click();
await checkSentenceStyle();
await analyze(2, 'They', 'Compare');
if (await active().locator('#vis-model-a').contentFrame().locator('.ud-help').count()) throw Error('Help should be limited to Parse');
const comparisonCorpus = await active().locator('#vis-model-b').contentFrame().locator('.grew-words a').first().getAttribute('href');
if (new URL(comparisonCorpus).searchParams.get('corpus') !== 'UD_English-GUM@2.18') throw Error('Comparison word links must use the second model corpus');
// Verify comparison status element precedes the first iframe
const statusPrecedesTree = await active().evaluate(panel => {
const statusEl = Array.from(panel.querySelectorAll('.diff-alert')).find(el => el.getBoundingClientRect().height > 0);
const firstFrame = panel.querySelector('iframe[id^="vis-"]');
if (!statusEl || !firstFrame) return false;
return (statusEl.compareDocumentPosition(firstFrame) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0;
});
if (!statusPrecedesTree) throw Error('Comparison status must precede the trees');
// Verify no literal markdown markers ** in status HTML
const statusText = await active().locator('.diff-alert').innerText();
if (statusText.includes('**')) throw Error('Literal markdown markers (**) found in status HTML');
// 3. Same-model comparison
const modelsCount = await active().getByRole('listbox', {name:'Second UDPipe parser', exact:true}).click();
await page.getByRole('option', {name:'UDPipe · english-ewt-ud-2.17-251125', exact:true}).click();
await active().getByRole('button', {name:'Compare', exact:true}).click();
await page.waitForFunction(() => {
const alert = document.querySelector('[role="tabpanel"]:not([style*="display: none"]) .diff-alert-same');
return alert && alert.textContent.includes('Same UDPipe Parser Selected');
});
// 4. Language change to German in Compare
await active().getByRole('listbox', {name:'Language', exact:true}).click();
await page.getByRole('option', {name:'German', exact:true}).click();
await page.waitForFunction(() => document.querySelector('input[aria-label="First UDPipe parser"]').value.includes('german-hdt-ud-2.17-251125'));
// Verify sentence stays as is when changing language
const currentSentence = await active().getByRole('textbox', {name:'Sentence', exact:true}).inputValue();
if (currentSentence !== 'They buy and sell books.') throw Error('Sentence should stay as is when language changes');
// Modifying the sentence clears the selected example and description
await active().getByRole('textbox', {name:'Sentence', exact:true}).pressSequentially(' Extra text');
await page.waitForTimeout(300);
const germanExValue = await active().locator('input[aria-label="German Examples"]').inputValue();
const englishExValue = await active().locator('input[aria-label="English Examples"]').inputValue();
if (germanExValue || englishExValue) throw Error('Modifying sentence should reset example dropdowns to empty');
await active().getByRole('textbox', {name:'Sentence', exact:true}).fill('Bücher überzeugen.');
// Analyze German comparison
await analyze(2, 'Bücher', 'Compare');
// 5. Test Parse tab retains independent state
await page.getByRole('tab', {name:'Parse', exact:true}).click();
if (await active().getByRole('textbox', {name:'Sentence', exact:true}).inputValue() !== 'They buy and sell books.') throw Error('Tabs should retain separate inputs');
// 6. Example selection applies immediately
if (!await active().getByRole('listbox', {name:'English Examples', exact:true}).isVisible()) {
await active().getByRole('button', {name:/^Try an example/}).click();
}
await active().getByRole('listbox', {name:'English Examples', exact:true}).click();
await page.getByRole('option', {name:'The dog that chased the cat barked loudly.', exact:true}).click();
await page.waitForFunction(() => Array.from(document.querySelectorAll('.sentence-input input, .sentence-input textarea')).some(el => el.value === 'The dog that chased the cat barked loudly.'));
if (await active().getByRole('button', {name:'Use example', exact:true}).count()) throw Error('Redundant example button');
await active().getByRole('listbox', {name:'German Examples', exact:true}).click();
await page.getByRole('option', {name:'Der Zug, der um acht Uhr ankommen sollte, hat Verspätung.', exact:true}).click();
await page.waitForFunction(() => document.querySelector('input[aria-label="UDPipe parser"]').value.includes('german-hdt-ud-2.17-251125'));
if (await active().getByRole('textbox', {name:'Sentence', exact:true}).inputValue() !== 'Der Zug, der um acht Uhr ankommen sollte, hat Verspätung.') throw Error('Cross-language example did not load sentence');
await active().getByText('Relative clause embedded in subject noun phrase', {exact:true}).waitFor();
await page.waitForFunction(() => document.querySelectorAll('[role="tabpanel"]:not([style*="display: none"]) iframe[id^="vis-"]').length === 1);
// 7. Empty input clears results and shows error
await active().getByRole('textbox', {name:'Sentence', exact:true}).fill('');
await active().getByRole('button', {name:'Parse', exact:true}).click();
await active().getByText('Please enter a sentence to parse.').waitFor();
// 8. Treebank Guide accordions check
await page.getByRole('tab', {name:'Treebank Guide', exact:true}).click();
const confAccordion = active().getByText('Training size, quality and conformance', {exact:true});
const catAccordion = active().getByText('Full treebank catalog', {exact:true});
if (await confAccordion.count() === 0 || await catAccordion.count() === 0) throw Error('Guide accordions missing');
await page.screenshot({path:'output/playwright/simplified-ui.png', fullPage:true});
return {defaultSingle:true, comparison:true, statusPrecedes:true, german:true, immediateExample:true, emptyInput:true, guideAccordions:true};
}