Clean up new tests

This commit is contained in:
Adam Gastineau 2025-01-07 11:38:32 -08:00
parent 9f05f03fc9
commit 58452b434f
4 changed files with 7 additions and 5 deletions

View file

@ -33,7 +33,6 @@ export const SettingsToolbarButton: React.FC<{}> = () => {
onClick={() => setOpen(current => !current)} onClick={() => setOpen(current => !current)}
/> />
<Dialog <Dialog
className='settings-toolbar-dialog'
style={{ style={{
backgroundColor: 'var(--vscode-sideBar-background)', backgroundColor: 'var(--vscode-sideBar-background)',
padding: '4px 8px' padding: '4px 8px'
@ -44,6 +43,7 @@ export const SettingsToolbarButton: React.FC<{}> = () => {
verticalOffset={8} verticalOffset={8}
requestClose={() => setOpen(false)} requestClose={() => setOpen(false)}
anchor={hostingRef} anchor={hostingRef}
dataTestId='settings-toolbar-dialog'
> >
<DefaultSettingsView /> <DefaultSettingsView />
</Dialog> </Dialog>

View file

@ -24,6 +24,7 @@ export interface DialogProps {
verticalOffset?: number; verticalOffset?: number;
requestClose?: () => void; requestClose?: () => void;
anchor?: React.RefObject<HTMLElement>; anchor?: React.RefObject<HTMLElement>;
dataTestId?: string;
} }
export const Dialog: React.FC<React.PropsWithChildren<DialogProps>> = ({ export const Dialog: React.FC<React.PropsWithChildren<DialogProps>> = ({
@ -34,6 +35,7 @@ export const Dialog: React.FC<React.PropsWithChildren<DialogProps>> = ({
verticalOffset, verticalOffset,
requestClose, requestClose,
anchor, anchor,
dataTestId,
children, children,
}) => { }) => {
const dialogRef = React.useRef<HTMLDialogElement>(null); const dialogRef = React.useRef<HTMLDialogElement>(null);
@ -96,7 +98,7 @@ export const Dialog: React.FC<React.PropsWithChildren<DialogProps>> = ({
return ( return (
open && ( open && (
<dialog ref={dialogRef} style={style} className={className} open> <dialog ref={dialogRef} style={style} className={className} data-testid={dataTestId} open>
{children} {children}
</dialog> </dialog>
) )

View file

@ -68,7 +68,7 @@ class TraceViewerPage {
this.metadataTab = page.getByTestId('metadata-view'); this.metadataTab = page.getByTestId('metadata-view');
this.sourceCodeTab = page.getByTestId('source-code'); this.sourceCodeTab = page.getByTestId('source-code');
this.settingsDialog = page.locator('.settings-toolbar-dialog'); this.settingsDialog = page.getByTestId('settings-toolbar-dialog');
this.darkModeSetting = page.locator('.setting').getByText('Dark mode'); this.darkModeSetting = page.locator('.setting').getByText('Dark mode');
this.displayCanvasContentSetting = page.locator('.setting').getByText('Display canvas content'); this.displayCanvasContentSetting = page.locator('.setting').getByText('Display canvas content');
} }

View file

@ -1641,7 +1641,7 @@ test('should toggle canvas rendering', async ({ runAndTrace, page }) => {
await page.goto(`data:text/html,<!DOCTYPE html><body><div>Hello world</div></body>`); await page.goto(`data:text/html,<!DOCTYPE html><body><div>Hello world</div></body>`);
}); });
let snapshotRequestPromise = traceViewer.page.waitForRequest(request => request.url().includes('/snapshot/'), { timeout: 2000 }); let snapshotRequestPromise = traceViewer.page.waitForRequest(request => request.url().includes('/snapshot/'));
// Click on the action with a canvas snapshot // Click on the action with a canvas snapshot
await traceViewer.selectAction('goto', 0); await traceViewer.selectAction('goto', 0);
@ -1659,7 +1659,7 @@ test('should toggle canvas rendering', async ({ runAndTrace, page }) => {
// Deselect canvas // Deselect canvas
await traceViewer.selectAction('goto', 1); await traceViewer.selectAction('goto', 1);
snapshotRequestPromise = traceViewer.page.waitForRequest(request => request.url().includes('/snapshot/'), { timeout: 2000 }); snapshotRequestPromise = traceViewer.page.waitForRequest(request => request.url().includes('/snapshot/'));
// Select canvas again // Select canvas again
await traceViewer.selectAction('goto', 0); await traceViewer.selectAction('goto', 0);