diff --git a/packages/plugins/openapi/tests/openapi-rpc.test.ts b/packages/plugins/openapi/tests/openapi-rpc.test.ts index f58b7fa09..845116ac3 100644 --- a/packages/plugins/openapi/tests/openapi-rpc.test.ts +++ b/packages/plugins/openapi/tests/openapi-rpc.test.ts @@ -4,7 +4,7 @@ import OpenAPIParser from '@readme/openapi-parser'; import { getLiteral, getObjectLiteral } from '@zenstackhq/sdk'; import { Model, Plugin, isPlugin } from '@zenstackhq/sdk/ast'; -import { loadZModelAndDmmf, normalizePath } from '@zenstackhq/testtools'; +import { loadSchema, loadZModelAndDmmf, normalizePath } from '@zenstackhq/testtools'; import fs from 'fs'; import path from 'path'; import * as tmp from 'tmp'; @@ -17,11 +17,13 @@ describe('Open API Plugin RPC Tests', () => { it('run plugin', async () => { for (const specVersion of ['3.0.0', '3.1.0']) { for (const omitInputDetails of [true, false]) { - const { model, dmmf, modelFile } = await loadZModelAndDmmf(` + const { projectDir } = await loadSchema( + ` plugin openapi { provider = '${normalizePath(path.resolve(__dirname, '../dist'))}' specVersion = '${specVersion}' omitInputDetails = ${omitInputDetails} + output = '$projectRoot/openapi.yaml' } enum role { @@ -89,18 +91,17 @@ model Bar { id String @id @@ignore } - `); - - const { name: output } = tmp.fileSync({ postfix: '.yaml' }); - - const options = buildOptions(model, modelFile, output); - await generate(model, options, dmmf); + `, + { provider: 'postgresql', pushDb: false } + ); console.log( - `OpenAPI specification generated for ${specVersion}${omitInputDetails ? ' - omit' : ''}: ${output}` + `OpenAPI specification generated for ${specVersion}${ + omitInputDetails ? ' - omit' : '' + }: ${projectDir}/openapi.yaml` ); - const parsed = YAML.parse(fs.readFileSync(output, 'utf-8')); + const parsed = YAML.parse(fs.readFileSync(path.join(projectDir, 'openapi.yaml'), 'utf-8')); expect(parsed.openapi).toBe(specVersion); const baseline = YAML.parse( fs.readFileSync( @@ -110,7 +111,7 @@ model Bar { ); expect(parsed).toMatchObject(baseline); - const api = await OpenAPIParser.validate(output); + const api = await OpenAPIParser.validate(path.join(projectDir, 'openapi.yaml')); expect(api.tags).toEqual( expect.arrayContaining([ diff --git a/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json b/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json index 179831693..342a2ef6f 100644 --- a/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json +++ b/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json @@ -13,7 +13,7 @@ "start": "next start" }, "dependencies": { - "@prisma/client": "^5.13.0", + "@prisma/client": "6.0.x", "@t3-oss/env-nextjs": "^0.7.1", "@tanstack/react-query": "^4.36.1", "@trpc/client": "^10.43.6", @@ -24,6 +24,7 @@ "react": "18.2.0", "react-dom": "18.2.0", "superjson": "^2.2.1", + "zenstack": "file:../../../../../../.build/zenstack-2.9.4.tgz", "zod": "^3.22.4" }, "devDependencies": { @@ -35,7 +36,7 @@ "@typescript-eslint/parser": "^6.11.0", "eslint": "^8.54.0", "eslint-config-next": "^14.0.4", - "prisma": "^5.13.0", + "prisma": "6.0.x", "typescript": "^5.5.4" }, "ct3aMetadata": { diff --git a/packages/server/tests/api/rest.test.ts b/packages/server/tests/api/rest.test.ts index 7367a4b64..2a59e6067 100644 --- a/packages/server/tests/api/rest.test.ts +++ b/packages/server/tests/api/rest.test.ts @@ -2701,7 +2701,7 @@ describe('REST server tests', () => { float: 1.23, decimal: decimalValue1, boolean: true, - bytes: Buffer.from([1, 2, 3, 4]), + bytes: new Uint8Array([1, 2, 3, 4]), }; const { json: createPayload, meta: createMeta } = SuperJSON.serialize({ @@ -2736,7 +2736,7 @@ describe('REST server tests', () => { let deserialized: any = SuperJSON.deserialize({ json: r.body, meta: serializationMeta }); let data = deserialized.data.attributes; expect(typeof data.bigInt).toBe('bigint'); - expect(Buffer.isBuffer(data.bytes)).toBeTruthy(); + expect(data.bytes).toBeInstanceOf(Uint8Array); expect(data.date instanceof Date).toBeTruthy(); expect(Decimal.isDecimal(data.decimal)).toBeTruthy(); @@ -2744,7 +2744,7 @@ describe('REST server tests', () => { bigInt: BigInt(1534543543534), date: new Date(), decimal: decimalValue2, - bytes: Buffer.from([5, 2, 3, 4]), + bytes: new Uint8Array([5, 2, 3, 4]), }; const { json: updatePayload, meta: updateMeta } = SuperJSON.serialize({ data: { @@ -2776,7 +2776,7 @@ describe('REST server tests', () => { expect(data.bigInt).toEqual(updateAttrs.bigInt); expect(data.date).toEqual(updateAttrs.date); expect(data.decimal.equals(updateAttrs.decimal)).toBeTruthy(); - expect(data.bytes.toString('base64')).toEqual(updateAttrs.bytes.toString('base64')); + expect(data.bytes.toString()).toEqual(updateAttrs.bytes.toString()); r = await handler({ method: 'get', @@ -2791,7 +2791,7 @@ describe('REST server tests', () => { deserialized = SuperJSON.deserialize({ json: r.body, meta: serializationMeta }); data = deserialized.data.attributes; expect(typeof data.bigInt).toBe('bigint'); - expect(Buffer.isBuffer(data.bytes)).toBeTruthy(); + expect(data.bytes).toBeInstanceOf(Uint8Array); expect(data.date instanceof Date).toBeTruthy(); expect(Decimal.isDecimal(data.decimal)).toBeTruthy(); @@ -2807,7 +2807,7 @@ describe('REST server tests', () => { expect(serializationMeta).toBeTruthy(); deserialized = SuperJSON.deserialize({ json: r.body, meta: serializationMeta }); const included = deserialized.included[0]; - expect(Buffer.isBuffer(included.attributes.bytes)).toBeTruthy(); + expect(included.attributes.bytes).toBeInstanceOf(Uint8Array); }); }); diff --git a/packages/server/tests/api/rpc.test.ts b/packages/server/tests/api/rpc.test.ts index 56ad8c5e0..ead12c033 100644 --- a/packages/server/tests/api/rpc.test.ts +++ b/packages/server/tests/api/rpc.test.ts @@ -304,8 +304,8 @@ describe('RPC API Handler Tests', () => { const decimalValue = new Decimal('0.046875'); const bigIntValue = BigInt(534543543534); const dateValue = new Date(); - const bufferValue = Buffer.from([1, 2, 3, 4]); - const barBufferValue = Buffer.from([7, 8, 9]); + const bytesValue = new Uint8Array([1, 2, 3, 4]); + const barBytesValue = new Uint8Array([7, 8, 9]); const createData = { string: 'string', @@ -315,9 +315,9 @@ describe('RPC API Handler Tests', () => { float: 1.23, decimal: decimalValue, boolean: true, - bytes: bufferValue, + bytes: bytesValue, bars: { - create: { bytes: barBufferValue }, + create: { bytes: barBytesValue }, }, }; @@ -342,10 +342,10 @@ describe('RPC API Handler Tests', () => { expect(r.meta).toBeTruthy(); const data: any = SuperJSON.deserialize({ json: r.data, meta: r.meta.serialization }); expect(typeof data.bigInt).toBe('bigint'); - expect(Buffer.isBuffer(data.bytes)).toBeTruthy(); + expect(data.bytes).toBeInstanceOf(Uint8Array); expect(data.date instanceof Date).toBeTruthy(); expect(Decimal.isDecimal(data.decimal)).toBeTruthy(); - expect(Buffer.isBuffer(data.bars[0].bytes)).toBeTruthy(); + expect(data.bars[0].bytes).toBeInstanceOf(Uint8Array); // find with filter not found const serializedQ = SuperJSON.serialize({ @@ -394,7 +394,7 @@ describe('RPC API Handler Tests', () => { where: { bars: { some: { - bytes: barBufferValue, + bytes: barBytesValue, }, }, }, @@ -418,7 +418,7 @@ describe('RPC API Handler Tests', () => { where: { bars: { none: { - bytes: barBufferValue, + bytes: barBytesValue, }, }, }, diff --git a/tests/integration/tests/e2e/type-coverage.test.ts b/tests/integration/tests/e2e/type-coverage.test.ts index 2a41b3ffd..659f36788 100644 --- a/tests/integration/tests/e2e/type-coverage.test.ts +++ b/tests/integration/tests/e2e/type-coverage.test.ts @@ -48,7 +48,7 @@ describe('Type Coverage Tests', () => { Float: 1.23, Decimal: new Decimal(1.2345), Boolean: true, - Bytes: Buffer.from('hello'), + Bytes: new Uint8Array([1, 2, 3, 4]), }; await db.foo.create({