✅ test: 覆盖弹窗生命周期、存储合并与插件页的时长选项
This commit is contained in:
+36
-1
@@ -122,6 +122,11 @@ test('the plugin page reads as three groups with copy, not raw keys', () => {
|
||||
'Every alert comes from this page',
|
||||
'What to notify about',
|
||||
'The switches are stored in this browser',
|
||||
'Popup',
|
||||
'Auto-close',
|
||||
'6s',
|
||||
'Never',
|
||||
'Hovering a card pauses the countdown',
|
||||
'System notification permission',
|
||||
'This environment cannot show system notifications',
|
||||
platformHint,
|
||||
@@ -149,6 +154,8 @@ test('the plugin page reads as three groups with copy, not raw keys', () => {
|
||||
'dsn-row',
|
||||
'dsn-row-title',
|
||||
'dsn-state',
|
||||
'dsn-chips',
|
||||
'dsn-chip',
|
||||
'dsn-facts',
|
||||
'dsn-fact-key',
|
||||
'dsn-fact-value',
|
||||
@@ -156,13 +163,41 @@ test('the plugin page reads as three groups with copy, not raw keys', () => {
|
||||
]) {
|
||||
assert.ok(classes.includes(className), `the page is missing .${className}`)
|
||||
}
|
||||
// Three switches, one status dot, and the readings as key/value pairs.
|
||||
// Three switches, five lifetime choices, one status dot, and the readings as
|
||||
// key/value pairs.
|
||||
assert.equal(classes.filter((className) => className === 'dsn-switch').length, 3)
|
||||
assert.equal(classes.filter((className) => className === 'dsn-chip').length, 5)
|
||||
assert.equal(classes.filter((className) => className === 'dsn-dot is-muted').length, 1)
|
||||
assert.equal(classes.filter((className) => className === 'dsn-fact-key').length, 4)
|
||||
assert.equal(classes.filter((className) => className === 'dsn-fact-value').length, 4)
|
||||
})
|
||||
|
||||
test('the popup lifetime is a real choice: the page reads it and writes it back', () => {
|
||||
const { config } = mount()
|
||||
const props = config.definition.inject()
|
||||
|
||||
const chips = (componentProps) => walk(config.component({ ...componentProps, view: 'page' }))
|
||||
.elements.filter((element) => element.props.className === 'dsn-chip')
|
||||
const labelOf = (chip) => walk(chip).text.join('')
|
||||
const checkedOf = (list) => list.filter((chip) => chip.props['aria-checked'] === true).map(labelOf)
|
||||
|
||||
const before = chips(props)
|
||||
assert.deepEqual(before.map(labelOf), ['3s', '6s', '10s', '30s', 'Never'])
|
||||
assert.deepEqual(checkedOf(before), ['6s'], 'the shipped default is preselected')
|
||||
assert.equal(before[0].props.role, 'radio')
|
||||
assert.equal(walk(config.component({ ...props, view: 'page' })).elements.find((element) => element.props.className === 'dsn-chips').props.role, 'radiogroup')
|
||||
|
||||
// "Never" is the zero choice, and choosing it goes through the plugin's own
|
||||
// action: the store the popup stack reads is updated, not just the button.
|
||||
before[4].props.onClick()
|
||||
assert.equal(props.store.getSnapshot().dismissAfterMs, 0)
|
||||
assert.deepEqual(checkedOf(chips(props)), ['Never'])
|
||||
|
||||
before[0].props.onClick()
|
||||
assert.equal(props.store.getSnapshot().dismissAfterMs, 3000)
|
||||
assert.deepEqual(checkedOf(chips(props)), ['3s'])
|
||||
})
|
||||
|
||||
test('the page follows the store: switches, permission state and delivery facts', () => {
|
||||
const { config } = mount()
|
||||
const props = config.definition.inject()
|
||||
|
||||
Reference in New Issue
Block a user