Repository navigation
Add optional feedback email and increase interface sound volume #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| import { chromium } from 'playwright'; | ||
| import assert from 'node:assert/strict'; | ||
| import { mkdir } from 'node:fs/promises'; | ||
|
|
||
| const browser = await chromium.launch(); | ||
| const sent = []; | ||
| const failures = []; | ||
| let rejectNext = false; | ||
| try { | ||
| const page = await browser.newPage({ viewport: { width: 651, height: 900 } }); | ||
| page.on('pageerror', error => failures.push(error.message)); | ||
| await page.exposeFunction('__feedbackSend', async input => { | ||
| sent.push(input); | ||
| if (rejectNext) { rejectNext = false; throw new Error('Temporary submission failure'); } | ||
| if (process.env.FEEDBACK_PORTAL_URL) { | ||
| const fields = { name: input.name, message: input.message, app_version: '2.2.18', os: 'windows' }; | ||
| if (input.email) fields.email = input.email; | ||
| if (input.includeDiagnostics) { | ||
| fields.diagnostics_summary = 'Local email integration check'; | ||
| fields.diagnostics = { name: 'cleanmeter-diagnostics.txt', mimeType: 'text/plain', buffer: Buffer.from('Local integration diagnostics\n') }; | ||
| } | ||
| const response = await page.request.post(`${process.env.FEEDBACK_PORTAL_URL}/api/feedback`, { | ||
| headers: { 'x-feedback-key': process.env.FEEDBACK_TEST_KEY ?? 'local-email-test-key' }, | ||
| multipart: fields, | ||
| }); | ||
| assert.equal(response.status(), 201, await response.text()); | ||
| } | ||
| }); | ||
| await page.route('**/src/lib/tauri.ts*', async route => { | ||
| const response = await route.fetch(); | ||
| const source = await response.text(); | ||
| const marker = 'export const submitFeedback = (input) => {'; | ||
| assert.ok(source.includes(marker), 'Intercept only the desktop transport boundary'); | ||
| await route.fulfill({ response, body: source.replace(marker, `${marker} return window.__feedbackSend(input);`) }); | ||
| }); | ||
| await page.goto(process.env.APP_URL ?? 'http://127.0.0.1:1433/'); | ||
| const open = async () => { | ||
| await page.getByRole('tab', { name: 'Help', exact: true }).click(); | ||
| await page.getByRole('button', { name: 'Give feedback', exact: true }).click(); | ||
| }; | ||
| await open(); | ||
| const email = page.getByRole('textbox', { name: 'Email (optional)', exact: true }); | ||
| const message = page.getByRole('textbox', { name: 'Message', exact: true }); | ||
| const submit = page.getByRole('button', { name: 'Submit', exact: true }); | ||
| await email.waitFor({ timeout: 5000 }); | ||
| await message.fill('Anonymous email test'); | ||
| await submit.click(); | ||
| await page.getByRole('dialog').waitFor({ state: 'hidden' }); | ||
| assert.equal(sent.at(-1).email, undefined, 'Blank email stays optional'); | ||
| await open(); | ||
| await email.fill('invalid'); | ||
| await email.blur(); | ||
| await message.fill('Contact email integration test'); | ||
| assert.equal(await email.getAttribute('aria-invalid'), 'true'); | ||
| assert.equal(await submit.isDisabled(), true); | ||
| const count = sent.length; | ||
| await email.fill('reply@example.com'); | ||
| rejectNext = true; | ||
| await submit.click(); | ||
| await page.getByRole('alert').filter({ hasText: 'Temporary submission failure' }).waitFor(); | ||
| assert.equal(await email.inputValue(), 'reply@example.com'); | ||
| assert.equal(await message.inputValue(), 'Contact email integration test'); | ||
| assert.equal(sent.length, count + 1); | ||
| await page.getByRole('checkbox', { name: 'Include system specs and app logs' }).check(); | ||
| await submit.click(); | ||
| await page.getByRole('dialog').waitFor({ state: 'hidden' }); | ||
| assert.equal(sent.at(-1).email, 'reply@example.com'); | ||
| assert.equal(sent.at(-1).includeDiagnostics, true); | ||
| await open(); | ||
| assert.equal(await email.inputValue(), ''); | ||
| assert.equal(await message.inputValue(), ''); | ||
| for (const colorScheme of ['light', 'dark']) { | ||
| await page.emulateMedia({ colorScheme }); | ||
| for (const height of [900, 500]) { | ||
| await page.setViewportSize({ width: 651, height }); | ||
| const fieldGeometry = await page.locator('#fb-name, #fb-email').evaluateAll(inputs => inputs.map(input => { | ||
| const style = getComputedStyle(input); | ||
| return { | ||
| id: input.id, | ||
| height: input.parentElement.getBoundingClientRect().height, | ||
| textSpace: input.clientHeight - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom), | ||
| lineHeight: parseFloat(style.lineHeight), | ||
| }; | ||
| })); | ||
| assert.ok(Math.abs(fieldGeometry[0].height - fieldGeometry[1].height) < 0.5, 'Name and email fields have equal heights'); | ||
| for (const field of fieldGeometry) assert.ok(field.textSpace >= field.lineHeight, `${field.id}: its text line fits inside the field without vertical clipping`); | ||
| await email.fill('invalid'); | ||
| await email.blur(); | ||
| await email.scrollIntoViewIfNeeded(); | ||
| assert.equal(await email.getAttribute('aria-invalid'), 'true'); | ||
| const errorContrast = await page.locator('#fb-email-error').evaluate(element => { | ||
| const luminance = color => { | ||
| const channels = color.match(/[\d.]+/g).slice(0, 3).map(Number).map(value => { | ||
| const s = value / 255; | ||
| return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4; | ||
| }); | ||
| return channels[0] * 0.2126 + channels[1] * 0.7152 + channels[2] * 0.0722; | ||
| }; | ||
| const foreground = luminance(getComputedStyle(element).color); | ||
| const background = luminance(getComputedStyle(element.closest('[role="dialog"]')).backgroundColor); | ||
| return (Math.max(foreground, background) + 0.05) / (Math.min(foreground, background) + 0.05); | ||
| }); | ||
| assert.ok(errorContrast >= 4.5, `Readable email error in ${colorScheme}: ${errorContrast.toFixed(2)}:1`); | ||
| assert.equal(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth), false); | ||
| await mkdir('test-results', { recursive: true }); | ||
| if (colorScheme === 'dark' && height === 900) await page.screenshot({ path: 'test-results/feedback-email-dark.png' }); | ||
| await submit.scrollIntoViewIfNeeded(); | ||
| const box = await submit.boundingBox(); | ||
| assert.ok(box.y >= 0 && box.y + box.height <= height, 'Submit remains reachable at short heights'); | ||
| } | ||
| } | ||
| assert.deepEqual(failures, []); | ||
| console.log('PASS optional email, validation, retry preservation, diagnostics, draft reset, both themes, short window, and submission transport'); | ||
| } finally { | ||
| await browser.close(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| :root{font:16px system-ui,sans-serif;color:#eef2f8;background:#10141c;color-scheme:dark}*{box-sizing:border-box}body{margin:0}main{max-width:1050px;margin:auto;padding:40px 24px}h1{font-size:34px;margin:0 0 10px}h2{font-size:22px;margin-top:32px}p{color:#aebbd0;line-height:1.6}label{display:flex;flex-direction:column;gap:9px}button,select{font:inherit;border:1px solid #46546b;border-radius:10px;background:#252f40;color:inherit;padding:12px;cursor:pointer}button:hover{background:#364863}button:focus-visible,select:focus-visible,input:focus-visible{outline:3px solid #83e7c1;outline-offset:3px}.controls{display:flex;flex-wrap:wrap;gap:20px;background:#1a2230;padding:20px;border-radius:14px;align-items:center}.controls label{min-width:130px;flex:1}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px}.cue{text-align:left;min-height:85px}.cue strong{display:block;margin-bottom:8px}.cue small{color:#b1c4dc}.inline{flex-direction:row;align-items:center!important}#status{position:sticky;bottom:12px;background:#193d32;border:1px solid #337660;padding:14px;border-radius:10px;margin-top:28px}a{color:#83e7c1}button:disabled{opacity:.45;cursor:default}input[type=range]{width:100%} | ||
| </style></head><body><main> | ||
| <h1>Sound lab</h1><p>Listen, compare, and choose your favourites. These controls only affect this playground.</p> | ||
| <div class="controls"><label>Volume <span id="volume-label">35%</span><input id="volume" type="range" min="0" max="100" value="35" aria-label="Preview volume"></label><button id="mute" aria-pressed="false">Mute</button><label class="inline"><input id="ready" type="checkbox" checked>Keep audio ready while testing</label></div> | ||
| <div class="controls"><label>Volume <span id="volume-label">70%</span><input id="volume" type="range" min="0" max="100" value="70" aria-label="Preview volume"></label><button id="mute" aria-pressed="false">Mute</button><label class="inline"><input id="ready" type="checkbox" checked>Keep audio ready while testing</label></div> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: sed -n '1,85p' tauri-app/sound-lab/index.html
rg -n 'sound-lab/index.html|<form|id="mute"' tauri-app/sound-lab tauri-app/src docs/sound-effects.mdRepository: SupaStellar/Cleanmeter Length of output: 3440 🏁 Script executed: set -o pipefail
printf '%s\n' '--- references ---'
rg -n -F --hidden --glob '!node_modules/**' --glob '!target/**' --glob '!dist/**' -e 'tauri-app/sound-lab' -e 'sound-lab' -e '<iframe' -e 'iframe' . || test "$?" -eq 1
printf '%s\n' '--- instruction/config candidates ---'
rg --files -g 'AGENTS.md' -g 'CONTRIBUTING*' -g '*STYLE*' -g '*GUIDELINE*' -g '.htmlhintrc*' -g 'package.json' -g 'README*' . | sort
printf '%s\n' '--- relevant instruction text ---'
for f in $(rg --files -g 'AGENTS.md' -g 'CONTRIBUTING*' -g '*STYLE*' -g '*GUIDELINE*' -g '.htmlhintrc*' | sort); do
printf '\n### %s\n' "$f"
sed -n '1,220p' "$f"
doneRepository: SupaStellar/Cleanmeter Length of output: 2478 Add The sound lab is currently used as a standalone page, so form submission is not a present runtime concern. However, Proposed fix-<button id="mute" aria-pressed="false">Mute</button>
+<button type="button" id="mute" aria-pressed="false">Mute</button>🧰 Tools🪛 HTMLHint (1.9.2)[warning] 6-6: The type attribute must be present on elements. (button-type-require) [warning] 6-6: No matching [ label ] tag found. (input-requires-label) [warning] 6-6: No matching [ label ] tag found. (input-requires-label) |
||
| <p><small>Audio readiness uses the same quiet output helper as Cleanmeter. It stops when this page loses focus or is muted. No sounds play automatically.</small></p> | ||
| <h2>Compare Cleanmeter cues</h2><p>These use the app's default sound theme. Volume follows the slider above.</p><div id="presets" class="grid"></div> | ||
| <h2>Explore the library</h2><div class="controls"><label>Library<select id="library"><option value="current">Cleanmeter - Cuelume 0.2.8</option><option value="legacy">Legacy - Cuelume 0.2.2</option></select></label><label>Theme<select id="theme"></select></label><label>Emphasis<select id="emphasis"><option>normal</option><option>subtle</option><option>strong</option></select></label><label>Direction<select id="direction"><option value="forward">Forward / on</option><option value="back">Back / off</option></select></label></div> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: SupaStellar/Cleanmeter
Length of output: 7158
🏁 Script executed:
Repository: SupaStellar/Cleanmeter
Length of output: 10802
🌐 Web query:
official Playwright documentation page.route handler throws exception request behavior💡 Result:
🏁 Script executed:
Repository: SupaStellar/Cleanmeter
Length of output: 10869
🌐 Web query:
site:playwright.dev/docs/api/class-page page.route handler throws exception abort request💡 Result:
🌐 Web query:
Playwright RouteHandler.handle _ignoreException thrown route handler implementation page.route exception abort request💡 Result:
Abort the intercepted request when the marker assertion fails.
The Vite transform removes the TypeScript return annotation, so the current marker matches the emitted function prefix. If formatting changes, the assertion runs before
route.fulfill. A rejected route handler does not call a terminal route method, so the request can remain pending and make the awaitedpage.gototime out instead of reporting the assertion directly.Suggested fix