@axinom/mosaic-graphql-common 0.31.0-rc.13 → 0.31.0-rc.16

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": "@axinom/mosaic-graphql-common",
3
- "version": "0.31.0-rc.13",
3
+ "version": "0.31.0-rc.16",
4
4
  "description": "Common GraphQL and PostGraphile related functionality.",
5
5
  "author": "Axinom",
6
6
  "license": "PROPRIETARY",
@@ -22,21 +22,22 @@
22
22
  "build:ci": "yarn workspaces focus && yarn build",
23
23
  "dev": "tsc -w --project tsconfig.build.json",
24
24
  "publish:latest": "npm run build && npm publish",
25
- "test": "jest --silent",
26
- "test:watch": "jest --watch --silent",
27
- "test:cov": "jest --coverage --silent && yarn posttest:cov",
25
+ "test": "vitest run --silent",
26
+ "test:watch": "vitest watch",
27
+ "test:cov": "vitest run --coverage --silent && yarn posttest:cov",
28
28
  "posttest:cov": "ts-node ../../scripts/open-test-coverage.ts -- libs/graphql-common",
29
- "test:debug": "node --inspect -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --silent",
30
- "test:ci": "jest --reporters=default --reporters=jest-junit --coverage --coverageReporters=cobertura --coverageReporters=html",
29
+ "test:debug": "vitest run --inspect-brk --no-file-parallelism",
30
+ "test:ci": "vitest run --reporter=default --reporter=junit --coverage --coverage.reporter=cobertura --coverage.reporter=html",
31
+ "test:ui": "vitest --ui",
31
32
  "lint": "eslint . --ext .ts,.tsx,.js --color --cache"
32
33
  },
33
34
  "dependencies": {
34
- "@axinom/mosaic-db-common": "^0.55.0-rc.13",
35
- "@axinom/mosaic-message-bus": "^0.48.0-rc.13",
36
- "@axinom/mosaic-message-bus-abstractions": "^0.24.1-rc.5",
37
- "@axinom/mosaic-messages": "^0.65.0-rc.13",
38
- "@axinom/mosaic-service-common": "^0.67.0-rc.13",
39
- "@axinom/mosaic-transactional-inbox-outbox": "^0.27.0-rc.13",
35
+ "@axinom/mosaic-db-common": "^0.55.0-rc.16",
36
+ "@axinom/mosaic-message-bus": "^0.48.0-rc.16",
37
+ "@axinom/mosaic-message-bus-abstractions": "^0.24.1-rc.8",
38
+ "@axinom/mosaic-messages": "^0.65.0-rc.16",
39
+ "@axinom/mosaic-service-common": "^0.67.0-rc.16",
40
+ "@axinom/mosaic-transactional-inbox-outbox": "^0.27.0-rc.16",
40
41
  "@graphile/pg-pubsub": "^4.12.3",
41
42
  "endent": "^2.1.0",
42
43
  "express": "^4.17.1",
@@ -45,26 +46,25 @@
45
46
  "graphile-utils": "^4.13.0",
46
47
  "graphql": "^15.4.0",
47
48
  "inflection": "^1.12.0",
48
- "jest": "^29",
49
- "jest-expect-message": "^1.1.3",
50
49
  "pg": "^8.11.3",
51
50
  "pg-transactional-outbox": "^0.6.4",
52
51
  "postgraphile": "^4.13.0"
53
52
  },
54
53
  "devDependencies": {
55
- "@axinom/mosaic-dev-be-common": "^0.15.1-rc.5",
54
+ "@axinom/mosaic-dev-be-common": "^0.16.0-rc.1",
56
55
  "@types/express": "^4.17.17",
57
56
  "@types/inflection": "^1.5.28",
58
- "@types/jest": "^29",
59
- "@types/jest-expect-message": "^1.1.0",
60
57
  "@types/node": "^22.0.0",
58
+ "@vitest/ui": "^4.0.18",
61
59
  "eslint": "^8.35.0",
60
+ "jest-extended": "^7.0.0",
62
61
  "rimraf": "^3.0.2",
63
62
  "ts-node": "^10.9.1",
64
- "typescript": "^5.9.3"
63
+ "typescript": "^5.9.3",
64
+ "vitest": "^4.0.18"
65
65
  },
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "gitHead": "40779318c9b091b23a3aa559734727df3e903741"
69
+ "gitHead": "61cc0e626bb816beee81d16b31c46f1d2a13844d"
70
70
  }
