From e760b561356ddf191847866f4af9e6a9bb7cb708 Mon Sep 17 00:00:00 2001 From: Eric Wittmann Date: Tue, 12 Nov 2024 12:11:29 -0500 Subject: [PATCH] Add tests for the typescript SDK --- .github/workflows/integration-tests.yaml | 28 +- typescript-sdk/package-lock.json | 377 ++++++++++++++++++++++- typescript-sdk/package.json | 7 +- typescript-sdk/tests/artifact.test.ts | 87 ++++++ typescript-sdk/tests/group.test.ts | 21 ++ typescript-sdk/tests/system-info.test.ts | 10 + typescript-sdk/tests/test.utils.ts | 16 + typescript-sdk/tsconfig.json | 2 +- 8 files changed, 528 insertions(+), 20 deletions(-) create mode 100644 typescript-sdk/tests/artifact.test.ts create mode 100644 typescript-sdk/tests/group.test.ts create mode 100644 typescript-sdk/tests/system-info.test.ts create mode 100644 typescript-sdk/tests/test.utils.ts diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 7a6e029de3..f441785566 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -310,17 +310,6 @@ jobs: path: ui/tests/playwright-report/ retention-days: 30 - - name: Collect logs - if: failure() - run: sh ./.github/scripts/collect_logs.sh - - - name: Upload tests logs artifacts - if: failure() - uses: actions/upload-artifact@v3 - with: - name: tests-logs-ui - path: artifacts - integration-tests-legacy-v2: name: Integration Tests Legacy V2 runs-on: ubuntu-22.04 @@ -359,6 +348,23 @@ jobs: name: tests-logs-legacy-v2 path: artifacts + integration-tests-typescript-sdk: + name: Integration Tests Typescript SDK + runs-on: ubuntu-22.04 + needs: prepare-integration-tests + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Run SDK tests + run: | + echo "Starting Registry App (In Memory)" + docker run -it -p 8080:8080 -e apicurio.rest.deletion.artifact.enabled=true -d ttl.sh/${{ github.sha }}/apicurio/apicurio-registry:1d + + cd typescript-sdk + npm install + npm run test + build-examples: name: Build and Run Application examples runs-on: ubuntu-22.04 diff --git a/typescript-sdk/package-lock.json b/typescript-sdk/package-lock.json index ebed4debe0..54f6fb37a4 100644 --- a/typescript-sdk/package-lock.json +++ b/typescript-sdk/package-lock.json @@ -25,8 +25,10 @@ "react-router-dom": "6.27.0", "rimraf": "5.0.10", "typescript": "5.6.3", + "uuid": "11.0.3", "vite": "5.4.10", - "vite-plugin-dts": "4.3.0" + "vite-plugin-dts": "4.3.0", + "vitest": "2.1.4" }, "peerDependencies": { "@microsoft/kiota-abstractions": "1.0.0-preview.68", @@ -830,6 +832,19 @@ "uuid": "^10.0.0" } }, + "node_modules/@microsoft/kiota-abstractions/node_modules/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "peer": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@microsoft/kiota-http-fetchlibrary": { "version": "1.0.0-preview.67", "resolved": "https://registry.npmjs.org/@microsoft/kiota-http-fetchlibrary/-/kiota-http-fetchlibrary-1.0.0-preview.67.tgz", @@ -1493,6 +1508,121 @@ "vite": "^4.2.0 || ^5.0.0" } }, + "node_modules/@vitest/expect": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.4.tgz", + "integrity": "sha512-DOETT0Oh1avie/D/o2sgMHGrzYUFFo3zqESB2Hn70z6QB1HrS2IQ9z5DfyTqU8sg4Bpu13zZe9V4+UTNQlUeQA==", + "dev": true, + "dependencies": { + "@vitest/spy": "2.1.4", + "@vitest/utils": "2.1.4", + "chai": "^5.1.2", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-2.1.4.tgz", + "integrity": "sha512-Ky/O1Lc0QBbutJdW0rqLeFNbuLEyS+mIPiNdlVlp2/yhJ0SbyYqObS5IHdhferJud8MbbwMnexg4jordE5cCoQ==", + "dev": true, + "dependencies": { + "@vitest/spy": "2.1.4", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.12" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^5.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/mocker/node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/@vitest/pretty-format": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.1.4.tgz", + "integrity": "sha512-L95zIAkEuTDbUX1IsjRl+vyBSLh3PwLLgKpghl37aCK9Jvw0iP+wKwIFhfjdUtA2myLgjrG6VU6JCFLv8q/3Ww==", + "dev": true, + "dependencies": { + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.1.4.tgz", + "integrity": "sha512-sKRautINI9XICAMl2bjxQM8VfCMTB0EbsBc/EDFA57V6UQevEKY/TOPOF5nzcvCALltiLfXWbq4MaAwWx/YxIA==", + "dev": true, + "dependencies": { + "@vitest/utils": "2.1.4", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.1.4.tgz", + "integrity": "sha512-3Kab14fn/5QZRog5BPj6Rs8dc4B+mim27XaKWFWHWA87R56AKjHTGcBFKpvZKDzC4u5Wd0w/qKsUIio3KzWW4Q==", + "dev": true, + "dependencies": { + "@vitest/pretty-format": "2.1.4", + "magic-string": "^0.30.12", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.4.tgz", + "integrity": "sha512-4JOxa+UAizJgpZfaCPKK2smq9d8mmjZVPMt2kOsg/R8QkoRzydHH1qHxIYNvr1zlEaFj4SXiaaJWxq/LPLKaLg==", + "dev": true, + "dependencies": { + "tinyspy": "^3.0.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.1.4.tgz", + "integrity": "sha512-MXDnZn0Awl2S86PSNIim5PWXgIAx8CIkzu35mBdSApUip6RFOGXBCf3YFyeEu8n1IHk4bWD46DeYFu9mQlFIRg==", + "dev": true, + "dependencies": { + "@vitest/pretty-format": "2.1.4", + "loupe": "^3.1.2", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/@volar/language-core": { "version": "2.4.8", "resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.8.tgz", @@ -1697,6 +1827,15 @@ "node": ">=8" } }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -1841,6 +1980,15 @@ "integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==", "dev": true }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -1870,6 +2018,22 @@ } ] }, + "node_modules/chai": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.2.tgz", + "integrity": "sha512-aGtmf24DW6MLHHG5gCx4zaI3uBq3KRtxeVs0DjFH6Z0rDNbsvTxFASFvdj79pxjxZ8/5u3PIiN3IwEIQkiiuPw==", + "dev": true, + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -1886,6 +2050,15 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/check-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", + "dev": true, + "engines": { + "node": ">= 16" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2103,6 +2276,15 @@ "node": ">=0.10.0" } }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -2438,6 +2620,15 @@ "node": ">=0.10.0" } }, + "node_modules/expect-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.1.0.tgz", + "integrity": "sha512-bFi65yM+xZgk+u/KRIpekdSYkTB5W1pEf0Lt8Q8Msh7b+eQ7LXVtIB1Bkm4fvclDEL1b2CZkMhv2mOeF8tMdkA==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -3204,6 +3395,12 @@ "loose-envify": "cli.js" } }, + "node_modules/loupe": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.2.tgz", + "integrity": "sha512-23I4pFZHmAemUnz8WZXbYRSKYj801VDaNv9ETuMh7IrMc7VuVVSo+Z9iLE3ni30+U48iDWfi30d3twAXBYmnCg==", + "dev": true + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -3502,6 +3699,15 @@ "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", "dev": true }, + "node_modules/pathval": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", + "dev": true, + "engines": { + "node": ">= 14.16" + } + }, "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", @@ -3993,6 +4199,12 @@ "node": "*" } }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true + }, "node_modules/signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", @@ -4038,6 +4250,18 @@ "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true + }, + "node_modules/std-env": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.8.0.tgz", + "integrity": "sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==", + "dev": true + }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -4227,12 +4451,51 @@ "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true + }, "node_modules/tinyduration": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/tinyduration/-/tinyduration-3.3.1.tgz", "integrity": "sha512-39iO6CyHMFTPv9PKFxXPXa1DDc2JHog4oGK6x3fG75T+chRO+SKmuEPT00myYs3aGFIq3nQ6U5J5c5hR0PMKjw==", "peer": true }, + "node_modules/tinyexec": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.1.tgz", + "integrity": "sha512-WiCJLEECkO18gwqIp6+hJg0//p23HXp4S+gGtAKu3mI2F2/sXC4FvHvXvB0zJVVaTPhx1/tOwdbRsa1sOBIKqQ==", + "dev": true + }, + "node_modules/tinypool": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.1.tgz", + "integrity": "sha512-URZYihUbRPcGv95En+sz6MfghfIc2OJ1sv/RmhWZLouPY0/8Vo80viwPvg3dlaS9fuq7fQMEfgRRK7BBZThBEA==", + "dev": true, + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-1.2.0.tgz", + "integrity": "sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==", + "dev": true, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", + "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", + "dev": true, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/to-buffer": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", @@ -4383,16 +4646,16 @@ "dev": true }, "node_modules/uuid": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", - "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.3.tgz", + "integrity": "sha512-d0z310fCWv5dJwnX1Y/MncBAqGMKEzlBb1AOf7z9K8ALnd0utBX/msg/fA0+sbyN1ihbMsLhrBlnl1ak7Wa0rg==", + "dev": true, "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" ], - "peer": true, "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } }, "node_modules/vite": { @@ -4454,6 +4717,27 @@ } } }, + "node_modules/vite-node": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.1.4.tgz", + "integrity": "sha512-kqa9v+oi4HwkG6g8ufRnb5AeplcRw8jUF6/7/Qz1qRQOXHImG8YnLbB+LLszENwFnoBl9xIf9nVdCFzNd7GQEg==", + "dev": true, + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.7", + "pathe": "^1.1.2", + "vite": "^5.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/vite-plugin-dts": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/vite-plugin-dts/-/vite-plugin-dts-4.3.0.tgz", @@ -4483,6 +4767,71 @@ } } }, + "node_modules/vitest": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-2.1.4.tgz", + "integrity": "sha512-eDjxbVAJw1UJJCHr5xr/xM86Zx+YxIEXGAR+bmnEID7z9qWfoxpHw0zdobz+TQAFOLT+nEXz3+gx6nUJ7RgmlQ==", + "dev": true, + "dependencies": { + "@vitest/expect": "2.1.4", + "@vitest/mocker": "2.1.4", + "@vitest/pretty-format": "^2.1.4", + "@vitest/runner": "2.1.4", + "@vitest/snapshot": "2.1.4", + "@vitest/spy": "2.1.4", + "@vitest/utils": "2.1.4", + "chai": "^5.1.2", + "debug": "^4.3.7", + "expect-type": "^1.1.0", + "magic-string": "^0.30.12", + "pathe": "^1.1.2", + "std-env": "^3.7.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.1", + "tinypool": "^1.0.1", + "tinyrainbow": "^1.2.0", + "vite": "^5.0.0", + "vite-node": "2.1.4", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/node": "^18.0.0 || >=20.0.0", + "@vitest/browser": "2.1.4", + "@vitest/ui": "2.1.4", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, "node_modules/vscode-uri": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz", @@ -4504,6 +4853,22 @@ "node": ">= 8" } }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", diff --git a/typescript-sdk/package.json b/typescript-sdk/package.json index 4278ce36c2..5c829bcae9 100644 --- a/typescript-sdk/package.json +++ b/typescript-sdk/package.json @@ -14,7 +14,8 @@ "generate-sources": "cross-env KIOTA_VERSION=v1.19.1 kiota generate --serializer none --deserializer none -l typescript -d ../common/src/main/resources/META-INF/openapi.json -c ApicurioRegistryClient -o ./lib/generated-client", "dev": "vite", "build": "tsc --p ./tsconfig-build.json && vite build", - "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0" + "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "test": "vitest run" }, "peerDependencies": { "@microsoft/kiota-abstractions": "1.0.0-preview.68", @@ -42,7 +43,9 @@ "react-router-dom": "6.27.0", "rimraf": "5.0.10", "typescript": "5.6.3", + "uuid": "11.0.3", "vite": "5.4.10", - "vite-plugin-dts": "4.3.0" + "vite-plugin-dts": "4.3.0", + "vitest": "2.1.4" } } diff --git a/typescript-sdk/tests/artifact.test.ts b/typescript-sdk/tests/artifact.test.ts new file mode 100644 index 0000000000..51cdf431d1 --- /dev/null +++ b/typescript-sdk/tests/artifact.test.ts @@ -0,0 +1,87 @@ +import { createTestClient, generateArtifactId, generateGroupId } from "./test.utils.ts"; +import { ArtifactMetaData, CreateArtifact, VersionMetaData } from "../lib/generated-client/models"; +import { expect, test } from "vitest"; + +const AVRO_CONTENT: string = ` +{ + "type": "record", + "name": "Example", + "namespace": "com.example", + "fields": [ + { + "name": "fieldOne", + "type": "string" + } + ] +} +`; + +test("Empty Artifact", async () => { + const client = createTestClient(); + const groupId = generateGroupId(); + const artifactId = generateArtifactId(); + const createArtifact: CreateArtifact = { + artifactId: artifactId, + artifactType: "AVRO", + name: "Test Artifact", + description: "Test Description" + }; + const car = await client.groups.byGroupId(groupId).artifacts.post(createArtifact); + expect(car?.artifact).toBeDefined(); + expect(car?.artifact?.artifactId).toBe(artifactId); + expect(car?.artifact?.groupId).toBe(groupId); + expect(car?.artifact?.name).toBe("Test Artifact"); + expect(car?.artifact?.description).toBe("Test Description"); + expect(car?.version).toBeFalsy(); + + const amd: ArtifactMetaData | undefined = await client.groups.byGroupId(groupId).artifacts.byArtifactId(artifactId).get(); + expect(amd?.artifactId).toBe(artifactId); + expect(amd?.groupId).toBe(groupId); + expect(amd?.name).toBe("Test Artifact"); + expect(amd?.description).toBe("Test Description"); +}); + +test("Artifact With Version", async () => { + const client = createTestClient(); + const groupId = generateGroupId(); + const artifactId = generateArtifactId(); + const createArtifact: CreateArtifact = { + artifactId: artifactId, + artifactType: "AVRO", + name: "Test Artifact", + description: "Test Description", + firstVersion: { + version: "1.0.0", + name: "Test Version", + description: "Test Version Description", + isDraft: false, + content: { + contentType: "application/json", + content: AVRO_CONTENT + } + } + }; + const car = await client.groups.byGroupId(groupId).artifacts.post(createArtifact); + expect(car?.artifact).toBeDefined(); + expect(car?.artifact?.artifactId).toBe(artifactId); + expect(car?.artifact?.groupId).toBe(groupId); + expect(car?.artifact?.name).toBe("Test Artifact"); + expect(car?.artifact?.description).toBe("Test Description"); + expect(car?.version).toBeDefined(); + expect(car?.version?.version).toBe("1.0.0"); + expect(car?.version?.name).toBe("Test Version"); + expect(car?.version?.description).toBe("Test Version Description"); + + const amd: ArtifactMetaData | undefined = await client.groups.byGroupId(groupId).artifacts.byArtifactId(artifactId).get(); + expect(amd?.groupId).toBe(groupId); + expect(amd?.artifactId).toBe(artifactId); + expect(amd?.name).toBe("Test Artifact"); + expect(amd?.description).toBe("Test Description"); + + const vmd: VersionMetaData | undefined = await client.groups.byGroupId(groupId).artifacts.byArtifactId(artifactId).versions.byVersionExpression("1.0.0").get(); + expect(vmd?.groupId).toBe(groupId); + expect(vmd?.artifactId).toBe(artifactId); + expect(vmd?.version).toBe("1.0.0"); + expect(vmd?.name).toBe("Test Version"); + expect(vmd?.description).toBe("Test Version Description"); +}); diff --git a/typescript-sdk/tests/group.test.ts b/typescript-sdk/tests/group.test.ts new file mode 100644 index 0000000000..01eafaa72f --- /dev/null +++ b/typescript-sdk/tests/group.test.ts @@ -0,0 +1,21 @@ +import { createTestClient, generateGroupId } from "./test.utils.ts"; +import { CreateGroup, type GroupMetaData } from "../lib/generated-client/models"; +import { expect, test } from "vitest"; + +test("Group", async () => { + const client = createTestClient(); + const groupId = generateGroupId(); + const createGroup: CreateGroup = { + groupId: groupId, + description: "Test Description" + }; + let gmd: GroupMetaData | undefined = await client.groups.post(createGroup); + expect(gmd).toBeDefined(); + expect(gmd?.groupId).toBe(groupId); + expect(gmd?.description).toBe("Test Description"); + + gmd = await client.groups.byGroupId(groupId).get(); + expect(gmd).toBeDefined(); + expect(gmd?.groupId).toBe(groupId); + expect(gmd?.description).toBe("Test Description"); +}); diff --git a/typescript-sdk/tests/system-info.test.ts b/typescript-sdk/tests/system-info.test.ts new file mode 100644 index 0000000000..89cd78aa9a --- /dev/null +++ b/typescript-sdk/tests/system-info.test.ts @@ -0,0 +1,10 @@ +import { createTestClient } from "./test.utils.ts"; +import { SystemInfo } from "../lib/generated-client/models"; +import { expect, test } from "vitest"; + +test("System Info", async () => { + const client = createTestClient(); + const info: SystemInfo | undefined = await client.system.info.get(); + expect(info).toBeDefined(); + expect(info?.name).toBe("Apicurio Registry (In Memory)"); +}); diff --git a/typescript-sdk/tests/test.utils.ts b/typescript-sdk/tests/test.utils.ts new file mode 100644 index 0000000000..71ac6c1ec4 --- /dev/null +++ b/typescript-sdk/tests/test.utils.ts @@ -0,0 +1,16 @@ +import { ApicurioRegistryClient } from "../lib/generated-client/apicurioRegistryClient.ts"; +import { RegistryClientFactory } from "../lib/sdk"; +import { v4 as uuidv4 } from "uuid"; + +export function createTestClient(): ApicurioRegistryClient { + const baseUrl: string = process.env.REGISTRY_API_BASE_URL || "http://localhost:8080/apis/registry/v3/"; + return RegistryClientFactory.createRegistryClient(baseUrl); +} + +export function generateGroupId(): string { + return "group-" + uuidv4(); +} + +export function generateArtifactId(): string { + return "arty-" + uuidv4(); +} diff --git a/typescript-sdk/tsconfig.json b/typescript-sdk/tsconfig.json index e3e5d0a111..ce56c43d24 100644 --- a/typescript-sdk/tsconfig.json +++ b/typescript-sdk/tsconfig.json @@ -20,6 +20,6 @@ "noUnusedParameters": false, "noFallthroughCasesInSwitch": true }, - "include": ["src", "lib"], + "include": ["src", "lib", "tests"], "references": [{ "path": "./tsconfig.node.json" }] }