@operato/help 10.29.33 → 10.29.34

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.
@@ -2,7 +2,10 @@ import { expect, fixture, html, waitUntil } from '@open-wc/testing'
2
2
 
3
3
  import '../src/components/ox-doc.js'
4
4
  import '../src/components/ox-help-spot.js'
5
+ import '../src/viewparts/ox-help-panel.js'
5
6
  import type { OxDoc } from '../src/components/ox-doc.js'
7
+ import { appendViewpart, VIEWPART_POSITION } from '@operato/layout'
8
+ import { store } from '@operato/shell'
6
9
 
7
10
  /**
8
11
  * ox-doc reads /helps/{topic}.html and renders it; the products that used to keep their own copy rely on
@@ -79,54 +82,27 @@ describe('ox-doc', () => {
79
82
  })
80
83
 
81
84
  describe('ox-help-spot', () => {
82
- /* Its two links are words of the reader's language, not English left in a Korean screen. */
83
- it('names its links in the reader\'s language', async () => {
84
- const { i18next } = await import('@operato/i18n')
85
- i18next.addResourceBundle(i18next.language || 'en', 'translations', { 'button.close': '닫기', 'text.help-open-full': '전체 보기' }, true, true)
86
- const el = await fixture<HTMLElement>(html`<ox-help-spot topic="a/one" section="part"></ox-help-spot>`)
87
- await waitUntil(() => el.shadowRoot!.querySelector('button.q'))
88
- ;(el.shadowRoot!.querySelector('button.q') as HTMLButtonElement).click()
89
- await waitUntil(() => el.shadowRoot!.querySelector('.bar'))
90
-
91
- const bar = el.shadowRoot!.querySelector('.bar')!.textContent!.replace(/\s+/g, ' ')
92
- expect(bar).to.contain('전체 보기')
93
- expect(bar).to.contain('닫기')
94
- expect(bar).not.to.contain('close')
95
- })
96
-
97
- it('opens the section in place and closes on Escape', async () => {
98
- const el = await fixture<HTMLElement>(html`<ox-help-spot topic="a/one" section="part"></ox-help-spot>`)
99
- await waitUntil(() => el.shadowRoot!.querySelector('button.q'))
100
- ;(el.shadowRoot!.querySelector('button.q') as HTMLButtonElement).click()
101
- await waitUntil(() => el.shadowRoot!.querySelector('ox-doc'))
102
-
103
- /* The dialog says what opened and can take focus (operato-twin's overlay guard asks both). */
104
- const panel = el.shadowRoot!.querySelector('.panel')!
105
- expect(panel.getAttribute('aria-label')).to.equal('help')
106
- expect(panel.getAttribute('tabindex')).to.equal('-1')
107
-
108
- const doc = el.shadowRoot!.querySelector('ox-doc') as OxDoc
109
- expect(doc.getAttribute('section')).to.equal('part')
110
- expect(doc.hasAttribute('compact')).to.equal(true)
111
-
112
- el.shadowRoot!.querySelector('.panel')!.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, composed: true }))
113
- await waitUntil(() => !el.shadowRoot!.querySelector('.panel'))
114
- })
115
-
116
- /* A `?` in a grid header sits in nowrap, bold, right-aligned text; its panel is a document and must not take those. */
117
- it('opens a panel that wraps and reads from the start, whatever the text around the ?', async () => {
85
+ /*
86
+ * The `?` opens the app's help overlay at its section and draws no panel of its own: one drawn inside it sat in
87
+ * whatever held the `?` (a card button, a grid header), took that parent's pointer and text settings, and handed
88
+ * its scrolling and presses back to it. The press of the `?` itself is not a press of its parent either.
89
+ */
90
+ it('opens the help overlay at its section, and its press does not reach what holds it', async () => {
91
+ appendViewpart({ name: 'help', viewpart: { show: false, hovering: 'edge', template: html`<ox-help-panel></ox-help-panel>` }, position: VIEWPART_POSITION.ASIDEBAR })
92
+ let parentPresses = 0
118
93
  const host = await fixture<HTMLElement>(
119
- html`<div style="white-space: nowrap; text-align: right; font-weight: 700; width: 120px"><ox-help-spot topic="a/one" section="part"></ox-help-spot></div>`
94
+ html`<button style="cursor: pointer" @click=${() => parentPresses++} @pointerdown=${() => parentPresses++}><ox-help-spot topic="a/one" section="part"></ox-help-spot></button>`
120
95
  )
121
96
  const el = host.querySelector('ox-help-spot') as HTMLElement
122
97
  await waitUntil(() => el.shadowRoot!.querySelector('button.q'))
123
- ;(el.shadowRoot!.querySelector('button.q') as HTMLButtonElement).click()
124
- await waitUntil(() => el.shadowRoot!.querySelector('.panel'))
125
-
126
- const panel = getComputedStyle(el.shadowRoot!.querySelector('.panel')!)
127
- expect(panel.whiteSpace).to.equal('normal')
128
- expect(panel.textAlign).to.equal('start')
129
- expect(panel.fontWeight).to.equal('400')
98
+ const q = el.shadowRoot!.querySelector('button.q') as HTMLButtonElement
99
+ q.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, composed: true }))
100
+ q.click()
101
+
102
+ expect(parentPresses).to.equal(0)
103
+ expect(el.shadowRoot!.querySelector('.panel, ox-doc')).to.equal(null)
104
+ expect(history.state?.overlay?.name).to.equal('help')
105
+ expect((store.getState() as any).layout.viewparts.help.templateProperties).to.deep.equal({ topic: 'a/one', section: 'part' })
130
106
  })
