chore: initial commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import test from 'node:test'
|
||||
|
||||
const styles = readFileSync(new URL('./index.css', import.meta.url), 'utf8')
|
||||
const compact = styles.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\s+/g, ' ')
|
||||
const mobileStyles = compact.slice(compact.indexOf('@media (max-width: 720px)'))
|
||||
|
||||
test('style source contract: constrains the desktop sidebar and gives the menu its own scroll region', () => {
|
||||
assert.match(compact, /\.client-shell\s*\{[^}]*overflow-x:\s*hidden/)
|
||||
assert.match(compact, /\.client-sidebar\s*\{[^}]*overflow:\s*hidden/)
|
||||
assert.match(compact, /\.client-sidebar nav\s*\{[^}]*flex:\s*1[^}]*min-height:\s*0[^}]*overflow-y:\s*auto/)
|
||||
assert.match(compact, /\.client-nav-menu,[^\{]*\.client-nav-submenu\s*\{[^}]*min-width:\s*0/)
|
||||
assert.match(compact, /\.client-nav-menu\s*\{[^}]*flex:\s*1[^}]*background:\s*transparent/)
|
||||
assert.match(compact, /\.client-sidebar-header,\s*\.client-sidebar-scrim\s*\{[^}]*display:\s*none/)
|
||||
})
|
||||
|
||||
test('style source contract: presents native grouped rows with restrained active states and truncation', () => {
|
||||
assert.doesNotMatch(compact, /\.client-sidebar \.el-menu|\.el-menu-item|\.el-sub-menu/)
|
||||
assert.match(compact, /\.client-nav-menu,[^\{]*\.client-nav-submenu\s*\{[^}]*margin:\s*0[^}]*padding:\s*0[^}]*list-style:\s*none/)
|
||||
assert.match(compact, /\.client-sidebar-group-trigger,[^\{]*\.client-sidebar-link\s*\{[^}]*height:\s*44px[^}]*border-radius:\s*8px/)
|
||||
assert.match(compact, /\.client-sidebar-link\[aria-current="page"\]\s*\{[^}]*background:\s*#e9f4f2[^}]*color:\s*var\(--primary\)/)
|
||||
assert.match(compact, /\.client-nav-node\.is-active-parent > \.client-sidebar-group-trigger\s*\{[^}]*background:\s*#f2f7f6[^}]*color:\s*var\(--primary\)/)
|
||||
assert.match(compact, /\.client-nav-submenu\s*\{[^}]*padding-left:\s*3[6-8]px/)
|
||||
assert.match(compact, /\.client-sidebar-group-trigger\s*\{[^}]*border:\s*0[^}]*background:\s*transparent/)
|
||||
assert.match(compact, /\.client-sidebar-link\s*\{[^}]*text-decoration:\s*none/)
|
||||
assert.match(compact, /\.client-sidebar (?:\.client-sidebar-group-trigger|\.client-sidebar-link) svg[^\{]*\{[^}]*flex:\s*0 0 18px/)
|
||||
assert.match(compact, /\.client-sidebar-group-trigger span,[^\{]*\.client-sidebar-link span\s*\{[^}]*min-width:\s*0[^}]*overflow:\s*hidden[^}]*text-overflow:\s*ellipsis[^}]*white-space:\s*nowrap/)
|
||||
})
|
||||
|
||||
test('style source contract: makes navigation and drawer controls touch sized with visible keyboard focus', () => {
|
||||
assert.match(compact, /\.client-sidebar-group-trigger,[^\{]*\.client-sidebar-link\s*\{[^}]*height:\s*44px/)
|
||||
assert.match(compact, /\.client-sidebar-group-trigger:focus-visible,[^\{]*\.client-sidebar-link:focus-visible,[^\{]*\.client-page-heading > button:focus-visible,[^\{]*\.client-sidebar-header button:focus-visible\s*\{[^}]*outline:\s*2px solid var\(--primary\)[^}]*outline-offset:\s*2px/)
|
||||
})
|
||||
|
||||
test('style source contract: turns the sidebar into a layered drawer at 720px and below', () => {
|
||||
assert.doesNotMatch(mobileStyles, /\.client-sidebar\s*\{[^}]*display:\s*none/)
|
||||
assert.match(mobileStyles, /\.client-sidebar\s*\{[^}]*display:\s*flex[^}]*width:\s*min\(286px,\s*86vw\)[^}]*visibility:\s*hidden[^}]*pointer-events:\s*none[^}]*transform:\s*translateX\(-100%\)[^}]*transition:\s*transform \.2s ease, visibility 0s linear \.2s[^}]*z-index:\s*19/)
|
||||
assert.match(mobileStyles, /\.mobile-menu-open \.client-sidebar\s*\{[^}]*visibility:\s*visible[^}]*pointer-events:\s*auto[^}]*transform:\s*translateX\(0\)[^}]*transition-delay:\s*0s/)
|
||||
assert.match(mobileStyles, /\.client-sidebar-scrim\s*\{[^}]*position:\s*fixed[^}]*inset:\s*68px 0 0[^}]*z-index:\s*18[^}]*background:\s*rgba\(23,\s*50,\s*77,\s*\.48\)/)
|
||||
assert.match(mobileStyles, /\.client-sidebar-header\s*\{[^}]*display:\s*flex[^}]*height:\s*52px/)
|
||||
assert.match(mobileStyles, /\.client-main\s*\{[^}]*max-width:\s*100%[^}]*margin-left:\s*0/)
|
||||
assert.match(mobileStyles, /\.client-page-heading > button\s*\{[^}]*display:\s*grid[^}]*width:\s*44px[^}]*height:\s*44px/)
|
||||
assert.match(mobileStyles, /\.client-user\s*\{[^}]*margin-left:\s*auto/)
|
||||
})
|
||||
|
||||
test('style source contract: removes drawer motion when reduced motion is preferred', () => {
|
||||
assert.match(compact, /@media \(prefers-reduced-motion: reduce\)\s*\{\s*\.client-sidebar,[^\{]*\.client-sidebar-group-chevron\s*\{[^}]*transition:\s*none/)
|
||||
})
|
||||
Reference in New Issue
Block a user