feat: simplify today into plain list
ci / gitleaks (push) Successful in 10s
ci / docker (push) Successful in 7m27s

This commit is contained in:
2026-09-17 18:04:40 +08:00
parent 73aca652f1
commit 66589dd458
9 changed files with 228 additions and 143 deletions
@@ -30,11 +30,12 @@ describe('TodayEnvironmentStrip', () => {
expect(host.querySelector('.today-environment')?.getAttribute('aria-label')).toBe('今日环境信息')
expect(host.textContent).toContain('9月16日 周三')
expect(host.textContent).toContain('农历八月初六')
expect(host.textContent).toContain('宁波海曙')
expect(host.textContent).toContain('27° 多云')
expect(host.textContent).toContain('Au99.99 延时')
expect(host.textContent).toContain('¥782.35/g')
expect(host.textContent).toContain('市场日期 09-15')
const weather = host.querySelector('.today-environment__weather')!
expect(weather.children).toHaveLength(2)
expect(weather.querySelector('strong')?.textContent).toBe('宁波 27°C 多云')
expect(weather.querySelector('small')?.textContent).toBe('海曙 09:00')
expect(host.textContent).toContain('Au99.99 ¥782.35/g')
expect(host.textContent).toContain('上金所延迟价 09-15')
expect(host.querySelector('.today-environment__gold')?.classList.contains('is-stale')).toBe(true)
})
@@ -45,11 +46,9 @@ describe('TodayEnvironmentStrip', () => {
gold: { contract: 'Au99.99', latest_price: '935.990', market_date: '2026-09-16', delayed: true, source: '上海黄金交易所', stale: true },
} as TodayEnvironment })
expect(host.textContent).toContain('9月16日 周三')
expect(host.textContent).toContain('宁波海曙')
expect(host.textContent).toMatch(/28\.4°\s+多云/)
expect(host.textContent).toContain('Au99.99 延时')
expect(host.textContent).toContain('¥935.99/g')
expect(host.textContent).toContain('市场日期 09-16')
expect(host.textContent).toContain('宁波 28.4°C 多云')
expect(host.textContent).toContain('Au99.99 ¥935.99/g')
expect(host.textContent).toContain('上金所延迟价 09-16')
expect(host.querySelector('.today-environment__gold')?.classList.contains('is-stale')).toBe(true)
})
@@ -70,9 +69,8 @@ describe('TodayEnvironmentStrip', () => {
it('keeps existing values visible while a refresh is in progress', async () => {
const host = await mountStrip({ environment, loading: true })
expect(host.textContent).toContain('27° 多云')
expect(host.textContent).toContain('Open-Meteo 09:00')
expect(host.textContent).not.toContain('Open-Meteo · 09:00')
expect(host.textContent).toContain('宁波 27°C 多云')
expect(host.textContent).toContain('海曙 09:00')
expect(host.textContent).toContain('¥782.35/g')
expect(host.querySelector('.today-environment')?.getAttribute('aria-busy')).toBe('true')
const status = host.querySelector('.today-environment__status')
@@ -141,10 +139,9 @@ describe('TodayEnvironmentStrip', () => {
it('matches the selected two-row mobile composition', () => {
const css = readFileSync(resolve(process.cwd(), 'src/style.css'), 'utf8')
expect(css).toContain('.today-track-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;color:#776c60;font-size:12px}')
expect(css).toContain('.today-track-head strong{font-size:14px;line-height:1.2;color:#403a32}')
expect(css).not.toContain('.today-track-head{')
expect(css).toContain('@media(max-width:720px){.today-environment{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-template-rows:auto auto}')
expect(css).toContain('.today-environment__calendar{grid-column:1/-1;grid-row:1;display:flex;flex-direction:column;align-items:flex-start')
expect(css).toContain('.today-environment__calendar{grid-column:1/-1;grid-row:1;display:flex;flex-direction:row;align-items:baseline;justify-content:space-between')
expect(css).toContain('.today-environment__weather{grid-column:1;grid-row:2;border-top:1px solid var(--line);border-left:0!important}')
expect(css).toContain('.today-environment__gold{grid-column:2;grid-row:2;border-top:1px solid var(--line)}')
expect(css).toContain('.today-environment__weather,.today-environment__gold{padding:13px 10px;display:flex;flex-direction:column;')