131
107
 
132
108
  /* A `?` is placed before its help is written; it must not open 「Content not found」 or the whole document. */
@@ -150,3 +126,25 @@ describe('ox-help-spot', () => {
150
126
  expect(missing.hasAttribute('hidden')).to.equal(true)
151
127
  })
152
128
  })
129
+
130
+ describe('ox-help-panel', () => {
131
+ /* The overlay shows what a `?` asked about - an html document's section - and the older markdown topics as before. */
132
+ it('shows an html topic through ox-doc at the section, and a markdown topic as markdown', async () => {
133
+ const html1 = await fixture<HTMLElement>(html`<ox-help-panel topic="a/one" section="part"></ox-help-panel>`)
134
+ await waitUntil(() => html1.shadowRoot!.querySelector('ox-doc'))
135
+ const doc = html1.shadowRoot!.querySelector('ox-doc') as OxDoc
136
+ expect([doc.getAttribute('topic'), doc.getAttribute('section'), doc.hasAttribute('compact')]).to.deep.equal(['a/one', 'part', true])
137
+
138
+ const md = await fixture<HTMLElement>(html`<ox-help-panel topic="b/md"></ox-help-panel>`)
139
+ await waitUntil(() => md.shadowRoot!.querySelector('ox-markdown'))
140
+ expect(md.shadowRoot!.querySelector('ox-doc')).to.equal(null)
141
+ })
142
+ })
143
+
144
+ describe('ox-doc anchor', () => {
145
+ /* The help page opens the whole document at the part the overlay showed. */
146
+ it('scrolls its scrolling parent to the anchor once the document is drawn', async () => {
147
+ const box = await fixture<HTMLElement>(html`<div style="height: 40px; overflow: auto"><ox-doc topic="a/one" anchor="next"></ox-doc></div>`)
148
+ await waitUntil(() => box.scrollTop > 0, 'the box scrolls to #next')
149
+ })
150
+ })
@@ -1,4 +0,0 @@
1
- {
2
- "button.close": "Close",
3
- "text.help-open-full": "open full"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "button.close": "Cerrar",
3
- "text.help-open-full": "abrir completo"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "button.close": "閉じる",
3
- "text.help-open-full": "全体を開く"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "button.close": "닫기",
3
- "text.help-open-full": "전체 보기"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "button.close": "Tutup",
3
- "text.help-open-full": "buka penuh"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "button.close": "关闭",
3
- "text.help-open-full": "打开全文"
4
- }