@@ -1,4 +1,4 @@
1
- import 'jest-extended';
1
+ import { describe, expect, it } from 'vitest';
2
2
  import { exportedForTestingAnnotatePlugin } from './annotate-types-with-permissions-plugin';
3
3
  const getPolicy = (
4
4
  overrides: {
@@ -1,27 +1,35 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+
3
+ // Mock the dependencies
4
+ vi.mock('@axinom/mosaic-db-common', async () => {
5
+ const actual = await vi.importActual<
6
+ typeof import('@axinom/mosaic-db-common')
7
+ >('@axinom/mosaic-db-common');
8
+ return {
9
+ ...actual,
10
+ buildPgSettings: vi.fn(() => ({
11
+ role: 'test_role',
12
+ 'mosaic.subject': 'test_user',
13
+ })),
14
+ transactionWithContext: vi.fn(
15
+ async (_pool, _isolationLevel, _pgSettings, callback) => {
16
+ // Execute the callback with a mock transaction client
17
+ const mockTxn = {} as DatabaseClient;
18
+ await callback(mockTxn);
19
+ },
20
+ ),
21
+ };
22
+ });
23
+
1
24
  import { PerformItemChangeCommand } from '@axinom/mosaic-messages';
2
25
  import { StoreInboxMessage } from '@axinom/mosaic-transactional-inbox-outbox';
3
26
  import { DatabaseClient } from 'pg-transactional-outbox';
4
27
  import { asyncResolverImplementation } from './bulk-edit-async-plugin-factory';
5
28
 
6
- // Mock the dependencies
7
- jest.mock('@axinom/mosaic-db-common', () => ({
8
- buildPgSettings: jest.fn(() => ({
9
- role: 'test_role',
10
- 'mosaic.subject': 'test_user',
11
- })),
12
- transactionWithContext: jest.fn(
13
- async (_pool, _isolationLevel, _pgSettings, callback) => {
14
- // Execute the callback with a mock transaction client
15
- const mockTxn = {} as DatabaseClient;
16
- await callback(mockTxn);
17
- },
18
- ),
19
- }));
20
-
21
29
  describe('bulk-edit-async-plugin-factory', () => {
22
30
  describe('asyncResolverImplementation', () => {
23
31
  let capturedMessages: PerformItemChangeCommand[];
24
- let mockStoreInboxMessage: jest.MockedFunction<StoreInboxMessage>;
32
+ let mockStoreInboxMessage: StoreInboxMessage;
25
33
  let mockOwnerPool: any;
26
34
  let mockEnvOwnerPool: any;
27
35
  let mockConfig: any;
@@ -31,19 +39,15 @@ describe('bulk-edit-async-plugin-factory', () => {
31
39
  capturedMessages = [];
32
40
 
33
41
  // Mock storeInboxMessage to capture messages
34
- mockStoreInboxMessage = jest
35
- .fn()
36
- .mockImplementation(
37
- async (
38
- _aggregateId: string,
39
- _messageSettings: any,
40
- payload: PerformItemChangeCommand,
41
- _client: DatabaseClient,
42
- _options?: any,
43
- ) => {
44
- capturedMessages.push(payload);
45
- },
46
- );
42
+ mockStoreInboxMessage = async <T>(
43
+ _aggregateId: string,
44
+ _messageSettings: any,
45
+ payload: T,
46
+ _client: DatabaseClient,
47
+ _options?: any,
48
+ ) => {
49
+ capturedMessages.push(payload as PerformItemChangeCommand);
50
+ };
47
51
 
48
52
  mockOwnerPool = {};
49
53
  mockEnvOwnerPool = {};
@@ -58,10 +62,6 @@ describe('bulk-edit-async-plugin-factory', () => {
58
62
  };
59
63
  });
60
64
 
61
- afterEach(() => {
62
- jest.clearAllMocks();
63
- });
64
-
65
65
  describe('SET_FIELD_VALUES action', () => {
66
66
  it('should generate SET_FIELD_VALUES message with correct structure', async () => {
67
67
  // Arrange
@@ -1,10 +1,11 @@
1
1
  import { PerformItemChangeCommand } from '@axinom/mosaic-messages';
2
2
  import { ClientBase, QueryResult } from 'pg';
3
+ import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest';
3
4
  import { handlePerformItemChangeCommand } from './bulk-edit-item-change-handler-helpers';
4
5
 
5
6
  describe('bulk-edit-item-change-handler-helpers', () => {
6
7
  let mockClient: ClientBase;
7
- let mockQuery: jest.MockedFunction<
8
+ let mockQuery: Mock<
8
9
  (queryText: string, values?: any[]) => Promise<QueryResult>
9
10
  >;
10
11
 
@@ -18,16 +19,12 @@ describe('bulk-edit-item-change-handler-helpers', () => {
18
19
  });
19
20
 
20
21
  beforeEach(() => {
21
- mockQuery = jest.fn().mockResolvedValue(createQueryResult([]));
22
+ mockQuery = vi.fn().mockResolvedValue(createQueryResult([]));
22
23
  mockClient = {
23
24
  query: mockQuery,
24
25
  } as unknown as ClientBase;
25
26
  });
26
27
 
27
- afterEach(() => {
28
- jest.restoreAllMocks();
29
- });
30
-
31
28
  describe('handlePerformItemChangeCommand', () => {
32
29
  describe('SET_FIELD_VALUES action', () => {
33
30
  it('should update main entity fields', async () => {
@@ -1,5 +1,5 @@
1
1
  import { GraphQLError, Source } from 'graphql';
2
- import 'jest-extended';
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
3
3
  import {
4
4
  GeneralGraphQlErrorCode,
5
5
  GraphQlOperation,
@@ -12,7 +12,7 @@ const UNIT_TEST_ERROR = 'UNIT_TEST_ERROR';
12
12
 
13
13
  describe('graphqlErrorHandler', () => {
14
14
  let timestampBeforeTest: Date;
15
- const mockLog = jest.fn();
15
+ const mockLog = vi.fn();
16
16
  const dateAfterTestStart = (received: string | Date): void => {
17
17
  const parsedDate = new Date(received).getTime();
18
18
  expect(parsedDate).toBeGreaterThanOrEqual(timestampBeforeTest.getTime());
@@ -24,10 +24,6 @@ describe('graphqlErrorHandler', () => {
24
24
  timestampBeforeTest = date;
25
25
  });
26
26
 
27
- afterEach(async () => {
28
- jest.restoreAllMocks();
29
- });
30
-
31
27
  it('minimal internal server error -> valid response', async () => {
32
28
  // Arrange
33
29
  const gqlError = new GraphQLError(
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable no-console */
2
- import { stub } from '@axinom/mosaic-dev-be-common';
2
+ import { stub } from '@axinom/mosaic-dev-be-common/vitest';
3
3
  import PgPubsub from '@graphile/pg-pubsub';
4
4
  import { Request, Response } from 'express';
5
5
  import { MutationPayloadQueryPlugin, NodePlugin } from 'graphile-build';
6
- import 'jest-extended';
7
6
  import { Pool } from 'pg';
8
7
  import { Plugin, PostGraphilePlugin } from 'postgraphile';
8
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
9
9
  import { Dict } from '../common';
10
10
  import {
11
11
  AnnotateTypesWithPermissionsPlugin,
@@ -21,13 +21,13 @@ describe('RascalConfigBuilder', () => {
21
21
  let req: Request & { token: string };
22
22
  let res: Response;
23
23
  let headers: Dict<string> = {};
24
- beforeEach(async () => {
24
+ beforeEach(() => {
25
25
  req = stub<Request & { token: string }>({ token: 'test-jwt-token-string' });
26
26
  res = stub<Response>({
27
27
  setHeader: (key: string, val: string) => (headers[key] = val),
28
28
  });
29
29
  });
30
- afterEach(async () => {
30
+ afterEach(() => {
31
31
  headers = {};
32
32
  });
33
33
  describe('build', () => {