This commit is contained in:
lee-at-zoo-corp
2025-03-27 11:26:11 -04:00
parent fb192ee213
commit c75aafa60d
7 changed files with 40 additions and 26 deletions

View File

@ -72,7 +72,6 @@ test.describe('integrations tests', () => {
}) })
await test.step('setup for next assertion', async () => { await test.step('setup for next assertion', async () => {
await toolbar.openFile('main.kcl') await toolbar.openFile('main.kcl')
await scene.settled(cmdBar) await scene.settled(cmdBar)
await clickObj() await clickObj()
@ -89,7 +88,7 @@ test.describe('integrations tests', () => {
await toolbar.expectFileTreeState(['main.kcl', fileName]) await toolbar.expectFileTreeState(['main.kcl', fileName])
}) })
await test.step('check sketch mode is exited when opening a different file', async () => { await test.step('check sketch mode is exited when opening a different file', async () => {
await toolbar.openFile(fileName, { wait: false }) await toolbar.openFile(fileName)
// check we're out of sketch mode // check we're out of sketch mode
await expect(toolbar.exitSketchBtn).not.toBeVisible() await expect(toolbar.exitSketchBtn).not.toBeVisible()

View File

@ -39,7 +39,8 @@ export class AuthenticatedApp {
} }
async initialise(code = '') { async initialise(code = '') {
await setup(this.context, this.page, this.testInfo) const testDir = this.testInfo.outputPath('electron-test-projects-dir')
await setup(this.context, this.page, testDir, this.testInfo)
const u = await getUtils(this.page) const u = await getUtils(this.page)
await this.page.addInitScript(async (code) => { await this.page.addInitScript(async (code) => {

View File

@ -159,16 +159,10 @@ export class ToolbarFixture {
} }
} }
/** /**
* Opens file by it's name and waits for execution to finish * Opens file by it's name
*/ */
openFile = async ( openFile = async (fileName: string) => {
fileName: string,
{ wait }: { wait?: boolean } = { wait: true }
) => {
await this.filePane.getByText(fileName).click() await this.filePane.getByText(fileName).click()
if (wait) {
await scene.settled(cmdBar)
}
} }
selectCenterRectangle = async () => { selectCenterRectangle = async () => {
await this.page await this.page

View File

@ -1029,7 +1029,7 @@ part002 = startSketchOn(XZ)
await page.setBodyDimensions({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
await scene.settled() await scene.settled(cmdBar)
await page.getByText('line(end = [3.79, 2.68], tag = $seg01)').click() await page.getByText('line(end = [3.79, 2.68], tag = $seg01)').click()
await expect(page.getByRole('button', { name: 'Edit Sketch' })).toBeEnabled( await expect(page.getByRole('button', { name: 'Edit Sketch' })).toBeEnabled(

View File

@ -71,7 +71,7 @@ export function useNetworkStatus() {
? NetworkHealthState.Disconnected ? NetworkHealthState.Disconnected
: hasIssues || hasIssues === undefined : hasIssues || hasIssues === undefined
? NetworkHealthState.Issue ? NetworkHealthState.Issue
: ping > 16.6 * 3 // we consider ping longer than 3 frames as weak : (ping ?? 0) > 16.6 * 3 // we consider ping longer than 3 frames as weak
? NetworkHealthState.Weak ? NetworkHealthState.Weak
: NetworkHealthState.Ok : NetworkHealthState.Ok
) )

View File

@ -298,11 +298,9 @@ class EngineConnection extends EventTarget {
public webrtcStatsCollector?: () => Promise<ClientMetrics> public webrtcStatsCollector?: () => Promise<ClientMetrics>
private engineCommandManager: EngineCommandManager private engineCommandManager: EngineCommandManager
private pingPongSpan: { ping?: Date; pong?: Date } private pingPongSpan: { ping?: number; pong?: number }
private pingIntervalId: ReturnType<typeof setInterval> = setInterval( private pingIntervalId: ReturnType<typeof setInterval> = setInterval(() => {},
() => {}, 60_000)
60_000
)
isUsingConnectionLite: boolean = false isUsingConnectionLite: boolean = false
timeoutToForceConnectId: ReturnType<typeof setTimeout> = setTimeout(() => {}, timeoutToForceConnectId: ReturnType<typeof setTimeout> = setTimeout(() => {},
@ -346,7 +344,7 @@ class EngineConnection extends EventTarget {
this.send({ type: 'ping' }) this.send({ type: 'ping' })
this.pingPongSpan = { this.pingPongSpan = {
ping: new Date(), ping: Date.now(),
pong: undefined, pong: undefined,
} }
}, pingIntervalMs) }, pingIntervalMs)
@ -909,7 +907,7 @@ class EngineConnection extends EventTarget {
// Send an initial ping // Send an initial ping
this.send({ type: 'ping' }) this.send({ type: 'ping' })
this.pingPongSpan.ping = new Date() this.pingPongSpan.ping = Date.now()
} }
this.websocket.addEventListener('open', this.onWebSocketOpen) this.websocket.addEventListener('open', this.onWebSocketOpen)
@ -1004,12 +1002,14 @@ class EngineConnection extends EventTarget {
switch (resp.type) { switch (resp.type) {
case 'pong': case 'pong':
this.pingPongSpan.pong = new Date() this.pingPongSpan.pong = Date.now()
this.dispatchEvent( this.dispatchEvent(
new CustomEvent(EngineConnectionEvents.PingPongChanged, { new CustomEvent(EngineConnectionEvents.PingPongChanged, {
detail: Math.min( detail: Math.min(
999, 999,
Math.floor(this.pingPongSpan.pong - this.pingPongSpan.ping) Math.floor(
this.pingPongSpan.pong - (this.pingPongSpan.ping ?? 0)
)
), ),
}) })
) )
@ -1176,7 +1176,7 @@ class EngineConnection extends EventTarget {
// Do not change this back to an object or any, we should only be sending the // Do not change this back to an object or any, we should only be sending the
// WebSocketRequest type! // WebSocketRequest type!
unreliableSend(message: Models['WebSocketRequest_type']) { unreliableSend(message: Models['WebSocketRequest_type']) {
if (this.unreliableDataChannel.readyState !== 'open') return if (this.unreliableDataChannel?.readyState !== 'open') return
// TODO(paultag): Add in logic to determine the connection state and // TODO(paultag): Add in logic to determine the connection state and
// take actions if needed? // take actions if needed?

View File

@ -223,16 +223,35 @@ export function createSettings() {
value: settingValueInStorage, value: settingValueInStorage,
updateValue: writeSettingValueToStorage, updateValue: writeSettingValueToStorage,
}) => { }) => {
const [timeoutId, setTimeoutId] = useState(undefined) const [timeoutId, setTimeoutId] = useState<
ReturnType<typeof setTimeout> | undefined
>(undefined)
const [preview, setPreview] = useState( const [preview, setPreview] = useState(
settingValueInStorage === undefined settingValueInStorage === undefined
? settingValueInStorage ? settingValueInStorage
: settingValueInStorage / MS_IN_MINUTE : settingValueInStorage / MS_IN_MINUTE
) )
const onChangeRange = (e: React.SyntheticEvent) => const onChangeRange = (e: React.SyntheticEvent) => {
setPreview(e.currentTarget.value) if (
!(
e.isTrusted &&
'value' in e.currentTarget &&
e.currentTarget.value
)
)
return
setPreview(Number(e.currentTarget.value))
}
const onSaveRange = (e: React.SyntheticEvent) => { const onSaveRange = (e: React.SyntheticEvent) => {
if (preview === undefined) return if (preview === undefined) return
if (
!(
e.isTrusted &&
'value' in e.currentTarget &&
e.currentTarget.value
)
)
return
writeSettingValueToStorage( writeSettingValueToStorage(
Number(e.currentTarget.value) * MS_IN_MINUTE Number(e.currentTarget.value) * MS_IN_MINUTE
) )
@ -241,6 +260,7 @@ export function createSettings() {
return ( return (
<div className="flex item-center gap-4 m-0 py-0"> <div className="flex item-center gap-4 m-0 py-0">
<Toggle <Toggle
name="streamIdleModeToggle"
offLabel="Off" offLabel="Off"
onLabel="On" onLabel="On"
checked={settingValueInStorage !== undefined} checked={settingValueInStorage !== undefined}