import * as playwright from "playwright" ; import { RethrownError } from "../utils/RethrownError" ; import { EnsureXrmGetter } from "./Global" ; import { XrmUiTest } from "./XrmUITest" ; /**
 * State of a tab
 */ export interface TabState { /**
     * Whether the tab is currently visible
     */ isVisible : boolean ; } /**
 * Module for interacting with D365 Tabs
 */ export class Tab { private _page : playwright . Page ; constructor ( private xrmUiTest ) { this . _page = xrmUiTest . page ; this . xrmUiTest = xrmUiTest ; } param tabName returns open = async ( tabName ) => { try { await EnsureXrmGetter ( this . _page ) ; await this . _page . evaluate ( ( tabName ) => { const xrm = window . oss_FindXrm ( ) ; xrm . Page . ui . tabs . get ( tabName ) . setDisplayState ( "expanded" ) ; } , tabName ) ; await this . xrmUiTest . waitForIdleness ( ) ; } catch ( e ) { throw new RethrownError ( `Error when opening tab '${ tabName }'` , e ) ; } } ; param name returns get = async ( name ) : Promise < TabState > => { try { await EnsureXrmGetter ( this . _page ) ; return this . _page . evaluate ( ( tabName ) => { const xrm = window . oss_FindXrm ( ) ; const tab = xrm . Page . ui . tabs . get ( tabName ) ; return { isVisible : tab . getVisible ( ) } ; } , name ) ; } catch ( e ) { throw new RethrownError ( `Error when getting tab '${ name }'` , e ) ; } } ; }