Skip to content

🎥 Make videos programmatically with React

Tests: Verify Studio pixel ratio defaults without source-name coupling

Igor Samokhovets4b73a85803b1
diff --git a/packages/it-tests/src/monorepo/studio-pixel-ratio.test.ts b/packages/it-tests/src/monorepo/studio-pixel-ratio.test.ts
index 03e5c1c17f..d38608a96f 100644
--- a/packages/it-tests/src/monorepo/studio-pixel-ratio.test.ts
+++ b/packages/it-tests/src/monorepo/studio-pixel-ratio.test.ts
@@ -1,21 +1,34 @@
import {expect, test} from 'bun:test';
-import {readFileSync} from 'fs';
import path from 'path';
-test('Studio canvas pixel ratio override is disabled in committed code', () => {
- const source = readFileSync(
- path.join(
- __dirname,
- '..',
- '..',
- '..',
- 'studio',
- 'src',
- 'helpers',
- 'studio-pixel-ratio.ts',
- ),
- 'utf-8',
+test('Studio canvas uses the device pixel ratio by default', () => {
+ const modulePath = path.join(
+ __dirname,
+ '..',
+ '..',
+ '..',
+ 'studio',
+ 'src',
+ 'helpers',
+ 'studio-pixel-ratio.ts',
);
- expect(source).toContain('const OVERRIDE_PIXEL_RATIO: number | null = null;');
+ const result = Bun.spawnSync([
+ process.execPath,
+ '--eval',
+ `
+ globalThis.window = {
+ location: {search: ''},
+ sessionStorage: {getItem: () => null},
+ devicePixelRatio: 2,
+ };
+ const {getStudioPixelRatio} = await import(${JSON.stringify(modulePath)});
+ console.log(getStudioPixelRatio());
+ window.devicePixelRatio = 3;
+ console.log(getStudioPixelRatio());
+ `,
+ ]);
+
+ expect(result.exitCode).toBe(0);
+ expect(result.stdout.toString().trim()).toBe('2\n3');
});