@things-factory/board-service 10.1.243 → 10.1.245

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/board-service",
3
- "version": "10.1.243",
3
+ "version": "10.1.245",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -25,14 +25,14 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@hatiolab/things-scene": "^10.1.104",
28
- "@things-factory/auth-base": "^10.1.241",
28
+ "@things-factory/auth-base": "^10.1.245",
29
29
  "@things-factory/env": "^10.1.149",
30
- "@things-factory/fav-base": "^10.1.241",
31
- "@things-factory/font-base": "^10.1.241",
32
- "@things-factory/integration-base": "^10.1.243",
30
+ "@things-factory/fav-base": "^10.1.245",
31
+ "@things-factory/font-base": "^10.1.245",
32
+ "@things-factory/integration-base": "^10.1.245",
33
33
  "@things-factory/operato-license-checker": "^4.0.4",
34
34
  "content-disposition": "^0.5.3",
35
35
  "pdfjs-dist": "^5.0.375"
36
36
  },
37
- "gitHead": "70a77f8a032f297a9d756ad530d3072e7a6c4bed"
37
+ "gitHead": "f7479631094a1c70b486485b556885b069025f88"
38
38
  }
@@ -0,0 +1,53 @@
1
+ import { join } from 'path'
2
+
3
+ /**
4
+ * The board list's type and state chips say how many boards each would show, in the list's scope (every board, the
5
+ * caller's favorites, the caller's own), under the list's other conditions - the chip's own field left out.
6
+ */
7
+
8
+ const { createSqliteTestDataSource } = require(join(__dirname, '..', '..', 'ops-master', 'test', 'support', 'database.cjs'))
9
+ const DIST = join(__dirname, '..', 'dist-server')
10
+ const { Board } = require(join(DIST, 'service', 'board', 'board.js'))
11
+ const { boardCounts } = require(join(DIST, 'service', 'board', 'board-counts.js'))
12
+ const { Favorite } = require('@things-factory/fav-base')
13
+ const { User } = require('@things-factory/auth-base')
14
+ const shell = require('@things-factory/shell')
15
+
16
+ let db: any
17
+ let here: any
18
+ let me: any
19
+ let other: any
20
+
21
+ beforeAll(async () => {
22
+ db = createSqliteTestDataSource([Board, Favorite, User])
23
+ await db.initialize()
24
+ shell.addDataSource('default', db)
25
+ here = await db.getRepository(shell.Domain).save({ name: 'counts', subdomain: 'counts' })
26
+ ;[me, other] = await db.getRepository(User).save([
27
+ { name: 'me', email: 'me@example.test' },
28
+ { name: 'other', email: 'other@example.test' }
29
+ ])
30
+ const boards = await db.getRepository(Board).save([
31
+ { domain: here, name: 'line A', type: 'main', state: 'released', creator: me, model: '{}' },
32
+ { domain: here, name: 'line B', type: 'main', state: 'draft', creator: other, model: '{}' },
33
+ { domain: here, name: 'popup C', type: 'popup', state: 'draft', creator: me, model: '{}' }
34
+ ])
35
+ await db.getRepository(Favorite).save({ domain: here, user: me, routing: boards[1].id })
36
+ })
37
+
38
+ afterAll(async () => {
39
+ await db?.destroy()
40
+ })
41
+
42
+ const counts = async (field: string, scope: string | null, params: any = {}) =>
43
+ Object.fromEntries((await boardCounts(here, me, field, scope, params)).map((one: any) => [one.value, one.count]))
44
+
45
+ test('★ each type is counted under the list’s other conditions, the type chosen left out', async () => {
46
+ expect(await counts('type', null, { filters: [{ name: 'type', operator: 'in', value: ['main'] }, { name: 'state', operator: 'in', value: ['draft'] }] })).toEqual({ main: 1, sub: 0, popup: 1 })
47
+ expect(await counts('state', null, { search: 'line' })).toEqual({ draft: 1, released: 1 })
48
+ })
49
+
50
+ test('★ the scope narrows the counts as it narrows the list - one’s favorites, one’s own', async () => {
51
+ expect(await counts('state', 'favor')).toEqual({ draft: 1, released: 0 })
52
+ expect(await counts('type', 'mywork')).toEqual({ main: 1, sub: 0, popup: 1 })
53
+ })