-
Notifications
You must be signed in to change notification settings - Fork 2
feat(queue): add e2e tests for fast-v2v and restyle-v2v #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2265ac1
feat(queue): add e2e tests for fast-v2v and restyle-v2v, improve test…
AdirAmsalem 4cac588
feat(tests): enhance e2e tests for lucy-restyle-v2v with prompt and r…
AdirAmsalem 2f66251
feat(tests): add realtime WebRTC e2e tests via vitest browser mode
AdirAmsalem 17b83b0
fix(tests): update e2e configuration and improve test structure
AdirAmsalem 9817b67
fix(tests): exclude e2e-realtime test and improve cleanup in test cases
AdirAmsalem 64953d2
refactor(tests): streamline media track cleanup in e2e-realtime tests
AdirAmsalem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,5 @@ node_modules | |
| dist | ||
| *.log | ||
| .DS_Store | ||
| tests/e2e-output | ||
| packages/sdk/tests/e2e-output | ||
| .env | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| declare const __DECART_API_KEY__: string; | ||
|
|
||
| import { createDecartClient, type DecartSDKError, models, type RealTimeModels } from "@decartai/sdk"; | ||
| import { beforeAll, describe, expect, it } from "vitest"; | ||
|
|
||
| function createSyntheticStream(fps: number, width: number, height: number): MediaStream { | ||
| const canvas = document.createElement("canvas"); | ||
| canvas.width = width; | ||
| canvas.height = height; | ||
| return canvas.captureStream(fps); | ||
| } | ||
|
|
||
| const REALTIME_MODELS: RealTimeModels[] = ["mirage", "mirage_v2", "lucy_v2v_720p_rt", "lucy_2_rt"]; | ||
|
|
||
| describe.concurrent("Realtime E2E Tests", { timeout: 30_000, retry: 2 }, () => { | ||
| let client: ReturnType<typeof createDecartClient>; | ||
|
|
||
| beforeAll(() => { | ||
| // Injected at build time via vitest.config.e2e-realtime.ts `define` | ||
| const apiKey = __DECART_API_KEY__; | ||
| if (!apiKey) { | ||
| throw new Error( | ||
| "DECART_API_KEY environment variable not set. Run with: DECART_API_KEY=your_key pnpm test:e2e:realtime", | ||
| ); | ||
| } | ||
| client = createDecartClient({ apiKey }); | ||
| }); | ||
|
|
||
| for (const modelName of REALTIME_MODELS) { | ||
| it(modelName, async () => { | ||
| const model = models.realtime(modelName); | ||
| const stream = createSyntheticStream(model.fps, model.width, model.height); | ||
|
|
||
| let remoteStreamReceived = false; | ||
|
|
||
| const realtimeClient = await client.realtime.connect(stream, { | ||
| model, | ||
| onRemoteStream: () => { | ||
| remoteStreamReceived = true; | ||
| }, | ||
| initialState: { | ||
| prompt: { text: "Anime style", enhance: false }, | ||
| }, | ||
| }); | ||
|
|
||
| const errors: DecartSDKError[] = []; | ||
| realtimeClient.on("error", (err) => errors.push(err)); | ||
|
|
||
| try { | ||
| expect(["connected", "generating"]).toContain(realtimeClient.getConnectionState()); | ||
| expect(realtimeClient.sessionId).toBeTruthy(); | ||
AdirAmsalem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| expect(remoteStreamReceived).toBe(true); | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| await realtimeClient.setPrompt("Cyberpunk city"); | ||
|
|
||
| expect(errors).toEqual([]); | ||
| } finally { | ||
| realtimeClient.disconnect(); | ||
| for (const track of stream.getTracks()) track.stop(); | ||
| } | ||
|
|
||
| expect(realtimeClient.getConnectionState()).toBe("disconnected"); | ||
| }); | ||
| } | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { defineConfig } from "vitest/config"; | ||
|
|
||
| export default defineConfig({ | ||
| define: { | ||
| __DECART_API_KEY__: JSON.stringify(process.env.DECART_API_KEY), | ||
| }, | ||
| test: { | ||
| include: ["tests/e2e-realtime.test.ts"], | ||
| browser: { | ||
| enabled: true, | ||
| provider: "playwright", | ||
| headless: true, | ||
| instances: [{ browser: "chromium" }], | ||
| }, | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| import { defineConfig } from "vitest/config"; | ||
|
|
||
| export default defineConfig({}); | ||
| export default defineConfig({ | ||
| test: { | ||
| exclude: ["tests/e2e-realtime.test.ts"], | ||
| }, | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.