@operato/form 10.29.41 → 10.29.43

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/form",
3
3
  "description": "WebApplication form supporting components following open-wc recommendations",
4
4
  "author": "heartyoh",
5
- "version": "10.29.41",
5
+ "version": "10.29.43",
6
6
  "type": "module",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
@@ -59,12 +59,12 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@material/web": "^2.0.0",
62
- "@operato/graphql": "^10.29.39",
63
- "@operato/input": "^10.29.41",
64
- "@operato/p13n": "^10.29.40",
62
+ "@operato/graphql": "^10.29.43",
63
+ "@operato/input": "^10.29.43",
64
+ "@operato/p13n": "^10.29.43",
65
65
  "@operato/styles": "^10.29.30",
66
66
  "@operato/time-calculator": "^10.29.1",
67
- "@operato/utils": "^10.29.39",
67
+ "@operato/utils": "^10.29.43",
68
68
  "lit": "^3.1.2"
69
69
  },
70
70
  "devDependencies": {
@@ -100,5 +100,5 @@
100
100
  "prettier --write"
101
101
  ]
102
102
  },
103
- "gitHead": "198aa1d3eb4bf66de898554f52e57ca0b0905911"
103
+ "gitHead": "ccc06fed313fcc20a076a1cf7bc586fdacaba594"
104
104
  }
@@ -0,0 +1,48 @@
1
+ import { expect, fixture, waitUntil } from '@open-wc/testing'
2
+ import { html } from 'lit'
3
+ import { decodeListQuery } from '@operato/utils/list-query.js'
4
+ import '../src/filters/ox-filters-form-base.js'
5
+ import type { OxFiltersFormBase } from '../src/filters/ox-filters-form-base.js'
6
+
7
+ describe('the shape of what a filters form sends', () => {
8
+ it('a list operator with one choice sends a one-element list, like the grid form', async () => {
9
+ const form = await fixture<OxFiltersFormBase>(html`
10
+ <ox-filters-form-base .filters=${[{ name: 'kind', type: 'text', operator: 'in', label: 'kind' }]}></ox-filters-form-base>
11
+ `)
12
+ await form.updateComplete
13
+ const input = form.renderRoot.querySelector('input[name=kind]') as HTMLInputElement
14
+ input.value = 'a'
15
+ expect(await form.getQueryFilters()).to.deep.equal([{ name: 'kind', operator: 'in', value: ['a'] }])
16
+ })
17
+ })
18
+
19
+ describe('an address-bound filters form', () => {
20
+ afterEach(() => history.replaceState(history.state, '', location.pathname))
21
+
22
+ it('writes the conditions its fields hold and tells the page once they are committed', async () => {
23
+ const told: { filters: unknown; from: string }[] = []
24
+ const holder = await fixture<HTMLElement>(html`
25
+ <div @filters-change=${(e: CustomEvent) => told.push(e.detail)}>
26
+ <ox-filters-form-base
27
+ url-params-sensitive
28
+ .filters=${[{ name: 'code', type: 'text', operator: 'eq', label: 'code' }]}
29
+ ></ox-filters-form-base>
30
+ </div>
31
+ `)
32
+ const form = holder.querySelector('ox-filters-form-base') as OxFiltersFormBase
33
+ await form.updateComplete
34
+ const input = form.renderRoot.querySelector('input[name=code]') as HTMLInputElement
35
+ input.value = 'A-1'
36
+ input.dispatchEvent(new Event('change', { bubbles: true, composed: true }))
37
+
38
+ await waitUntil(() => new URLSearchParams(location.search).get('filters') !== null, 'address not written')
39
+ expect(decodeListQuery(location.search).filters).to.deep.equal([
40
+ { name: 'code', operator: 'eq', value: 'A-1' }
41
+ ])
42
+ await waitUntil(() => told.length > 0, 'page never told')
43
+ expect(told[told.length - 1]).to.deep.equal({
44
+ filters: [{ name: 'code', operator: 'eq', value: 'A-1' }],
45
+ from: 'url-parameter'
46
+ })
47
+ })
48
+ })