@operato/layout 10.29.67 → 10.29.69

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/layout",
3
3
  "description": "Webcomponent layout following open-wc recommendations",
4
4
  "author": "heartyoh",
5
- "version": "10.29.67",
5
+ "version": "10.29.69",
6
6
  "type": "module",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
@@ -67,12 +67,13 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "@material/web": "^2.0.0",
70
+ "@operato/graphql": "^10.29.69",
70
71
  "@operato/i18n": "^10.29.27",
71
- "@operato/input": "^10.29.67",
72
- "@operato/popup": "^10.29.61",
73
- "@operato/shell": "^10.29.61",
74
- "@operato/styles": "^10.29.61",
75
- "@operato/utils": "^10.29.61",
72
+ "@operato/input": "^10.29.69",
73
+ "@operato/popup": "^10.29.69",
74
+ "@operato/shell": "^10.29.69",
75
+ "@operato/styles": "^10.29.69",
76
+ "@operato/utils": "^10.29.69",
76
77
  "lit": "^3.1.2"
77
78
  },
78
79
  "devDependencies": {
@@ -107,5 +108,5 @@
107
108
  "prettier --write"
108
109
  ]
109
110
  },
110
- "gitHead": "cd6c3fd780bbfd658cdf48086fa4bfcf7f745883"
111
+ "gitHead": "b2054a02e73f7ee2bc3834c89ac61b5ef4d533bf"
111
112
  }
@@ -0,0 +1,25 @@
1
+ import { expect } from '@open-wc/testing'
2
+
3
+ import { entity360Answer } from '../src/actions/entity360-door.js'
4
+
5
+ /** A section that declared its query (ADR-0190) comes to rest in one of the four states, as a door's answer does. */
6
+ describe('entity360Answer', () => {
7
+ const pick = (data: any) => data?.invoice
8
+
9
+ it('is undefined while the query first reads, and keeps what it holds while it reads again', () => {
10
+ expect(entity360Answer({ loading: true }, pick)).to.equal(undefined)
11
+ expect(entity360Answer({ loading: false }, pick)).to.equal(undefined)
12
+ expect(entity360Answer({ loading: true, data: { invoice: { id: 'a' } } }, pick)).to.deep.equal({ state: 'ready', data: { id: 'a' } })
13
+ })
14
+
15
+ it('is ready, or none when the door holds nothing', () => {
16
+ expect(entity360Answer({ loading: false, data: { invoice: { id: 'a' } } }, pick)).to.deep.equal({ state: 'ready', data: { id: 'a' } })
17
+ expect(entity360Answer({ loading: false, data: { invoice: null } }, pick)).to.deep.equal({ state: 'none', data: null })
18
+ })
19
+
20
+ it('keeps a refusal forbidden, and a request that threw failed with its message', () => {
21
+ const refused = { graphQLErrors: [{ message: 'no', extensions: { code: 'FORBIDDEN' } }] }
22
+ expect(entity360Answer({ loading: false, error: refused }, pick)).to.deep.equal({ state: 'forbidden' })
23
+ expect(entity360Answer({ loading: false, error: new TypeError('Failed to fetch') }, pick)).to.deep.equal({ state: 'failed', message: 'Failed to fetch' })
24
+ })
25
+ })
@@ -11,10 +11,10 @@ import {
11
11
  registerEntity360Kind,
12
12
  registerEntity360Section,
13
13
  setEntity360Value,
14
- ENTITY360_UNKEPT,
15
14
  type Entity360Subject,
16
15
  type OxEntity360Dock
17
16
  } from '../src/index.js'
17
+ import { DRAFT_UNKEPT } from '@operato/shell'
18
18
 
