Skip to content

Commit 8a8c89b

Browse files
pavelfeldmanaslushnikov
authored andcommitted
cherry-pick(#17367): chore: rebuild components on new vite
1 parent e1681a3 commit 8a8c89b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

packages/playwright-core/src/common/userAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function getClientLanguage(): { langName: string, langVersion: string } {
7575
return { langName, langVersion };
7676
}
7777

78-
export function getPlaywrightVersion(majorMinorOnly = false) {
78+
export function getPlaywrightVersion(majorMinorOnly = false): string {
7979
const packageJson = require('./../../package.json');
8080
return majorMinorOnly ? packageJson.version.split('.').slice(0, 2).join('.') : packageJson.version;
8181
}

packages/playwright-test/src/plugins/vitePlugin.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ import { collectComponentUsages, componentInfo } from '../tsxTransform';
2626
import type { FullConfig } from '../types';
2727
import { assert, calculateSha1 } from 'playwright-core/lib/utils';
2828
import type { AddressInfo } from 'net';
29+
import { getPlaywrightVersion } from 'playwright-core/lib/common/userAgent';
2930

3031
let stoppableServer: any;
31-
const VERSION = 6;
32+
const playwrightVersion = getPlaywrightVersion();
3233

3334
type CtConfig = {
3435
ctPort?: number;
@@ -65,14 +66,17 @@ export function createPlugin(
6566
const registerSource = await fs.promises.readFile(registerSourceFile, 'utf-8');
6667
const registerSourceHash = calculateSha1(registerSource);
6768

69+
const { version: viteVersion } = require('vite/package.json');
6870
try {
6971
buildInfo = JSON.parse(await fs.promises.readFile(buildInfoFile, 'utf-8')) as BuildInfo;
70-
assert(buildInfo.version === VERSION);
72+
assert(buildInfo.version === playwrightVersion);
73+
assert(buildInfo.viteVersion === viteVersion);
7174
assert(buildInfo.registerSourceHash === registerSourceHash);
7275
buildExists = true;
7376
} catch (e) {
7477
buildInfo = {
75-
version: VERSION,
78+
version: playwrightVersion,
79+
viteVersion,
7680
registerSourceHash,
7781
components: [],
7882
tests: {},
@@ -156,7 +160,8 @@ export function createPlugin(
156160
}
157161

158162
type BuildInfo = {
159-
version: number,
163+
version: string,
164+
viteVersion: string,
160165
registerSourceHash: string,
161166
sources: {
162167
[key: string]: {

tests/playwright-test/playwright.ct-build.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ test('should work with the empty component list', async ({ runInlineTest }, test
3737
expect(output.replace(/\\+/g, '/')).toContain('playwright/.cache/playwright/index.html');
3838

3939
const metainfo = JSON.parse(fs.readFileSync(testInfo.outputPath('playwright/.cache/metainfo.json'), 'utf-8'));
40-
expect(metainfo.version).toEqual(expect.any(Number));
40+
expect(metainfo.version).toEqual(require('playwright-core/package.json').version);
41+
expect(metainfo.viteVersion).toEqual(require('vite/package.json').version);
4142
expect(Object.entries(metainfo.tests)).toHaveLength(1);
4243
expect(Object.entries(metainfo.sources)).toHaveLength(8);
4344
});

0 commit comments

Comments
 (0)