Skip to content

Commit 4d13fe6

Browse files
committed
Validate measured mode labels by tolerance
1 parent d427108 commit 4d13fe6

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎.github/workflows/mode-solo-e2e.yml‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,26 @@ jobs:
8989
const count = await page.$$eval(selector, nodes => nodes.length);
9090
if (count !== 3) throw new Error(`expected 3 interactive modes, got ${count}`);
9191
const labels = await page.$$eval(selector, nodes => nodes.map(node => node.getAttribute('aria-label')));
92-
if (!labels[0]?.includes('440.0') || !labels[1]?.includes('997.0') || !labels[2]?.includes('2413.')) throw new Error(`unexpected mode labels ${JSON.stringify(labels)}`);
92+
const frequencies = labels.map(label => {
93+
const match = label?.match(/([0-9]+(?:\.[0-9]+)?) hertz$/);
94+
if (!match) throw new Error(`unparseable mode label ${label}`);
95+
return Number(match[1]);
96+
});
97+
const expected = [440, 997, 2413];
98+
expected.forEach((frequency, index) => {
99+
if (Math.abs(frequencies[index] - frequency) > Math.max(3, frequency * 0.005)) {
100+
throw new Error(`mode ${index} outside frequency tolerance: ${frequencies[index]}`);
101+
}
102+
});
93103
94104
await page.$eval(`${selector}[data-mode-index="0"]`, node => node.dispatchEvent(new MouseEvent('click', { bubbles: true })));
95-
await page.waitForFunction(() => document.body.innerText.includes('SOLO 440.0 HZ'));
105+
await page.waitForFunction(label => document.body.innerText.includes(`SOLO ${label} HZ`), {}, frequencies[0].toFixed(1));
96106
const firstPressed = await page.$eval(`${selector}[data-mode-index="0"]`, node => node.getAttribute('aria-pressed'));
97107
if (firstPressed !== 'true') throw new Error('first mode did not become selected');
98108
99109
await page.focus(`${selector}[data-mode-index="1"]`);
100110
await page.keyboard.press('Space');
101-
await page.waitForFunction(() => document.body.innerText.includes('SOLO 997.'));
111+
await page.waitForFunction(label => document.body.innerText.includes(`SOLO ${label} HZ`), {}, frequencies[1].toFixed(1));
102112
const pressed = await page.$$eval(selector, nodes => nodes.map(node => node.getAttribute('aria-pressed')));
103113
if (pressed[0] !== 'false' || pressed[1] !== 'true') throw new Error(`selection did not transfer ${JSON.stringify(pressed)}`);
104114
@@ -111,7 +121,7 @@ jobs:
111121
const report = {
112122
targetRevision: process.env.TARGET_REVISION,
113123
interactiveModeCount: count,
114-
labels,
124+
frequenciesHz: frequencies,
115125
clickSolo: true,
116126
keyboardSolo: true,
117127
reconstructionClearsSolo: true,

0 commit comments

Comments
 (0)