finish test for default case
This commit is contained in:
parent
b4d60deb74
commit
e24a5ba8f9
|
|
@ -52,7 +52,7 @@ export const SnapshotTab: React.FunctionComponent<{
|
||||||
}> = ({ action, model, sdkLanguage, testIdAttributeName, isInspecting, setIsInspecting, highlightedLocator, setHighlightedLocator, openPage }) => {
|
}> = ({ action, model, sdkLanguage, testIdAttributeName, isInspecting, setIsInspecting, highlightedLocator, setHighlightedLocator, openPage }) => {
|
||||||
const [measure, ref] = useMeasure<HTMLDivElement>();
|
const [measure, ref] = useMeasure<HTMLDivElement>();
|
||||||
const [snapshotTab, setSnapshotTab] = React.useState<'action'|'before'|'after'>('action');
|
const [snapshotTab, setSnapshotTab] = React.useState<'action'|'before'|'after'>('action');
|
||||||
const [showScreenshotInsteadOfSnapshot] = useSetting('screenshot-instead-of-snapshot', false, 'Show screenshot instead of snapshot');
|
const [showScreenshotInsteadOfSnapshot] = useSetting('screenshot-instead-of-snapshot', false);
|
||||||
|
|
||||||
type Snapshot = { action: ActionTraceEvent, snapshotName: string, point?: { x: number, y: number } };
|
type Snapshot = { action: ActionTraceEvent, snapshotName: string, point?: { x: number, y: number } };
|
||||||
const { snapshots } = React.useMemo(() => {
|
const { snapshots } = React.useMemo(() => {
|
||||||
|
|
@ -230,7 +230,7 @@ export const SnapshotTab: React.FunctionComponent<{
|
||||||
transform: `translate(${translate.x}px, ${translate.y}px) scale(${scale})`,
|
transform: `translate(${translate.x}px, ${translate.y}px) scale(${scale})`,
|
||||||
}}>
|
}}>
|
||||||
<BrowserFrame url={snapshotInfo.url} />
|
<BrowserFrame url={snapshotInfo.url} />
|
||||||
{(showScreenshotInsteadOfSnapshot && screencastFrame) && <img src={`sha1/${screencastFrame.sha1}`} width={screencastFrame.width} height={screencastFrame.height} />}
|
{(showScreenshotInsteadOfSnapshot && screencastFrame) && <img alt={`Screenshot of ${action?.apiName} > ${renderTitle(snapshotTab)}`} src={`sha1/${screencastFrame.sha1}`} width={screencastFrame.width} height={screencastFrame.height} />}
|
||||||
<div className='snapshot-switcher' style={showScreenshotInsteadOfSnapshot ? { display: 'none' } : undefined}>
|
<div className='snapshot-switcher' style={showScreenshotInsteadOfSnapshot ? { display: 'none' } : undefined}>
|
||||||
<iframe ref={iframeRef0} name='snapshot' title='DOM Snapshot' className={clsx(loadingRef.current.visibleIframe === 0 && 'snapshot-visible')}></iframe>
|
<iframe ref={iframeRef0} name='snapshot' title='DOM Snapshot' className={clsx(loadingRef.current.visibleIframe === 0 && 'snapshot-visible')}></iframe>
|
||||||
<iframe ref={iframeRef1} name='snapshot' title='DOM Snapshot' className={clsx(loadingRef.current.visibleIframe === 1 && 'snapshot-visible')}></iframe>
|
<iframe ref={iframeRef1} name='snapshot' title='DOM Snapshot' className={clsx(loadingRef.current.visibleIframe === 1 && 'snapshot-visible')}></iframe>
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ export function copy(text: string) {
|
||||||
textArea.remove();
|
textArea.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useSetting<S>(name: string | undefined, defaultValue: S, title?: string): [S, React.Dispatch<React.SetStateAction<S>>] {
|
export function useSetting<S>(name: string | undefined, defaultValue: S): [S, React.Dispatch<React.SetStateAction<S>>] {
|
||||||
if (name)
|
if (name)
|
||||||
defaultValue = settings.getObject(name, defaultValue);
|
defaultValue = settings.getObject(name, defaultValue);
|
||||||
const [value, setValue] = React.useState<S>(defaultValue);
|
const [value, setValue] = React.useState<S>(defaultValue);
|
||||||
|
|
|
||||||
|
|
@ -1471,7 +1471,15 @@ test('should allow showing screenshots instead of snapshots', async ({ runAndTra
|
||||||
await page.goto(server.PREFIX + '/one-style.html');
|
await page.goto(server.PREFIX + '/one-style.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
const snapshotFrame = await traceViewer.snapshotFrame('page.goto');
|
const screenshot = traceViewer.page.getByAltText(`Screenshot of page.goto > Action`);
|
||||||
await expect(snapshotFrame.locator('body')).toHaveCSS('background-color', 'pink', { timeout: 0 });
|
const snapshot = (await traceViewer.snapshotFrame('page.goto')).owner();
|
||||||
|
await expect(snapshot).toBeVisible();
|
||||||
|
await expect(screenshot).not.toBeVisible();
|
||||||
|
|
||||||
|
await traceViewer.page.getByTitle('Settings').click();
|
||||||
|
await traceViewer.page.getByText('Show screenshot instead of snapshot').setChecked(true);
|
||||||
|
|
||||||
|
await expect(snapshot).not.toBeVisible();
|
||||||
|
await expect(screenshot).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue