-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring to get e2e tests back on track
- Loading branch information
1 parent
df2399c
commit 8dd0659
Showing
9 changed files
with
95 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
deployables/app/app/components/pilotStatus/PilotStatusContext.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
createContext, | ||
useContext, | ||
useState, | ||
type PropsWithChildren, | ||
} from 'react' | ||
import { useConnectChangeOnPilotEvents } from './useConnectChangeOnPilotEvents' | ||
import { useDisconnectWhenUnreachable } from './useDisconnectWhenUnreachable' | ||
import { usePingWhileDisconnected } from './usePingWhileDisconnected' | ||
|
||
const PilotStatusContext = createContext(false) | ||
|
||
export const ProvidePilotStatus = ({ children }: PropsWithChildren) => ( | ||
<PilotStatusContext value={useUpdatedConnectionStatus()}> | ||
{children} | ||
</PilotStatusContext> | ||
) | ||
|
||
const useUpdatedConnectionStatus = () => { | ||
const [connected, setConnected] = useState(false) | ||
|
||
useConnectChangeOnPilotEvents({ | ||
onConnect: () => setConnected(true), | ||
onDisconnect: () => setConnected(false), | ||
}) | ||
usePingWhileDisconnected(connected, { onConnect: () => setConnected(true) }) | ||
useDisconnectWhenUnreachable(connected, { | ||
onDisconnect: () => setConnected(false), | ||
}) | ||
|
||
return connected | ||
} | ||
|
||
export const useConnected = () => useContext(PilotStatusContext) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { PilotStatus } from './PilotStatus' | ||
export { ProvidePilotStatus, useConnected } from './PilotStatusContext' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import type { Page } from '@playwright/test' | ||
import { expect } from './fixture' | ||
import { getExtensionPage } from './getExtensionPage' | ||
|
||
export const loadExtension = async (page: Page) => { | ||
await page.goto('/') | ||
await page.getByRole('button', { name: 'Open Pilot' }).click() | ||
|
||
await page.getByRole('button', { name: 'Open extension' }).click() | ||
const extension = await getExtensionPage(page) | ||
|
||
return getExtensionPage(page) | ||
await expect( | ||
extension.getByRole('heading', { name: 'Welcome to Zodiac Pilot' }), | ||
).toBeInViewport() | ||
|
||
return extension | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters