mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 11:03:47 +08:00
update test to check for improprerly spaced buttons and fix them
This commit is contained in:
@@ -12,21 +12,28 @@ const assert = require('node:assert/strict')
|
||||
const { createApp } = await import('./vendor/vue/vue.esm-browser.js')
|
||||
const { GxNotice } = await import('./js/notice.js')
|
||||
const { BluetoothNotice } = await import('./js/bluetooth-notice.js')
|
||||
const { LocalAccess } = await import('./js/local-access.js')
|
||||
const LocalAccessError = { ...LocalAccess, mounted() {}, beforeUnmount() {},
|
||||
setup: () => ({ state: { error: 'Galaxy could not connect. Reconnecting automatically…' } }) }
|
||||
window.StarPilotApp = { connectionOptions() {} }
|
||||
document.body.innerHTML = '<main class="gx-content"><div id="fixture" class="gx-settings"></div></main>'
|
||||
createApp({ components: { GxNotice, BluetoothNotice }, data: () => ({ clicks: 0 }),
|
||||
createApp({ components: { GxNotice, BluetoothNotice, LocalAccessError }, data: () => ({ clicks: 0 }),
|
||||
template: `<GxNotice tone="danger">This page could not finish loading.<template #actions><button class="gx-btn" @click="clicks++">Reload page</button></template></GxNotice>
|
||||
<output>{{ clicks }}</output>
|
||||
<GxNotice v-for="tone in ['info', 'success', 'warn', 'danger']" :tone="tone" :title="tone"><p>A message that wraps onto multiple lines on narrow screens, with enough detail to explain what happens next.</p><p>Additional guidance.</p><template #actions><button class="gx-btn gx-btn--tonal">Choose another file with a longer name</button><a class="gx-btn" href="#fixture">Open settings</a></template></GxNotice>
|
||||
<section class="gx-card gx-tuner__section"><div class="gx-actions"><button class="gx-btn">Download tune</button></div><GxNotice tone="success">Tune backup download started.</GxNotice></section>
|
||||
<GxNotice busy>Connecting to your comma…</GxNotice>
|
||||
<GxNotice>Unable to load https://example.com/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</GxNotice>
|
||||
<BluetoothNotice feature="Replay"/>`,
|
||||
<BluetoothNotice feature="Replay"/>
|
||||
<section class="gx-card gx-panel"><GxNotice tone="danger">Connection failed.</GxNotice><button class="gx-btn">Direct action</button></section>
|
||||
<section class="gx-card gx-panel"><GxNotice tone="warn">Check your connection.</GxNotice><div class="gx-actions"><button class="gx-btn">Grouped action</button></div></section>
|
||||
<section class="gx-card gx-panel gx-stack"><GxNotice>Stacked message.</GxNotice><button class="gx-btn">Stacked action</button></section>
|
||||
<LocalAccessError mode="local"/>`,
|
||||
}).mount('#fixture')
|
||||
})
|
||||
for (const theme of ['dark', 'light']) {
|
||||
await page.evaluate(theme => document.documentElement.dataset.theme = theme, theme)
|
||||
for (const width of [320, 390, 768, 1280, 3440]) {
|
||||
for (const width of [320, 390, 627, 768, 1280, 3440]) {
|
||||
await page.setViewportSize({ width, height: 1200 })
|
||||
const failures = await page.locator('.gx-alert').evaluateAll(banners => banners.flatMap(banner => {
|
||||
const box = banner.getBoundingClientRect()
|
||||
@@ -45,6 +52,14 @@ const assert = require('node:assert/strict')
|
||||
if (Math.abs(actionBox.left - text.left) > 1) issues.push('action alignment')
|
||||
if (banner.querySelector('.gx-alert__text button')) issues.push('button inside message')
|
||||
}
|
||||
// Check rendered siblings as well as slot actions: buttons may live in a
|
||||
// following component (for example ConnectionLogs inside LocalAccess).
|
||||
for (const [direction, sibling] of [['before', banner.previousElementSibling], ['after', banner.nextElementSibling]]) {
|
||||
if (!sibling || !sibling.getClientRects().length) continue
|
||||
const other = sibling.getBoundingClientRect()
|
||||
const gap = direction === 'after' ? other.top - box.bottom : box.top - other.bottom
|
||||
if (gap < 11) issues.push(`${direction} ${banner.textContent.trim()}: only ${gap}px between banner and sibling`)
|
||||
}
|
||||
return issues
|
||||
}))
|
||||
assert.deepEqual(failures, [], `${theme}/${width}`)
|
||||
|
||||
@@ -851,7 +851,7 @@ border-radius: var(--radius-full); color: var(--text-muted);
|
||||
.gx-view > *, .gx-driving > *, .gx-long-curves > *, .gx-vehicle > * { margin-block: 0; }
|
||||
.gx-view h2, .gx-monitor h2 { margin-top: 0; }
|
||||
.gx-note { color: var(--text-muted); font-size: var(--fs-sm); }
|
||||
.gx-alert { --notice-accent: var(--primary); align-items: center; backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border); border-left: 4px solid var(--notice-accent); border-radius: var(--radius-md); display: flex; gap: var(--sp-3); box-sizing: border-box; min-width: 0; width: 100%; margin: 0; padding: var(--sp-4); background: color-mix(in srgb, var(--notice-accent) 12%, transparent); }
|
||||
.gx-alert { --notice-accent: var(--primary); align-items: center; backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border); border-left: 4px solid var(--notice-accent); border-radius: var(--radius-md); display: flex; gap: var(--sp-3); box-sizing: border-box; min-width: 0; width: 100%; margin: 0 0 var(--sp-4); padding: var(--sp-4); background: color-mix(in srgb, var(--notice-accent) 12%, transparent); }
|
||||
* + .gx-alert { margin-top: var(--sp-4); }
|
||||
.gx-alert--warn { --notice-accent: var(--warning); }
|
||||
.gx-alert--danger { --notice-accent: var(--error); }
|
||||
|
||||
Reference in New Issue
Block a user