@operato/popup 10.29.12 → 10.29.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/coverage/lcov-report/index.html +24 -24
- package/coverage/lcov.info +4245 -3679
- package/dist/src/ox-prompt.d.ts +3 -0
- package/dist/src/ox-prompt.js +7 -2
- package/dist/src/ox-prompt.js.map +1 -1
- package/dist/test/ox-prompt-ime-enter.test.d.ts +1 -0
- package/dist/test/ox-prompt-ime-enter.test.js +64 -0
- package/dist/test/ox-prompt-ime-enter.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/test/ox-prompt-ime-enter.test.ts +75 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing'
|
|
2
|
+
|
|
3
|
+
import { OxPrompt } from '../src/ox-prompt.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* OxPrompt.prompt confirms on Enter. An Enter that ends an IME composition (Korean, Japanese) only
|
|
7
|
+
* commits the last syllable, so confirming on it resolved with that syllable missing: a screen named
|
|
8
|
+
* "조립 셀" was created as "조립 ". The plant station-screen list guarded this in its own popup; the
|
|
9
|
+
* shared prompt now does, for every caller.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const settle = (ms = 50) => new Promise(resolve => setTimeout(resolve, ms))
|
|
13
|
+
|
|
14
|
+
/* Watches the step that matters - whether Enter asks the prompt to confirm - without waiting on the close. */
|
|
15
|
+
async function openWatched() {
|
|
16
|
+
void OxPrompt.prompt({ title: 'name', preventCloseOnBlur: true })
|
|
17
|
+
await settle()
|
|
18
|
+
|
|
19
|
+
const prompts = document.body.querySelectorAll('ox-prompt')
|
|
20
|
+
const prompt = prompts[prompts.length - 1] as OxPrompt
|
|
21
|
+
const field = prompt.querySelector('input') as HTMLInputElement
|
|
22
|
+
let confirmed = 0
|
|
23
|
+
prompt.onConfirm = () => {
|
|
24
|
+
confirmed++
|
|
25
|
+
}
|
|
26
|
+
return { field, confirmed: () => confirmed }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function enter(field: HTMLInputElement, isComposing: boolean) {
|
|
30
|
+
field.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', isComposing, bubbles: true, composed: true }))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe('OxPrompt.prompt and Enter', () => {
|
|
34
|
+
afterEach(async () => {
|
|
35
|
+
/* Cancel through the prompt itself so its open() settles and leaves nothing listening behind. */
|
|
36
|
+
document.body.querySelectorAll('ox-prompt').forEach(p => (p as OxPrompt).onCancel())
|
|
37
|
+
await settle(100)
|
|
38
|
+
document.body.querySelectorAll('ox-prompt').forEach(p => p.remove())
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('an Enter that ends a composition does not confirm', async () => {
|
|
42
|
+
const { field, confirmed } = await openWatched()
|
|
43
|
+
expect(field, 'the prompt draws a field').to.exist
|
|
44
|
+
enter(field, true)
|
|
45
|
+
expect(confirmed()).to.equal(0)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('a plain Enter confirms', async () => {
|
|
49
|
+
const { field, confirmed } = await openWatched()
|
|
50
|
+
enter(field, false)
|
|
51
|
+
expect(confirmed()).to.equal(1)
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
describe('OxPrompt.prompt draws no icon unless asked', () => {
|
|
56
|
+
afterEach(async () => {
|
|
57
|
+
/* Cancel through the prompt itself so its open() settles and leaves nothing listening behind. */
|
|
58
|
+
document.body.querySelectorAll('ox-prompt').forEach(p => (p as OxPrompt).onCancel())
|
|
59
|
+
await settle(100)
|
|
60
|
+
document.body.querySelectorAll('ox-prompt').forEach(p => p.remove())
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('a plain prompt has no icon; a typed one does', async () => {
|
|
64
|
+
void OxPrompt.prompt({ title: 'name', preventCloseOnBlur: true })
|
|
65
|
+
void OxPrompt.prompt({ title: 'name', type: 'warning', preventCloseOnBlur: true })
|
|
66
|
+
await settle()
|
|
67
|
+
|
|
68
|
+
const prompts = document.body.querySelectorAll('ox-prompt')
|
|
69
|
+
const plain = prompts[0] as OxPrompt
|
|
70
|
+
const typed = prompts[1] as OxPrompt
|
|
71
|
+
await Promise.all([plain.updateComplete, typed.updateComplete])
|
|
72
|
+
expect(plain.renderRoot.querySelector('[icon]')).to.equal(null)
|
|
73
|
+
expect(typed.renderRoot.querySelector('[icon]')).to.not.equal(null)
|
|
74
|
+
})
|
|
75
|
+
})
|