@things-factory/apptool-ui 10.1.278 → 10.1.279

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.
@@ -1,314 +0,0 @@
1
- import { readFileSync } from 'fs'
2
- import path from 'path'
3
-
4
- import {
5
- menuButtonShown,
6
- scopeName,
7
- scopeOptions,
8
- scopeShape,
9
- SLOT_ORDER,
10
- toolsBySlot,
11
- unreadLabel,
12
- wordmark
13
- } from '../client/layout/header-band-model'
14
-
15
- /**
16
- * The shared header band (ADR-0060 decision 4 and its 2026-09-18 addendum).
17
- *
18
- * The drawing needs a DOM and this repository's runner has none, so what a test can reach is the
19
- * deciding: which slot a tool belongs to, whether the menu button is drawn, what shape a scope
20
- * takes. The rest is held by reading the band's own source - the rules that matter there are about
21
- * what the band must not do (keep a second registry, know an app's words), and those are visible in
22
- * the text.
23
- */
24
-
25
- const BAND = path.resolve(__dirname, '../client/layout/app-header-band.ts')
26
- const bandSource = readFileSync(BAND, 'utf-8')
27
-
28
- /** The source with its comments stripped, so prose about a rule cannot satisfy the rule. */
29
- const bandCode = bandSource.replace(/\/\*[\s\S]*?\*\//g, '').replace(/^\s*\/\/.*$/gm, '')
30
-
31
- describe('the band splits one registry', () => {
32
- it('★ the five slot names are still the ones @operato/layout declares', () => {
33
- /*
34
- * The model writes the five out rather than importing the enum: @operato/layout is an ES module
35
- * and this runner does not transform node_modules, so an import there would put every decision
36
- * out of reach of every test. This reads the installed declaration instead, so the two cannot
37
- * drift apart in silence.
38
- */
39
- const declaration = readFileSync(
40
- path.resolve(__dirname, '../../../node_modules/@operato/layout/dist/src/actions/layout.d.ts'),
41
- 'utf-8'
42
- )
43
- const body = declaration.slice(declaration.indexOf('enum TOOL_POSITION'))
44
- const declared = [...body.slice(0, body.indexOf('}')).matchAll(/(\w+) = "(\w+)"/g)].map(match => match[2])
45
-
46
- expect(declared).toEqual([...SLOT_ORDER])
47
- })
48
-
49
- it('★ every tool lands in the slot it declared', () => {
50
- const tools = [
51
- { name: 'hamburger', position: 'FRONT_END' },
52
- { name: 'favorite', position: 'REAR' },
53
- { name: 'more', position: 'REAR_END' },
54
- { name: 'title-bar', position: 'CENTER' },
55
- { name: 'unplaced' }
56
- ]
57
-
58
- const bySlot = toolsBySlot(tools)
59
-
60
- expect(SLOT_ORDER.map(slot => bySlot[slot].map(tool => tool.name))).toEqual([
61
- ['hamburger'],
62
- [],
63
- ['title-bar'],
64
- ['favorite'],
65
- ['more']
66
- ])
67
- })
68
-
69
- it('★ and it reads the registry the app toolbar reads, rather than keeping one of its own', () => {
70
- /*
71
- * A second registry would make every contributor pick a side: lite-menu's hamburger and
72
- * more-ui's morenda button are dispatched once, to one place, by packages that do not know
73
- * which of the two is drawing.
74
- */
75
- expect(bandCode).toContain('store.getState()')
76
- expect(bandCode).toContain('apptool')
77
- expect(bandCode).not.toContain('APPEND_APP_TOOL')
78
- expect(bandCode).not.toContain('store.dispatch')
79
- })
80
-
81
- it('★ and it draws the five slots left to right in the declared order', () => {
82
- const order = ['frontEnd', 'front', 'center', 'rear', 'rearEnd']
83
- const template = bandCode.slice(bandCode.indexOf('<div class="band">'))
84
- const drawn = order
85
- .map(name => ({ name, at: template.indexOf(`${name}.map(`) }))
86
- .filter(({ at }) => at >= 0)
87
-
88
- expect(drawn.map(({ name }) => name)).toEqual(order)
89
- expect(drawn.map(({ at }) => at)).toEqual([...drawn.map(({ at }) => at)].sort((a, b) => a - b))
90
- })
91
- })
92
-
93
- describe('the way into the menu', () => {
94
- const hamburger = [{ name: 'hamburger', position: 'FRONT_END' }]
95
-
96
- it('★ the band draws a menu button while the rail is hidden', () => {
97
- /*
98
- * lite-menu puts the rail away on a mobile device in portrait, or when the app asks for
99
- * `hovering`, and registers its hamburger in the app toolbar - which a band app has turned off.
100
- * twin had no button of its own, so on a phone there was no way to leave the screen you were on
101
- * (2026-09-18, seen under mobile emulation).
102
- *
103
- * A narrowed desktop window is not that case: the rail stays and spreads to the window's width.
104
- * Warehouse looked for it at 375px on a desktop and it did not happen, then saw it under a
105
- * Pixel 8 user agent (:3500, 2026-09-18) - the device check runs once at boot, so emulation
106
- * only counts after a reload.
107
- */
108
- expect(menuButtonShown(false, [])).toBe(true)
109
- })
110
-
111
- it('and not while the rail is on screen, or before the menu part has registered', () => {
112
- expect(menuButtonShown(true, [])).toBe(false)
113
- /* Absent reads as shown, so the button does not flash on during boot. */
114
- expect(menuButtonShown(undefined, [])).toBe(false)
115
- })
116
-
117
- it('★ and not when something already registered one, so there are never two', () => {
118
- expect(menuButtonShown(false, hamburger)).toBe(false)
119
- })
120
-
121
- it('★ a page can also clear the rail itself, with widebleed or fullbleed', () => {
122
- /*
123
- * `@operato/shell`'s app.ts gives the nav bar `?fullbleed=${fullbleed || widebleed}`, which
124
- * hides its contents without touching the menu part's own `show` - board's viewer and player do
125
- * this (2026-09-22). The rail is gone from the screen either way, so the button is drawn even
126
- * though the menu part itself still reads "shown".
127
- */
128
- expect(menuButtonShown(true, [], true)).toBe(true)
129
- })
130
-
131
- it('and not when the page asks for neither and the rail is on screen', () => {
132
- expect(menuButtonShown(true, [], false)).toBe(false)
133
- })
134
-
135
- it('★ and the band hands the page’s own choice to that rule when it draws', () => {
136
- /*
137
- * The rule took the page's widebleed/fullbleed from 2026-09-22, but the band went on calling it with
138
- * two arguments, so board's modeller hid the rail and drew no way back to the menu (2026-10-06).
139
- */
140
- const call = bandCode.match(/menuButtonShown\(([^)]*)\)/)
141
- expect(call?.[1].split(',').map(arg => arg.trim())).toEqual(['this.menuPartShow', 'frontEnd', 'railHiddenByPage'])
142
- })
143
- })
144
-
145
- describe('the notification count', () => {
146
- it('★ nothing is drawn for nothing unread', () => {
147
- expect(unreadLabel(0)).toBeUndefined()
148
- expect(unreadLabel(undefined)).toBeUndefined()
149
- })
150
-
151
- it('and the exact number stops being worth the width past 99', () => {
152
- expect(unreadLabel(1)).toEqual('1')
153
- expect(unreadLabel(99)).toEqual('99')
154
- expect(unreadLabel(100)).toEqual('99+')
155
- })
156
-
157
- it('★ the bell opens the side panel, rather than navigating to a page', () => {
158
- /*
159
- * plant sent this to `notification-list-page` for a while. An alarm is glanced at without
160
- * leaving the screen you are on, and navigating away is the thing that was wrong with it.
161
- */
162
- expect(bandCode).toContain("toggleOverlay('notification'")
163
- expect(bandCode).not.toContain('notification-list-page')
164
- })
165
- })
166
-
167
- describe('the scope the app hands over', () => {
168
- it('★ one of something draws its name, with nothing to press', () => {
169
- const scope = { label: 'factory', items: [{ id: 'a', label: '미라텍' }], selectedId: 'a' }
170
-
171
- expect(scopeShape(scope)).toEqual('name')
172
- expect(scopeName(scope)).toEqual('미라텍')
173
- })
174
-
175
- it('★ the picker takes away the select\'s own outline, so its pill draws the ring every other control draws', () => {
176
- /*
177
- * The scope select sets outline: none to sit borderless inside its pill. With nothing in its place a
178
- * keyboard user lost the focus on that one control: plant's e2e measured it invisible on 21 screens
179
- * (2026-10-10).
180
- */
181
- expect(bandCode).toMatch(/\.scope select \{[^}]*outline: none/)
182
- expect(bandCode).toMatch(/\.scope:has\(select:focus-visible\) \{[^}]*outline: 2px solid var\(--md-sys-color-primary\)/)
183
- })
184
-
185
- it('and several draw a picker, and none draws nothing', () => {
186
- const two = {
187
- label: 'factory',
188
- items: [
189
- { id: 'a', label: '미라텍' },
190
- { id: 'b', label: '제2공장' }
191
- ],
192
- selectedId: 'a'
193
- }
194
-
195
- expect(scopeShape(two)).toEqual('picker')
196
- expect(scopeShape(undefined)).toEqual('none')
197
- expect(scopeShape({ label: 'factory', items: [] })).toEqual('none')
198
- })
199
-
200
- it('★ an app where "not chosen yet" is real can say so, and the head does not claim a choice', () => {
201
- const sites = [
202
- { id: 'a', label: 'Rosarito' },
203
- { id: 'b', label: 'Tijuana' }
204
- ]
205
- const scope = { label: 'site', items: sites, unchosen: 'pick a site' }
206
-
207
- /* The empty entry leads and is the one selected - not the first site. */
208
- expect(scopeOptions(scope).map(option => [option.id, option.selected])).toEqual([
209
- ['', true],
210
- ['a', false],
211
- ['b', false]
212
- ])
213
-
214
- /* Once one is chosen, the empty entry stays so you can go back, but it is no longer selected. */
215
- expect(scopeOptions({ ...scope, selectedId: 'b' }).map(option => option.selected)).toEqual([false, false, true])
216
- })
217
-
218
- it('★ and a lone scope not yet chosen is offered, not named', () => {
219
- const lone = { label: 'site', items: [{ id: 'a', label: 'Rosarito' }], unchosen: 'pick a site' }
220
-
221
- expect(scopeShape(lone)).toEqual('picker')
222
- expect(scopeName(lone)).toEqual('pick a site')
223
-
224
- expect(scopeShape({ ...lone, selectedId: 'a' })).toEqual('name')
225
- expect(scopeName({ ...lone, selectedId: 'a' })).toEqual('Rosarito')
226
- })
227
-
228
- it('and an app that leaves it out keeps what it had', () => {
229
- const two = {
230
- label: 'factory',
231
- items: [
232
- { id: 'a', label: '미라텍' },
233
- { id: 'b', label: '제2공장' }
234
- ],
235
- selectedId: 'a'
236
- }
237
-
238
- expect(scopeOptions(two).map(option => option.id)).toEqual(['a', 'b'])
239
- expect(scopeShape({ label: 'factory', items: [{ id: 'a', label: '미라텍' }] })).toEqual('name')
240
- })
241
-
242
- it('★ the picker draws the entries the model decides', () => {
243
- expect(bandCode).toMatch(/scopeOptions\(scope\)\.map\(/)
244
- })
245
-
246
- it('★ and the band never spells a scope word of its own', () => {
247
- /*
248
- * ADR-0048 · 0058: the shared band does not know the app's vocabulary. plant's scope is a
249
- * factory, twin's is a site, warehouse's is a warehouse, and each of those words belongs to the
250
- * app that passes it.
251
- */
252
- const theirs = ['factory', 'site', 'warehouse', '공장', '현장', '창고', 'domain', 'subdomain']
253
-
254
- expect(theirs.filter(word => bandCode.toLowerCase().includes(word.toLowerCase()))).toEqual([])
255
- })
256
- })
257
-
258
- describe('a tool from the registry', () => {
259
- it('★ takes the band control shape rather than the toolbar one', () => {
260
- /*
261
- * lite-menu's hamburger and more-ui's morenda button are a bare md-icon apiece, written for the
262
- * coloured app toolbar. On warehouse they came out as 18x18 marks with `cursor: auto` beside
263
- * this row's 28px pill buttons (:3500, 2026-09-18) - nothing said they could be pressed.
264
- *
265
- * The rule reaches a tool because its template renders inside the band's own shadow root. The
266
- * band's buttons keep their icons inside a `.ctl`, so the direct-child selector leaves them be.
267
- */
268
- const styles = bandSource.slice(bandSource.indexOf('static styles = ['), bandSource.indexOf('@property'))
269
-
270
- expect(styles).toContain('.slot > md-icon')
271
- expect(styles).toContain('.slot > button:not(.ctl)')
272
- /* Pressable, and the same box the band's own buttons have. */
273
- expect(styles.slice(styles.indexOf('.slot > md-icon'))).toContain('cursor: pointer')
274
- })
275
- })
276
-
277
- describe('the product name', () => {
278
- it('★ the band owns the shape and the app gives one word', () => {
279
- expect(wordmark('plant')).toEqual({ lead: 'operato', name: 'plant' })
280
- expect(wordmark(' figure ')).toEqual({ lead: 'operato', name: 'figure' })
281
- })
282
-
283
- it('and an app that gives no word gets no wordmark', () => {
284
- expect(wordmark(undefined)).toBeUndefined()
285
- expect(wordmark('')).toBeUndefined()
286
- })
287
- })
288
-
289
- describe('a narrow band', () => {
290
- /*
291
- * Measured on twin and plant at 375px (2026-09-24): every slot shrank below its 28px buttons (the
292
- * menu slot at 17-24px, the dock button pressed to 19px), and the product name ran into the scope.
293
- * The rules are CSS, so what a test here can hold is that they are written and where they sit.
294
- */
295
- const slots = [...bandCode.matchAll(/<span class="slot([^"]*)">/g)].map(match => match[1].trim())
296
-
297
- it('★ the slots that hold only buttons never shrink', () => {
298
- expect(slots).toEqual(['fixed', 'scope-slot', 'center', 'fixed', 'fixed'])
299
- expect(bandCode).toMatch(/\.slot\.fixed\s*\{\s*flex:\s*none;/)
300
- })
301
-
302
- it('★ the scope shortens with an ellipsis, and the centre gives way before it', () => {
303
- expect(bandCode).toMatch(/\.scope-name\s*\{[^}]*text-overflow:\s*ellipsis/)
304
- const shrink = (slot: string) => Number(bandCode.match(new RegExp(`\\.slot\\.${slot}\\s*\\{\\s*flex:\\s*0\\s+(\\d+)`))?.[1])
305
- expect(shrink('center')).toBeGreaterThan(shrink('scope-slot'))
306
- })
307
-
308
- it('★ and it folds by its own width, dropping the product name first', () => {
309
- expect(bandCode).toMatch(/:host\s*\{[^}]*container-type:\s*inline-size/)
310
- const narrow = bandCode.split('@container (max-width: 599px)')[1] ?? ''
311
- expect(narrow).toMatch(/\.wordmark\s*\{\s*display:\s*none;/)
312
- expect(bandCode).not.toMatch(/@media/)
313
- })
314
- })
@@ -1,78 +0,0 @@
1
- import { readFileSync } from 'fs'
2
- import path from 'path'
3
-
4
- import { keepOnly, nextAfterClose, withoutRoute, type MdiRoute } from '../client/layout/mdibar-routes'
5
-
6
- /**
7
- * Closing MDI tabs (2026-10-12, user report: "a tab does not close in one go").
8
- *
9
- * Found in the browser on operato-plant with five tabs open:
10
- *
11
- * × on the active tab the tab came back at the end, carrying the next page's address
12
- * context menu "close" the chosen page was disposed, the tab to its left was dropped
13
- * "close others" `route === route` - no other page was disposed, only the tabs vanished
14
- *
15
- * The rules are tested here; that the bar uses them, and keeps a closed page from coming back, is read
16
- * from the source.
17
- */
18
-
19
- const home: MdiRoute = { url: '/' }
20
- const a: MdiRoute = { url: '/a', name: 'a', page: { id: 'A' } }
21
- const b: MdiRoute = { url: '/b', name: 'b', page: { id: 'B' } }
22
- const c: MdiRoute = { url: '/c', name: 'c', page: { id: 'C' } }
23
- const routes = [home, a, b, c]
24
-
25
- describe('closing an MDI tab', () => {
26
- it('★ takes out exactly that tab, found by itself - not by a position', () => {
27
- expect(withoutRoute(routes, b)).toEqual({ routes: [home, a, c], at: 2 })
28
- expect(withoutRoute(routes, a)).toEqual({ routes: [home, b, c], at: 1 })
29
- expect(withoutRoute(routes, c)).toEqual({ routes: [home, a, b], at: 3 })
30
- })
31
-
32
- it('home never closes, and a tab that is not there changes nothing', () => {
33
- expect(withoutRoute(routes, home).at).toBe(-1)
34
- expect(withoutRoute(routes, { url: '/x' }).at).toBe(-1)
35
- expect(withoutRoute(routes, { url: '/x' }).routes).toBe(routes)
36
- })
37
-
38
- it('the tab on screen closing hands the screen to the tab on its left - home for the first', () => {
39
- expect(nextAfterClose(withoutRoute(routes, b).routes, 2)).toBe(a)
40
- expect(nextAfterClose(withoutRoute(routes, a).routes, 1)).toBe(home)
41
- expect(nextAfterClose(withoutRoute(routes, c).routes, 3)).toBe(b)
42
- })
43
-
44
- it('★ close others keeps home and the chosen tab, and hands back every other tab to dispose', () => {
45
- expect(keepOnly(routes, b)).toEqual({ routes: [home, b], closed: [a, c] })
46
- })
47
-
48
- it('close all (keep home) closes every tab but home', () => {
49
- expect(keepOnly(routes, home)).toEqual({ routes: [home], closed: [a, b, c] })
50
- expect(keepOnly(routes, undefined)).toEqual({ routes: [home], closed: [a, b, c] })
51
- })
52
- })
53
-
54
- describe('the bar uses the rules', () => {
55
- const code = readFileSync(path.resolve(__dirname, '../client/layout/page-mdibar.ts'), 'utf-8')
56
-
57
- it('★ a page the bar closed never comes back as a tab while the address catches up', () => {
58
- expect(code).toMatch(/this\.closed\.add\(page\)/)
59
- expect(code).toMatch(/const page = activePage\s*\/\*[^*]*\*\/\s*if \(this\.closed\.has\(page\)\) \{\s*return\s*\}/)
60
- })
61
-
62
- it('★ every close path goes through dispose, by route - no index from the template', () => {
63
- expect(code).not.toMatch(/contextMenuTargetIndex/)
64
- expect(code).not.toMatch(/closePage\([^)]*,/)
65
- expect(code.match(/pageDispose\(\)/g)).toHaveLength(1)
66
- })
67
-
68
- it('the menu speaks the user language', () => {
69
- expect(code).not.toMatch(/label="close/)
70
- for (const key of ['button.close-tab', 'button.close-other-tabs', 'button.close-all-tabs', 'text.confirm_close_other_tabs']) {
71
- expect(code).toContain(`'${key}'`)
72
- for (const lang of ['ko', 'en', 'ja', 'zh', 'es', 'ms']) {
73
- const words = JSON.parse(readFileSync(path.resolve(__dirname, `../translations/${lang}.json`), 'utf-8'))
74
- expect(words[key]).toBeTruthy()
75
- }
76
- }
77
- })
78
- })
@@ -1,32 +0,0 @@
1
- import { readFileSync } from 'fs'
2
- import path from 'path'
3
-
4
- /**
5
- * The tab menu refreshes the page of the tab it was opened on (ADR-0174) - home's too - through the page's own
6
- * `refresh()`. Read from the source, as the close rules are.
7
- */
8
-
9
- describe('the tab menu refreshes a page', () => {
10
- const code = readFileSync(path.resolve(__dirname, '../client/layout/page-mdibar.ts'), 'utf-8')
11
-
12
- it('★ refreshes the page of the tab or home the menu was opened on, nothing when opened on the bar', () => {
13
- expect(code).toMatch(/this\.contextMenuTargetPage = route\.page/)
14
- expect(code).toMatch(/this\.contextMenuTargetPage = home\.page/)
15
- expect(code).toMatch(/delete this\.contextMenuTargetRoute\s*delete this\.contextMenuTargetPage/)
16
- expect(code).toMatch(/refreshing\.refresh\(\)/)
17
- })
18
-
19
- it('★ a click on the tab on screen - home too - refreshes it without asking; on another tab it moves there', () => {
20
- expect(code).toMatch(/@click=\$\{\(\) => this\.select\(home\.page, \(\) => this\.moveToHome\(\)\)\}/)
21
- expect(code).toMatch(/@click=\$\{\(\) => this\.select\(route\.page, \(\) => this\.moveTo\(route\)\)\}/)
22
- expect(code).toMatch(/if \(page && page === this\._routeCtrl\.activePage\) void page\.refresh\(\{ ask: false \}\)\s*else move\(\)/)
23
- })
24
-
25
- it('the item comes first, in the user language', () => {
26
- expect(code.indexOf("'button.refresh'")).toBeLessThan(code.indexOf("'button.close-tab'", code.indexOf('openContextMenu(e: MouseEvent) {')))
27
- for (const lang of ['ko', 'en', 'ja', 'zh', 'es', 'ms']) {
28
- const words = JSON.parse(readFileSync(path.resolve(__dirname, `../../shell/translations/${lang}.json`), 'utf-8'))
29
- expect(words['button.refresh']).toBeTruthy()
30
- }
31
- })
32
- })
@@ -1,78 +0,0 @@
1
- import { readFileSync } from 'fs'
2
- import path from 'path'
3
-
4
- import { mdibarShownNow, resolveMdibarShow } from '../client/mdibar-setting-state'
5
-
6
- /**
7
- * The MDI setting row must say what the tab bar is doing.
8
- *
9
- * It read the stored setting alone, so in an app that starts the bar on
10
- * (`setupAppToolPart({ mdibar: { default: true } })`) the row drew an empty checkbox over a bar that
11
- * was on screen. Seen on operato-plant at :4000, 2026-09-18.
12
- */
13
-
14
- describe('what the MDI setting row shows', () => {
15
- const stateWith = (show: boolean | undefined) => ({ layout: { viewparts: { appmdibar: { show } } } })
16
-
17
- it('★ on, when the app starts the bar on and the user has stored nothing', () => {
18
- /* setupAppToolPart folded `{ default: true }` into the viewpart; nothing is in clientSettingStore. */
19
- expect(mdibarShownNow(stateWith(true))).toBe(true)
20
- })
21
-
22
- it('off, when the user turned the bar off', () => {
23
- expect(mdibarShownNow(stateWith(false))).toBe(false)
24
- })
25
-
26
- it('off, when there is no bar to speak of', () => {
27
- expect(mdibarShownNow({ layout: { viewparts: {} } })).toBe(false)
28
- expect(mdibarShownNow({ layout: {} })).toBe(false)
29
- expect(mdibarShownNow({})).toBe(false)
30
- expect(mdibarShownNow(undefined)).toBe(false)
31
- })
32
-
33
- it('a half-written viewpart is not "on" — only an explicit true is', () => {
34
- expect(mdibarShownNow(stateWith(undefined))).toBe(false)
35
- expect(mdibarShownNow({ layout: { viewparts: { appmdibar: { show: 'yes' } } } })).toBe(false)
36
- })
37
-
38
- it('★ follows the bar while the settings card is on screen — a card that read once drew the old answer', () => {
39
- const code = readFileSync(path.resolve(__dirname, '../client/mdibar-setting-let.ts'), 'utf-8')
40
-
41
- expect(code).toMatch(/connectedCallback\(\)[\s\S]*store\.subscribe\(/)
42
- expect(code).toMatch(/disconnectedCallback\(\)[\s\S]*this\._unsubscribe\?\.\(\)/)
43
- expect(code).not.toMatch(/firstUpdated/)
44
- })
45
-
46
- it('the row reads the bar, not the stored setting', () => {
47
- const code = readFileSync(path.resolve(__dirname, '../client/mdibar-setting-let.ts'), 'utf-8')
48
-
49
- const body = code.match(/connectedCallback\(\) \{([\s\S]*?)\n \}/)?.[1]
50
-
51
- expect(body).toMatch(/this\.show = mdibarShownNow\(store\.getState\(\)\)/)
52
- /* The stored value is the user's own choice; the viewpart already carries it, folded with the app's default. */
53
- expect(body).not.toMatch(/clientSettingStore/)
54
- /* Writing the default into the store would freeze it — the app could never change its own default again. */
55
- expect(code).not.toMatch(/clientSettingStore\.put[\s\S]{0,120}default/)
56
- })
57
-
58
- describe('the state the bar starts in', () => {
59
- it("★ the app's default holds until the user picks — one rule, shared with setupAppToolPart", () => {
60
- expect(resolveMdibarShow(undefined, { default: true })).toBe(true)
61
- expect(resolveMdibarShow(undefined, { default: false })).toBe(false)
62
- expect(resolveMdibarShow(undefined, true)).toBe(false)
63
- })
64
-
65
- it('the stored choice wins once it exists', () => {
66
- expect(resolveMdibarShow(false, { default: true })).toBe(false)
67
- expect(resolveMdibarShow(true, true)).toBe(true)
68
- expect(resolveMdibarShow(true, { default: false })).toBe(true)
69
- })
70
-
71
- it('setupAppToolPart uses that one rule instead of writing its own', () => {
72
- const code = readFileSync(path.resolve(__dirname, '../client/index.ts'), 'utf-8')
73
-
74
- expect(code).toMatch(/const show = resolveMdibarShow\(stored, mdibar\)/)
75
- expect(code).not.toMatch(/stored === undefined \? fallback : stored/)
76
- })
77
- })
78
- })
@@ -1,36 +0,0 @@
1
- import { readFileSync } from 'fs'
2
- import path from 'path'
3
-
4
- import { mdibarStandsAside } from '../client/layout/mdibar-visibility'
5
-
6
- /**
7
- * A page can ask the MDI tab bar to stand aside while it is active (ADR-0060 decision 4). Shop-floor
8
- * screens do; every other page keeps the bar.
9
- *
10
- * These check the decision and that the bar is wired to it. Whether `hidden` actually lands on the
11
- * element is a screen check: hidden on a shop-floor page, back on the next page, still off for a user
12
- * who turned the bar off in settings.
13
- */
14
-
15
- describe('mdibar stands aside', () => {
16
- it('only for a page that says mdibar: false', () => {
17
- expect(mdibarStandsAside({ mdibar: false })).toBe(true)
18
- })
19
-
20
- it('★ not for a page that says nothing, so leaving a shop-floor page brings the bar back', () => {
21
- expect(mdibarStandsAside({ title: 'work orders' } as never)).toBe(false)
22
- expect(mdibarStandsAside({})).toBe(false)
23
- expect(mdibarStandsAside(undefined)).toBe(false)
24
- expect(mdibarStandsAside(null)).toBe(false)
25
- expect(mdibarStandsAside({ mdibar: true })).toBe(false)
26
- })
27
-
28
- it('the bar reads it on every update and hides itself, leaving the user setting alone', () => {
29
- const code = readFileSync(path.resolve(__dirname, '../client/layout/page-mdibar.ts'), 'utf-8')
30
-
31
- expect(code).toMatch(/willUpdate\(\) \{[^}]*this\.hidden = mdibarStandsAside\(this\._routeCtrl\.context\)/)
32
- expect(code).toMatch(/:host\(\[hidden\]\) \{\s*display: none;/)
33
- expect(code).not.toMatch(/updateViewpart\(/)
34
- expect(code).not.toMatch(/clientSettingStore/)
35
- })
36
- })