@things-factory/scheduler 10.1.38 → 10.1.39

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/scheduler",
3
- "version": "10.1.38",
3
+ "version": "10.1.39",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -27,11 +27,12 @@
27
27
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration"
28
28
  },
29
29
  "dependencies": {
30
+ "@operato/data-grist": "^10.19.0",
30
31
  "@operato/graphql": "^10.0.0",
31
32
  "@operato/shell": "^10.0.0",
32
- "@things-factory/auth-base": "^10.1.38",
33
- "@things-factory/scheduler-client": "^10.1.38",
34
- "@things-factory/shell": "^10.1.38"
33
+ "@things-factory/auth-base": "^10.1.39",
34
+ "@things-factory/scheduler-client": "^10.1.39",
35
+ "@things-factory/shell": "^10.1.39"
35
36
  },
36
- "gitHead": "b947349fe1c27d11038b592ceadaba336f14785b"
37
+ "gitHead": "fe5257ad8995fe7e79275e287f36e95b5fd32d1c"
37
38
  }
@@ -0,0 +1,64 @@
1
+ import { readFileSync } from 'fs'
2
+ import { join } from 'path'
3
+
4
+ import { selectSchedules } from '../server/service/schedule/select-schedules'
5
+
6
+ /*
7
+ * The schedule list's title bar search used to be dropped: the door read only its named filters, so
8
+ * the term came back as the whole list, and the reader took it for "nothing like that here".
9
+ */
10
+
11
+ const schedules = [
12
+ {
13
+ name: 'nightly-close',
14
+ client: { application: 'operato-plant', group: 'mes', type: 'batch', key: 'k1', operation: 'close' }
15
+ },
16
+ {
17
+ name: 'hourly-sync',
18
+ client: { application: 'operato-twin', group: 'mirror', type: 'poll', key: 'k2', operation: 'sync' }
19
+ },
20
+ {
21
+ name: 'kpi-rollup',
22
+ client: { application: 'operato-plant', group: 'kpi', type: 'batch', key: 'k3', operation: 'rollup' }
23
+ }
24
+ ]
25
+
26
+ const names = (result: { items: any[] }) => result.items.map(schedule => schedule.name)
27
+
28
+ describe('selectSchedules', () => {
29
+ it('finds a schedule by its name', () => {
30
+ expect(names(selectSchedules(schedules, { search: 'HOURLY' }))).toEqual(['hourly-sync'])
31
+ })
32
+
33
+ it('finds a schedule by who registered it', () => {
34
+ expect(names(selectSchedules(schedules, { search: 'twin' }))).toEqual(['hourly-sync'])
35
+ expect(names(selectSchedules(schedules, { search: 'rollup' }))).toEqual(['kpi-rollup'])
36
+ })
37
+
38
+ it('narrows the named filters further, not instead of them', () => {
39
+ const result = selectSchedules(schedules, {
40
+ search: 'batch',
41
+ filters: [
42
+ { name: 'application', operator: 'i_like', value: 'plant' },
43
+ { name: 'group', operator: 'i_like', value: 'kpi' }
44
+ ]
45
+ })
46
+ expect(names(result)).toEqual(['kpi-rollup'])
47
+ })
48
+
49
+ it('answers the whole list for no term, or one of spaces', () => {
50
+ expect(selectSchedules(schedules, {}).total).toBe(3)
51
+ expect(selectSchedules(schedules, { search: ' ' }).total).toBe(3)
52
+ })
53
+
54
+ it('counts what matched, not what fits on the page', () => {
55
+ const result = selectSchedules(schedules, { search: 'operato', pagination: { page: 2, limit: 2 } })
56
+ expect(result.total).toBe(3)
57
+ expect(names(result)).toEqual(['kpi-rollup'])
58
+ })
59
+
60
+ it('is what the door answers with', () => {
61
+ const door = readFileSync(join(__dirname, '../server/service/schedule/schedule-query.ts'), 'utf-8')
62
+ expect(door).toMatch(/return selectSchedules\(await getSchedules\(\{\}\), params\)/)
63
+ })
64
+ })