chore: do not select after hooks automatically (#27805)

This commit is contained in:
Pavel Feldman 2023-10-25 17:05:06 -07:00 committed by GitHub
parent 54235120a0
commit 47733b04fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 16 deletions

View file

@ -254,7 +254,10 @@ export const UIModeView: React.FC<{}> = ({
</div>} </div>}
<ToolbarButton icon='play' title='Run all' onClick={() => runTests('bounce-if-busy', visibleTestIds)} disabled={isRunningTest || isLoading}></ToolbarButton> <ToolbarButton icon='play' title='Run all' onClick={() => runTests('bounce-if-busy', visibleTestIds)} disabled={isRunningTest || isLoading}></ToolbarButton>
<ToolbarButton icon='debug-stop' title='Stop' onClick={() => sendMessageNoReply('stop')} disabled={!isRunningTest || isLoading}></ToolbarButton> <ToolbarButton icon='debug-stop' title='Stop' onClick={() => sendMessageNoReply('stop')} disabled={!isRunningTest || isLoading}></ToolbarButton>
<ToolbarButton icon='eye' title='Watch all' toggled={watchAll} onClick={() => setWatchAll(!watchAll)}></ToolbarButton> <ToolbarButton icon='eye' title='Watch all' toggled={watchAll} onClick={() => {
setWatchedTreeIds({ value: new Set() });
setWatchAll(!watchAll);
}}></ToolbarButton>
<ToolbarButton icon='collapse-all' title='Collapse all' onClick={() => { <ToolbarButton icon='collapse-all' title='Collapse all' onClick={() => {
setCollapseAllCount(collapseAllCount + 1); setCollapseAllCount(collapseAllCount + 1);
}} /> }} />

View file

@ -72,12 +72,21 @@ export const Workbench: React.FunctionComponent<{
if (selectedAction && model?.actions.includes(selectedAction)) if (selectedAction && model?.actions.includes(selectedAction))
return; return;
const failedAction = model?.failedAction(); const failedAction = model?.failedAction();
if (initialSelection && model?.actions.includes(initialSelection)) if (initialSelection && model?.actions.includes(initialSelection)) {
setSelectedAction(initialSelection); setSelectedAction(initialSelection);
else if (failedAction) } else if (failedAction) {
setSelectedAction(failedAction); setSelectedAction(failedAction);
else if (model?.actions.length) } else if (model?.actions.length) {
setSelectedAction(model.actions[model.actions.length - 1]); // Select the last non-after hooks item.
let index = model.actions.length - 1;
for (let i = 0; i < model.actions.length; ++i) {
if (model.actions[i].apiName === 'After Hooks' && i) {
index = i - 1;
break;
}
}
setSelectedAction(model.actions[index]);
}
}, [model, selectedAction, setSelectedAction, initialSelection]); }, [model, selectedAction, setSelectedAction, initialSelection]);
const onActionSelected = React.useCallback((action: ActionTraceEventInContext) => { const onActionSelected = React.useCallback((action: ActionTraceEventInContext) => {

View file

@ -109,8 +109,6 @@ test('should update trace live', async ({ runUITest, server }) => {
/page.gotohttp:\/\/localhost:\d+\/one.html[\d.]+m?s/, /page.gotohttp:\/\/localhost:\d+\/one.html[\d.]+m?s/,
/page.gotohttp:\/\/localhost:\d+\/two.html[\d.]+m?s/, /page.gotohttp:\/\/localhost:\d+\/two.html[\d.]+m?s/,
/After Hooks[\d.]+m?s/, /After Hooks[\d.]+m?s/,
/fixture: page[\d.]+m?s/,
/fixture: context[\d.]+m?s/,
]); ]);
}); });

View file

@ -44,6 +44,6 @@ test('should show screenshots', async ({ runUITest }) => {
await page.getByText('test 2', { exact: true }).click(); await page.getByText('test 2', { exact: true }).click();
await expect( await expect(
page.locator('.CodeMirror .source-line-running'), page.locator('.CodeMirror .source-line-running'),
).toContainText(`test('test 2', async ({ page }) => {`); ).toContainText(`await page.waitForTimeout(1000);`);
await expect(page.locator('.film-strip-frame').first()).toBeVisible(); await expect(page.locator('.film-strip-frame').first()).toBeVisible();
}); });

View file

@ -45,8 +45,6 @@ test('should merge trace events', async ({ runUITest, server }) => {
/locator.clickgetByRole\('button'\)[\d.]+m?s/, /locator.clickgetByRole\('button'\)[\d.]+m?s/,
/expect.toBe[\d.]+m?s/, /expect.toBe[\d.]+m?s/,
/After Hooks[\d.]+m?s/, /After Hooks[\d.]+m?s/,
/fixture: page[\d.]+m?s/,
/fixture: context[\d.]+m?s/,
]); ]);
}); });
@ -72,8 +70,6 @@ test('should merge web assertion events', async ({ runUITest }, testInfo) => {
/page.setContent[\d.]+m?s/, /page.setContent[\d.]+m?s/,
/expect.toBeVisiblelocator\('button'\)[\d.]+m?s/, /expect.toBeVisiblelocator\('button'\)[\d.]+m?s/,
/After Hooks[\d.]+m?s/, /After Hooks[\d.]+m?s/,
/fixture: page[\d.]+m?s/,
/fixture: context[\d.]+m?s/,
]); ]);
}); });
@ -98,9 +94,8 @@ test('should merge screenshot assertions', async ({ runUITest }, testInfo) => {
/Before Hooks[\d.]+m?s/, /Before Hooks[\d.]+m?s/,
/page.setContent[\d.]+m?s/, /page.setContent[\d.]+m?s/,
/expect.toHaveScreenshot[\d.]+m?s/, /expect.toHaveScreenshot[\d.]+m?s/,
/attach "trace-test-1-actual.png/,
/After Hooks[\d.]+m?s/, /After Hooks[\d.]+m?s/,
/fixture: page[\d.]+m?s/,
/fixture: context[\d.]+m?s/,
]); ]);
}); });
@ -147,8 +142,6 @@ test('should show snapshots for sync assertions', async ({ runUITest, server })
/locator\.clickgetByRole\('button'\)[\d.]+m?s/, /locator\.clickgetByRole\('button'\)[\d.]+m?s/,
/expect\.toBe[\d.]+m?s/, /expect\.toBe[\d.]+m?s/,
/After Hooks[\d.]+m?s/, /After Hooks[\d.]+m?s/,
/fixture: page[\d.]+m?s/,
/fixture: context[\d.]+m?s/,
]); ]);
await expect( await expect(