cherry-pick(#21844): chore: update test locations when merging
This commit is contained in:
parent
b8f802910c
commit
75b429d143
|
|
@ -301,6 +301,7 @@ export class TeleReporterReceiver {
|
||||||
test.id = payload.testId;
|
test.id = payload.testId;
|
||||||
test.expectedStatus = payload.expectedStatus;
|
test.expectedStatus = payload.expectedStatus;
|
||||||
test.timeout = payload.timeout;
|
test.timeout = payload.timeout;
|
||||||
|
test.location = payload.location;
|
||||||
test.annotations = payload.annotations;
|
test.annotations = payload.annotations;
|
||||||
test.retries = payload.retries;
|
test.retries = payload.retries;
|
||||||
return test;
|
return test;
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ export const SourceTab: React.FunctionComponent<{
|
||||||
const highlight: SourceHighlight[] = source.errors.map(e => ({ type: 'error', line: e.location.line, message: e.error!.message }));
|
const highlight: SourceHighlight[] = source.errors.map(e => ({ type: 'error', line: e.location.line, message: e.error!.message }));
|
||||||
highlight.push({ line: targetLine, type: 'running' });
|
highlight.push({ line: targetLine, type: 'running' });
|
||||||
|
|
||||||
if (source.content === undefined) {
|
if (source.content === undefined || fallbackLocation) {
|
||||||
const sha1 = await calculateSha1(location.file);
|
const sha1 = await calculateSha1(location.file);
|
||||||
try {
|
try {
|
||||||
let response = await fetch(`sha1/src@${sha1}.txt`);
|
let response = await fetch(`sha1/src@${sha1}.txt`);
|
||||||
|
|
|
||||||
|
|
@ -614,6 +614,10 @@ const sendMessage = async (method: string, params: any) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendMessageNoReply = (method: string, params?: any) => {
|
const sendMessageNoReply = (method: string, params?: any) => {
|
||||||
|
if ((window as any)._overrideProtocolForTest) {
|
||||||
|
(window as any)._overrideProtocolForTest({ method, params }).catch(() => {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
sendMessage(method, params).catch((e: Error) => {
|
sendMessage(method, params).catch((e: Error) => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
|
||||||
|
|
@ -168,3 +168,62 @@ test('should pick new / deleted nested tests', async ({ runUITest, writeFiles, d
|
||||||
◯ inner fails
|
◯ inner fails
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should update test locations', async ({ runUITest, writeFiles, deleteFile }) => {
|
||||||
|
const page = await runUITest({
|
||||||
|
'a.test.ts': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('passes', () => {});
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect.poll(dumpTestTree(page), { timeout: 15000 }).toContain(`
|
||||||
|
▼ ◯ a.test.ts
|
||||||
|
◯ passes
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages: any = [];
|
||||||
|
await page.exposeBinding('_overrideProtocolForTest', (_, data) => messages.push(data));
|
||||||
|
|
||||||
|
const passesItemLocator = page.getByRole('listitem').filter({ hasText: 'passes' });
|
||||||
|
await passesItemLocator.hover();
|
||||||
|
await passesItemLocator.getByTitle('Open in VS Code').click();
|
||||||
|
|
||||||
|
expect(messages).toEqual([{
|
||||||
|
method: 'open',
|
||||||
|
params: {
|
||||||
|
location: expect.stringContaining('a.test.ts:3'),
|
||||||
|
},
|
||||||
|
}]);
|
||||||
|
|
||||||
|
await writeFiles({
|
||||||
|
'a.test.ts': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('new-test', () => {});
|
||||||
|
|
||||||
|
test('passes', () => {});
|
||||||
|
`
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect.poll(dumpTestTree(page), { timeout: 15000 }).toContain(`
|
||||||
|
▼ ◯ a.test.ts
|
||||||
|
◯ new-test
|
||||||
|
◯ passes <=
|
||||||
|
`);
|
||||||
|
|
||||||
|
messages.length = 0;
|
||||||
|
await passesItemLocator.hover();
|
||||||
|
await passesItemLocator.getByTitle('Open in VS Code').click();
|
||||||
|
|
||||||
|
expect(messages).toEqual([{
|
||||||
|
method: 'open',
|
||||||
|
params: {
|
||||||
|
location: expect.stringContaining('a.test.ts:5'),
|
||||||
|
},
|
||||||
|
}]);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByTestId('source-code').locator('.source-tab-file-name')
|
||||||
|
).toHaveText('a.test.ts');
|
||||||
|
await expect(page.locator('.CodeMirror-code')).toContainText(`3 test('new-test', () => {});`);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue