From 6cf6a26ee63f8b17bd216ced75a312617c690b46 Mon Sep 17 00:00:00 2001 From: Dor Eitan Date: Tue, 26 Aug 2025 15:34:16 +0300 Subject: [PATCH 1/6] chore: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 03e8d343..99882b4e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@d-id/client-sdk", "private": false, - "version": "1.1.10", + "version": "1.1.11", "type": "module", "description": "d-id client sdk", "repository": { From b1bd430ce968a844a5442b9350657def8779404d Mon Sep 17 00:00:00 2001 From: dariusz-did Date: Tue, 9 Sep 2025 18:16:22 +0200 Subject: [PATCH 2/6] SDK tests (#202) * tests * run in CI * eslint * workglow name * CI fixes * dummy test removed * changes after review * changes after review * prettier --- .github/workflows/README.md | 72 + .github/workflows/test.yml | 144 + demo/app.tsx | 8 +- jest.config.cjs | 42 + jest.setup.ts | 21 + package.json | 18 +- src/auth/get-auth-header.ts | 5 +- .../agent-manager/connect-to-manager.test.ts | 479 ++ src/services/agent-manager/index.test.ts | 755 ++++ .../streaming-manager/advanced.test.ts | 519 +++ .../streaming-manager/business-flows.test.ts | 231 + src/services/streaming-manager/core.test.ts | 378 ++ .../streaming-manager/disconnect.test.ts | 408 ++ .../streaming-manager/edge-cases.test.ts | 534 +++ src/services/streaming-manager/index.ts | 10 +- src/services/streaming-manager/stats/poll.ts | 6 +- .../streaming-manager/stats/report.ts | 8 +- src/services/streaming-manager/utils.test.ts | 141 + .../factories/agent-manager.factory.ts | 23 + src/test-utils/factories/agent.factory.ts | 26 + .../factories/agents-api.factory.ts | 12 + src/test-utils/factories/analytics.factory.ts | 6 + src/test-utils/factories/chat.factory.ts | 8 + src/test-utils/factories/index.ts | 8 + .../factories/socket-manager.factory.ts | 5 + .../factories/stream-api.factory.ts | 17 + .../factories/streaming-manager.factory.ts | 42 + src/types/entities/knowledge/index.ts | 2 +- src/types/stream/api/index.ts | 1 - src/utils/index.ts | 7 +- tsconfig.json | 2 +- yarn.lock | 3982 +++++++++++++---- 32 files changed, 7040 insertions(+), 880 deletions(-) create mode 100644 .github/workflows/README.md create mode 100644 .github/workflows/test.yml create mode 100644 jest.config.cjs create mode 100644 jest.setup.ts create mode 100644 src/services/agent-manager/connect-to-manager.test.ts create mode 100644 src/services/agent-manager/index.test.ts create mode 100644 src/services/streaming-manager/advanced.test.ts create mode 100644 src/services/streaming-manager/business-flows.test.ts create mode 100644 src/services/streaming-manager/core.test.ts create mode 100644 src/services/streaming-manager/disconnect.test.ts create mode 100644 src/services/streaming-manager/edge-cases.test.ts create mode 100644 src/services/streaming-manager/utils.test.ts create mode 100644 src/test-utils/factories/agent-manager.factory.ts create mode 100644 src/test-utils/factories/agent.factory.ts create mode 100644 src/test-utils/factories/agents-api.factory.ts create mode 100644 src/test-utils/factories/analytics.factory.ts create mode 100644 src/test-utils/factories/chat.factory.ts create mode 100644 src/test-utils/factories/index.ts create mode 100644 src/test-utils/factories/socket-manager.factory.ts create mode 100644 src/test-utils/factories/stream-api.factory.ts create mode 100644 src/test-utils/factories/streaming-manager.factory.ts diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000..04dd0bbc --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,72 @@ +# CI/CD Workflows + +This directory contains GitHub Actions workflows for automated testing, building, and deployment. + +## ๐Ÿงช Test Workflow (`test.yml`) + +**Triggers**: Pull requests and pushes to `main`/`develop` + +### Jobs: + +1. **`test`** - Unit Tests + - Runs all Jest unit tests + - Ensures all tests pass + +2. **`lint`** - Code Quality + - Checks TypeScript compilation + - Validates code formatting (Prettier) + +3. **`build`** - Build Verification + - Ensures project builds successfully + - Uploads build artifacts + +4. **`all-checks-passed`** - Gate Keeper + - Only passes if ALL other jobs succeed + - **This is the required status check for branch protection** + +### Test Requirements: + +- All unit tests must pass +- No failing test cases + +## ๐Ÿš€ E2E Workflows + +- `pr-main-e2e.yml` - E2E tests against production +- `pr-prod-e2e.yml` - Production E2E validation +- `manual-e2e.yml` - Manual E2E trigger +- `publish-on-merge.yml` - Package publishing + +## ๐Ÿ”ง Local Development + +```bash +# Run tests +yarn test + +# Run tests in watch mode +yarn test:watch + +# Run tests in CI mode +yarn test:ci + +# Type checking +yarn type-check + +# Code formatting +yarn lint +yarn lint:fix + +# Full CI simulation +yarn ci:test +``` + +## ๐Ÿ“Š Artifacts + +Each workflow run produces: + +- **Build Artifacts** (3 days retention) +- **Test Results** (30 days retention for E2E) + +## ๐Ÿ” Monitoring + +- Test results visible in workflow logs +- Failed runs block PR merging automatically diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..9f22ccb0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,144 @@ +name: Unit Tests +permissions: + contents: read + +on: + pull_request: + branches: [main, prod] + types: [opened, synchronize, reopened] + push: + branches: [main, prod] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + +jobs: + type-check: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'yarn' + cache-dependency-path: yarn.lock + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Run TypeScript type checking + run: yarn tsc --noEmit + + lint: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'yarn' + cache-dependency-path: yarn.lock + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Check code formatting + run: | + if command -v yarn prettier &> /dev/null; then + echo "Running Prettier check..." + yarn prettier --check "src/**/*.{ts,tsx,js,jsx}" || { + echo "โŒ Code formatting issues found. Please run 'yarn prettier --write .' to fix them." + exit 1 + } + else + echo "Prettier not configured, skipping format check" + fi + + test: + runs-on: ubuntu-latest + timeout-minutes: 15 + needs: [type-check, lint] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'yarn' + cache-dependency-path: yarn.lock + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Run unit tests with coverage + run: yarn test:ci --coverage + env: + CI: true + + build: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'yarn' + cache-dependency-path: yarn.lock + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Build project + run: yarn build + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts-${{ github.run_id }} + path: | + dist/ + retention-days: 3 + + # This job will only run if all previous jobs succeed + # It serves as a single status check for branch protection + all-checks-passed: + runs-on: ubuntu-latest + needs: [type-check, lint, test, build] + if: always() + + steps: + - name: Check if all jobs succeeded + run: | + if [[ "${{ needs.type-check.result }}" == "success" && + "${{ needs.lint.result }}" == "success" && + "${{ needs.test.result }}" == "success" && + "${{ needs.build.result }}" == "success" ]]; then + echo "โœ… All checks passed!" + exit 0 + else + echo "โŒ Some checks failed:" + echo " Type Check: ${{ needs.type-check.result }}" + echo " Lint: ${{ needs.lint.result }}" + echo " Test: ${{ needs.test.result }}" + echo " Build: ${{ needs.build.result }}" + exit 1 + fi diff --git a/demo/app.tsx b/demo/app.tsx index 8fbe657f..585bb987 100644 --- a/demo/app.tsx +++ b/demo/app.tsx @@ -25,12 +25,7 @@ export function App() { mode, enableAnalytics: false, auth: { type: 'key', clientKey }, - streamOptions: { - streamWarmup: warmup, - sessionTimeout, - compatibilityMode, - fluent, - }, + streamOptions: { streamWarmup: warmup, sessionTimeout, compatibilityMode, fluent }, }); async function onClick() { @@ -52,7 +47,6 @@ export function App() {