@operato/layout 10.29.24 → 10.29.26
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 +23 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +416 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov.info +17681 -0
- package/dist/src/actions/entity360-name.d.ts +8 -0
- package/dist/src/actions/entity360-name.js +19 -3
- package/dist/src/actions/entity360-name.js.map +1 -1
- package/dist/src/actions/entity360-registry.d.ts +31 -0
- package/dist/src/actions/entity360-registry.js +126 -7
- package/dist/src/actions/entity360-registry.js.map +1 -1
- package/dist/src/actions/entity360.d.ts +2 -0
- package/dist/src/actions/entity360.js +4 -0
- package/dist/src/actions/entity360.js.map +1 -1
- package/dist/test/entity360-kind.test.d.ts +1 -0
- package/dist/test/entity360-kind.test.js +140 -0
- package/dist/test/entity360-kind.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/test/entity360-kind.test.ts +176 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { expect, fixture } from '@open-wc/testing'
|
|
2
|
+
import { html, render } from 'lit'
|
|
3
|
+
import { store, UPDATE_CONTEXT } from '@operato/shell'
|
|
4
|
+
import '../src/index.js'
|
|
5
|
+
import {
|
|
6
|
+
closeEntity360,
|
|
7
|
+
entity360Link,
|
|
8
|
+
onEntity360Change,
|
|
9
|
+
openEntity360Kind,
|
|
10
|
+
redrawEntity360,
|
|
11
|
+
registerEntity360Kind,
|
|
12
|
+
type Entity360Subject,
|
|
13
|
+
type OxEntity360Dock
|
|
14
|
+
} from '../src/index.js'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A 360 opened by kind and id, the dock's own back trail, and the assistant subject it stands in for.
|
|
18
|
+
*
|
|
19
|
+
* A screen often holds an identifier, not a typed value: a location inside a stock line, an order
|
|
20
|
+
* inside a task's 360. It still opens the 360 of that kind, with the same link as entity360Name.
|
|
21
|
+
* Opening is a step in the address (f=kind:id), so back - the dock's or the browser's - returns to the one before.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const settle = () => new Promise(resolve => setTimeout(resolve, 50))
|
|
25
|
+
/** Go back and wait for the address to arrive - a late popstate would land in the next test. */
|
|
26
|
+
const back = (go: () => void = () => history.back()) =>
|
|
27
|
+
new Promise<void>(resolve => {
|
|
28
|
+
window.addEventListener('popstate', () => setTimeout(resolve, 0), { once: true })
|
|
29
|
+
go()
|
|
30
|
+
})
|
|
31
|
+
let bar: HTMLElement
|
|
32
|
+
const dock = () => bar.shadowRoot!.querySelector('ox-entity360-dock') as OxEntity360Dock
|
|
33
|
+
const subject = () => (store.getState() as any).route?.context?.subject
|
|
34
|
+
const address = () => new URLSearchParams(location.search).get('f')
|
|
35
|
+
|
|
36
|
+
registerEntity360Kind({ kind: 'kx-order', typenames: [], title: s => `order ${s.id}`, assistantSubject: true })
|
|
37
|
+
registerEntity360Kind({ kind: 'kx-place', typenames: [], title: s => `place ${s.id}`, assistantSubject: true })
|
|
38
|
+
registerEntity360Kind({ kind: 'kx-quiet', typenames: [], title: s => `quiet ${s.id}` })
|
|
39
|
+
let late = ''
|
|
40
|
+
registerEntity360Kind({ kind: 'kx-late', typenames: [], title: s => late || s.id })
|
|
41
|
+
|
|
42
|
+
describe('entity 360 by kind', () => {
|
|
43
|
+
beforeEach(async () => {
|
|
44
|
+
history.replaceState(null, '', location.pathname)
|
|
45
|
+
bar = await fixture(html`<ox-aside-bar></ox-aside-bar>`)
|
|
46
|
+
store.dispatch({ type: UPDATE_CONTEXT, context: { title: 'page', subject: { type: 'page', id: 'P' } } })
|
|
47
|
+
})
|
|
48
|
+
afterEach(() => dock()?.view?.onClose())
|
|
49
|
+
|
|
50
|
+
it('★ an identifier of a registered kind is the same link as a name; an unregistered one stays text', async () => {
|
|
51
|
+
const host = document.createElement('div')
|
|
52
|
+
render(html`${entity360Link('kx-order', 'SO-1')}|${entity360Link('nobody', 'X-1')}|${entity360Link('kx-order', '')}`, host)
|
|
53
|
+
|
|
54
|
+
const anchors = host.querySelectorAll('a[data-entity360]')
|
|
55
|
+
expect(anchors.length).to.equal(1)
|
|
56
|
+
expect(anchors[0].textContent).to.equal('SO-1')
|
|
57
|
+
expect(host.textContent).to.include('X-1')
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('★ a click on the link opens that kind with that id', async () => {
|
|
61
|
+
const host = await fixture(html`<div>${entity360Link('kx-order', 'SO-2')}</div>`)
|
|
62
|
+
;(host.querySelector('a') as HTMLElement).click()
|
|
63
|
+
await settle()
|
|
64
|
+
|
|
65
|
+
expect(dock().view!.title).to.equal('order SO-2')
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('★ opening is a step in the address; back returns to the 360 before', async () => {
|
|
69
|
+
openEntity360Kind('kx-order', { id: 'SO-3' })
|
|
70
|
+
await settle()
|
|
71
|
+
expect(address()).to.equal('kx-order:SO-3')
|
|
72
|
+
expect(dock().view!.onBack).to.equal(undefined)
|
|
73
|
+
|
|
74
|
+
openEntity360Kind('kx-place', { id: 'L-1' })
|
|
75
|
+
await settle()
|
|
76
|
+
expect(address()).to.equal('kx-place:L-1')
|
|
77
|
+
|
|
78
|
+
await back(() => dock().view!.onBack!())
|
|
79
|
+
expect(dock().view!.title).to.equal('order SO-3')
|
|
80
|
+
expect(address()).to.equal('kx-order:SO-3')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('★ an id with colons (an EPC) survives the address', async () => {
|
|
84
|
+
openEntity360Kind('kx-order', { id: 'SO-6' })
|
|
85
|
+
await settle()
|
|
86
|
+
openEntity360Kind('kx-place', { id: 'urn:epc:id:sgln:0614141.00001.0' })
|
|
87
|
+
await settle()
|
|
88
|
+
openEntity360Kind('kx-order', { id: 'SO-7' })
|
|
89
|
+
await settle()
|
|
90
|
+
/* Back only from a step this test took - otherwise it would leave the test page. */
|
|
91
|
+
expect(address()).to.equal('kx-order:SO-7')
|
|
92
|
+
expect(dock().view!.onBack).to.be.a('function')
|
|
93
|
+
|
|
94
|
+
await back()
|
|
95
|
+
expect(dock().view!.title).to.equal('place urn:epc:id:sgln:0614141.00001.0')
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('★ closing leaves the address without a 360', async () => {
|
|
99
|
+
openEntity360Kind('kx-order', { id: 'SO-4' })
|
|
100
|
+
await settle()
|
|
101
|
+
dock().view!.onClose()
|
|
102
|
+
await settle()
|
|
103
|
+
|
|
104
|
+
expect(address()).to.equal(null)
|
|
105
|
+
expect(dock()).to.equal(null)
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('★ while open, the 360 is the page subject; closing gives the page its own back', async () => {
|
|
109
|
+
openEntity360Kind('kx-order', { id: 'SO-5' })
|
|
110
|
+
await settle()
|
|
111
|
+
expect(subject()).to.deep.equal({ type: 'kx-order', id: 'SO-5' })
|
|
112
|
+
|
|
113
|
+
openEntity360Kind('kx-place', { id: 'L-3' })
|
|
114
|
+
await settle()
|
|
115
|
+
expect(subject()).to.deep.equal({ type: 'kx-place', id: 'L-3' })
|
|
116
|
+
|
|
117
|
+
dock().view!.onClose()
|
|
118
|
+
await settle()
|
|
119
|
+
expect(subject()).to.deep.equal({ type: 'page', id: 'P' })
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('a kind that does not stand in for the page leaves the page subject alone', async () => {
|
|
123
|
+
openEntity360Kind('kx-quiet', { id: 'Q-1' })
|
|
124
|
+
await settle()
|
|
125
|
+
expect(subject()).to.deep.equal({ type: 'page', id: 'P' })
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('★ an app hears what the dock shows - open, back, and close', async () => {
|
|
129
|
+
const heard: (Entity360Subject | undefined)[] = []
|
|
130
|
+
const stop = onEntity360Change(subject => heard.push(subject))
|
|
131
|
+
|
|
132
|
+
openEntity360Kind('kx-order', { id: 'SO-8' })
|
|
133
|
+
await settle()
|
|
134
|
+
openEntity360Kind('kx-place', { id: 'L-8' })
|
|
135
|
+
await settle()
|
|
136
|
+
await back(() => dock().view!.onBack!())
|
|
137
|
+
dock().view!.onClose()
|
|
138
|
+
await settle()
|
|
139
|
+
stop()
|
|
140
|
+
|
|
141
|
+
expect(heard.map(one => (one ? `${one.kind}:${one.id}` : 'closed'))).to.deep.equal(['kx-order:SO-8', 'kx-place:L-8', 'kx-order:SO-8', 'closed'])
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('an app that let go of its selection closes the 360 and its step', async () => {
|
|
145
|
+
openEntity360Kind('kx-order', { id: 'SO-9' })
|
|
146
|
+
await settle()
|
|
147
|
+
closeEntity360()
|
|
148
|
+
await settle()
|
|
149
|
+
|
|
150
|
+
expect(dock()).to.equal(null)
|
|
151
|
+
expect(address()).to.equal(null)
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('redraw reads the title again - for a title its section learns later', async () => {
|
|
155
|
+
late = ''
|
|
156
|
+
openEntity360Kind('kx-late', { id: 'X-9' })
|
|
157
|
+
await settle()
|
|
158
|
+
expect(dock().view!.title).to.equal('X-9')
|
|
159
|
+
|
|
160
|
+
late = 'named later'
|
|
161
|
+
redrawEntity360()
|
|
162
|
+
await settle()
|
|
163
|
+
expect(dock().view!.title).to.equal('named later')
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it('a link carries more for the sections, beside the id', async () => {
|
|
167
|
+
const heard: (Entity360Subject | undefined)[] = []
|
|
168
|
+
const stop = onEntity360Change(subject => heard.push(subject))
|
|
169
|
+
const host = await fixture(html`<div>${entity360Link('kx-order', 'SO-10', undefined, { instanceId: 'twin-2' })}</div>`)
|
|
170
|
+
;(host.querySelector('a') as HTMLElement).click()
|
|
171
|
+
await settle()
|
|
172
|
+
stop()
|
|
173
|
+
|
|
174
|
+
expect(heard[0]?.value).to.include({ id: 'SO-10', instanceId: 'twin-2' })
|
|
175
|
+
})
|
|
176
|
+
})
|