19
19
  /**
20
20
  * A 360 opened by kind and id, the dock's own back trail, and the assistant subject it stands in for.
@@ -251,7 +251,7 @@ describe('entity 360 by kind', () => {
251
251
  openEntity360Kind('kx-lot', { id: 'L-3', name: 'L-3' })
252
252
  await settle()
253
253
  const input = section().querySelector('input')!
254
- input.dispatchEvent(new CustomEvent(ENTITY360_UNKEPT, { bubbles: true, composed: true, detail: { unkept: true } }))
254
+ input.dispatchEvent(new CustomEvent(DRAFT_UNKEPT, { bubbles: true, composed: true, detail: { unkept: true } }))
255
255
 
256
256
  openEntity360Kind('kx-lot', { id: 'L-4', name: 'L-4' })
257
257
  await settle()
@@ -1,7 +1,7 @@
1
1
  import { expect, fixture } from '@open-wc/testing'
2
2
  import { html } from 'lit'
3
3
  import '../src/index.js'
4
- import { askEntity360Door, Entity360Reads, readEntity360Door, type OxEntity360Section } from '../src/index.js'
4
+ import { askEntity360Door, readEntity360Door, type OxEntity360Section } from '../src/index.js'
5
5
 
6
6
  /**
7
7
  * A 360 section says what its door answered (ADR-0067): something, nothing, may-not-see, or failed.
@@ -21,24 +21,6 @@ describe('entity 360 door', () => {
21
21
  expect((await askEntity360Door(Promise.reject(thrown), d => d?.items)).state).to.equal('forbidden')
22
22
  })
23
23
 
24
- it('★ only the newest read answers - a second read of the same id drops the first', async () => {
25
- const reads = new Entity360Reads()
26
- let release!: (value: any) => void
27
- const first = reads.ask(() => new Promise(resolve => (release = resolve)), d => d.items)
28
- const second = reads.ask(() => Promise.resolve({ data: { items: [2] } }), d => d.items)
29
- release({ data: { items: [1] } })
30
- expect(await first).to.equal(undefined)
31
- expect((await second)?.data).to.deep.equal([2])
32
- })
33
-
34
- it('a read that throws synchronously still ends failed; forget drops one on its way', async () => {
35
- const reads = new Entity360Reads()
36
- expect((await reads.ask(() => { throw new Error('no client') }, d => d))?.state).to.equal('failed')
37
- const pending = reads.ask(() => Promise.resolve({ data: { items: [1] } }), d => d.items)
38
- reads.forget()
39
- expect(await pending).to.equal(undefined)
40
- })
41
-
42
24
  it('a request that answers is read as readEntity360Door reads it', async () => {
43
25
  expect((await askEntity360Door(Promise.resolve({ data: { items: [] } }), d => d.items)).state).to.equal('none')
44
26
  expect((await askEntity360Door(Promise.resolve({ data: { items: [1] } }), d => d.items)).data).to.deep.equal([1])
@@ -1,7 +1,8 @@
1
1
  import { expect, fixture, elementUpdated } from '@open-wc/testing'
2
2
  import { html } from 'lit'
3
3
  import '../src/index.js'
4
- import { showEntity360, hideEntity360, isEntity360Unkept, navigateEntity360, canGoBackEntity360, ENTITY360_UNKEPT, type OxEntity360Dock, type Entity360View } from '../src/index.js'
4
+ import { showEntity360, hideEntity360, isEntity360Unkept, navigateEntity360, canGoBackEntity360, type OxEntity360Dock, type Entity360View } from '../src/index.js'
5
+ import { DRAFT_UNKEPT } from '@operato/shell'
5
6
 
6
7
  const owner = {}
7
8
  const labels = { close: 'Close', expand: 'Expand', collapse: 'Collapse', resize: 'Resize', back: 'Back' }
@@ -67,7 +68,7 @@ describe('shared nonmodal entity 360 dock', () => {
67
68
  await settle()
68
69
  const content = dock().shadowRoot!.querySelector('ox-entity360-content') as HTMLElement
69
70
  const input = content.shadowRoot!.querySelector('input')!
70
- const tell = (unkept: boolean) => input.dispatchEvent(new CustomEvent(ENTITY360_UNKEPT, { bubbles: true, composed: true, detail: { unkept } }))
71
+ const tell = (unkept: boolean) => input.dispatchEvent(new CustomEvent(DRAFT_UNKEPT, { bubbles: true, composed: true, detail: { unkept } }))
71
72
  expect(isEntity360Unkept(owner)).to.equal(false)
72
73
  tell(true)
73
74
  expect(isEntity360Unkept(owner)).to.equal(true)