Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 27 additions & 45 deletions e2e/core-beta-args-pill-commit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import {
waitForWebContents,
type WebContentsPage,
} from './support/cdpPages'
import { getIpcInvocations, resetIpcInvocations } from './support/devHooks'
import {
expectNoBetaArgsPill,
openWithBetaArgsAnswers,
type BetaArgsOpen,
} from './support/betaArgsAnswers'
import { opsFlagsGrantSeed, reserveFreePort, writeFakeComfyInstall } from './support/fakeComfyInstall'
import { byTestId, TID } from './support/testIds'

Expand Down Expand Up @@ -124,64 +128,42 @@ test.afterAll(async () => {
else process.env['POSTHOG_HOST'] = previousPosthogHost
})

async function openStartupArgs(): Promise<WebContentsPage> {
async function openStartupArgs(): Promise<BetaArgsOpen> {
await closeTitlePopupIfOpen(ctx.app)
await new Promise((resolve) => setTimeout(resolve, TITLE_REOPEN_SUPPRESSION_MS))
await ctx.panel.evaluate(
`window.api.openInstancePicker({ installationId: ${JSON.stringify(INSTALL_ID)}, initialTab: 'config' })`,
)
await waitForWebContents(ctx.app, 'comfyTitlePopup.html')
const popup = titlePopupPage(ctx.app)
await popup.waitForVisible(byTestId(TID.pickerSettingsSections), { timeout: 15_000 })
await popup.waitForVisible(`${ARGS_FIELD} .ui-input`, { timeout: 10_000 })
return popup
return openWithBetaArgsAnswers(ctx.app, async () => {
await ctx.panel.evaluate(
`window.api.openInstancePicker({ installationId: ${JSON.stringify(INSTALL_ID)}, initialTab: 'config' })`,
)
await waitForWebContents(ctx.app, 'comfyTitlePopup.html')
const popup = titlePopupPage(ctx.app)
await popup.waitForVisible(byTestId(TID.pickerSettingsSections), { timeout: 15_000 })
await popup.waitForVisible(`${ARGS_FIELD} .ui-input`, { timeout: 10_000 })
return popup
})
}

const pillLabel = (popup: WebContentsPage): Promise<string | null> =>
popup.evaluate<string | null>(
`document.querySelector(${JSON.stringify(PILL)})?.getAttribute('aria-label') ?? null`,
)

/** Open with the request count reset, so absence can be read against this open's own answers. */
async function openCounted(): Promise<WebContentsPage> {
await resetIpcInvocations(ctx.app, 'get-core-beta-args')
return openStartupArgs()
}

/**
* The pill renders nothing both before its answer and for an empty one, so absence only means
* something once the answers are in. A fresh open asks twice (on mount, and again once the args
* field's schema load settles), so wait for both, then require no pill and no loading placeholder
* for long enough that a late answer would have shown.
*/
async function expectAnsweredWithNoPill(popup: WebContentsPage, message: string): Promise<void> {
await expect
.poll(async () => (await getIpcInvocations(ctx.app, 'get-core-beta-args')).length, {
timeout: 15_000,
intervals: [100, 200],
})
.toBeGreaterThanOrEqual(2)
const deadline = Date.now() + 2_000
while (Date.now() < deadline) {
expect(await pillLabel(popup), message).toBeNull()
expect(await popup.exists(`${ARGS_FIELD} .beta-args-loading`), message).toBe(false)
await new Promise((resolve) => setTimeout(resolve, 200))
}
}

test('a commit grant whose range contains HEAD shows before any launch @linux', async () => {
const popup = await openStartupArgs()
const { popup } = await openStartupArgs()
await popup.waitForVisible(PILL, { timeout: 15_000 })
expect(await pillLabel(popup)).toBe('1 beta argument eligible for the next launch, show details')
})

test('moving HEAD below the range hides it @linux', async () => {
git('reset', '-q', '--hard', sha.base!)
const popup = await openCounted()
await expectAnsweredWithNoPill(popup, 'the grant was still shown with HEAD below its range')
await expectNoBetaArgsPill(
ctx.app,
await openStartupArgs(),
'the grant was still shown with HEAD below its range',
)
git('reset', '-q', '--hard', sha.head!)
const back = await openStartupArgs()
await back.waitForVisible(PILL, { timeout: 15_000 })
const { popup } = await openStartupArgs()
await popup.waitForVisible(PILL, { timeout: 15_000 })
})

test('an object store git cannot read hides the grant, and the settings view still loads @linux', async () => {
Expand All @@ -191,7 +173,7 @@ test('an object store git cannot read hides the grant, and the settings view sti
for (const entry of await readdir(objects)) {
if (entry !== 'info') await rm(path.join(objects, entry), { recursive: true, force: true })
}
const popup = await openCounted()
await expectAnsweredWithNoPill(popup, 'the grant was shown though git could not prove it')
expect(await popup.exists(`${ARGS_FIELD} input`)).toBe(true)
const opened = await openStartupArgs()
await expectNoBetaArgsPill(ctx.app, opened, 'the grant was shown though git could not prove it')
expect(await opened.popup.exists(`${ARGS_FIELD} input`)).toBe(true)
})
30 changes: 19 additions & 11 deletions e2e/core-beta-args-pill-restart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import { launchApp, type AppContext } from './launchApp'
import { clickInstallTile, expectChooserVisible, openPickerViaTitlePill } from './support/chooserHelpers'
import { closeTitlePopupIfOpen, isPopupVisible, type WebContentsPage } from './support/cdpPages'
import { getRunningSessionSnapshot } from './support/devHooks'
import {
expectNoBetaArgsPill,
openWithBetaArgsAnswers,
type BetaArgsOpen,
} from './support/betaArgsAnswers'
import { opsFlagsGrantSeed, reserveFreePort, writeFakeComfyInstall } from './support/fakeComfyInstall'
import { byTestId, TID } from './support/testIds'

Expand Down Expand Up @@ -83,11 +88,13 @@ test.afterAll(async () => {
else process.env['POSTHOG_HOST'] = previousPosthogHost
})

async function openStartupArgs(): Promise<WebContentsPage> {
async function openStartupArgs(): Promise<BetaArgsOpen> {
await closeTitlePopupIfOpen(ctx.app)
const popup = await openPickerViaTitlePill(ctx.app, ctx.titleBar, 'config')
await popup.waitForVisible(`${ARGS_FIELD} .ui-input`, { timeout: 15_000 })
return popup
return openWithBetaArgsAnswers(ctx.app, async () => {
const popup = await openPickerViaTitlePill(ctx.app, ctx.titleBar, 'config')
await popup.waitForVisible(`${ARGS_FIELD} .ui-input`, { timeout: 15_000 })
return popup
})
}

const pillLabel = (popup: WebContentsPage): Promise<string | null> =>
Expand All @@ -105,7 +112,7 @@ test('the pill follows the new session after a Restart that drops a grant @linux
})
.not.toBeNull()

let popup = await openStartupArgs()
const { popup } = await openStartupArgs()
await popup.waitForVisible(PILL, { timeout: 15_000 })
expect(await pillLabel(popup)).toBe('1 beta argument added for this session, show details')

Expand Down Expand Up @@ -143,13 +150,14 @@ test('the pill follows the new session after a Restart that drops a grant @linux
)
.toBe(true)

popup = await openStartupArgs()
await popup.waitFor(async () => (await pillLabel(popup)) === null, {
timeout: 10_000,
message: "the pill still showed the previous session's grant after the restart",
})
const reopened = await openStartupArgs()
await expectNoBetaArgsPill(
ctx.app,
reopened,
"the pill still showed the previous session's grant after the restart",
)
// The new session consumed the edit, so nothing is pending any more.
await popup.waitFor(async () => !(await popup.exists(RESTART_TAG)), {
await reopened.popup.waitFor(async () => !(await reopened.popup.exists(RESTART_TAG)), {
timeout: 10_000,
message: '"Restart to apply" was still shown after the restart',
})
Expand Down
66 changes: 34 additions & 32 deletions e2e/core-beta-args-pill-stopped.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import {
import { opsFlagsGrantSeed, reserveFreePort, writeFakeComfyInstall } from './support/fakeComfyInstall'
import { byTestId, TID } from './support/testIds'
import { getIpcInvocations, resetIpcInvocations } from './support/devHooks'
import {
expectNoBetaArgsPill,
openWithBetaArgsAnswers,
type BetaArgsOpen,
} from './support/betaArgsAnswers'

test.describe.configure({ mode: 'serial' })

Expand Down Expand Up @@ -96,17 +101,19 @@ test.afterAll(async () => {
else process.env['POSTHOG_HOST'] = previousPosthogHost
})

async function openStartupArgs(): Promise<WebContentsPage> {
async function openStartupArgs(): Promise<BetaArgsOpen> {
await closeTitlePopupIfOpen(ctx.app)
await new Promise((resolve) => setTimeout(resolve, TITLE_REOPEN_SUPPRESSION_MS))
await ctx.panel.evaluate(
`window.api.openInstancePicker({ installationId: ${JSON.stringify(INSTALL_ID)}, initialTab: 'config' })`,
)
await waitForWebContents(ctx.app, 'comfyTitlePopup.html')
const popup = titlePopupPage(ctx.app)
await popup.waitForVisible(byTestId(TID.pickerSettingsSections), { timeout: 15_000 })
await popup.waitForVisible(`${ARGS_FIELD} .ui-input`, { timeout: 10_000 })
return popup
return openWithBetaArgsAnswers(ctx.app, async () => {
await ctx.panel.evaluate(
`window.api.openInstancePicker({ installationId: ${JSON.stringify(INSTALL_ID)}, initialTab: 'config' })`,
)
await waitForWebContents(ctx.app, 'comfyTitlePopup.html')
const popup = titlePopupPage(ctx.app)
await popup.waitForVisible(byTestId(TID.pickerSettingsSections), { timeout: 15_000 })
await popup.waitForVisible(`${ARGS_FIELD} .ui-input`, { timeout: 10_000 })
return popup
})
}

async function pillAriaLabel(popup: WebContentsPage): Promise<string | null> {
Expand All @@ -115,16 +122,8 @@ async function pillAriaLabel(popup: WebContentsPage): Promise<string | null> {
)
}

/** Absence is a real answer only against a fresh sections read. Every caller reaches here from the
* Desktop Settings popup kind, which unmounts the picker, so the args field `openStartupArgs` waited
* for was rendered from this open's own response. The schema is already cached by then, so no
* discovery-driven re-read is still coming either. */
async function expectNoPill(popup: WebContentsPage): Promise<void> {
expect(await pillAriaLabel(popup)).toBeNull()
}

test('shows the grants the next launch is eligible for @linux', async () => {
const popup = await openStartupArgs()
const { popup } = await openStartupArgs()
// First open: the field's own schema discovery fills the cache, then the pill asks again.
await popup.waitForVisible(PILL, { timeout: 15_000 })
expect(await pillAriaLabel(popup)).toBe(
Expand All @@ -140,7 +139,7 @@ test('shows the grants the next launch is eligible for @linux', async () => {
})

test('turning the beta opt-in off removes the pill on the next open, and on restores it @linux', async () => {
let popup = await openStartupArgs()
let { popup } = await openStartupArgs()
await popup.waitForVisible(PILL, { timeout: 10_000 })
await popup.clickUntilVisible(PILL, MANAGE, { timeout: 10_000 })
expect(await popup.click(MANAGE)).toBe(true)
Expand All @@ -153,8 +152,11 @@ test('turning the beta opt-in off removes the pill on the next open, and on rest
expect(await popup.click(BETA_SWITCH)).toBe(true)
await popup.waitFor(async () => (await checked()) === 'false', { timeout: 5_000 })

popup = await openStartupArgs()
await expectNoPill(popup)
await expectNoBetaArgsPill(
ctx.app,
await openStartupArgs(),
'the pill was shown on the next open after the beta opt-in was turned off',
)

await closeTitlePopupIfOpen(ctx.app)
await new Promise((resolve) => setTimeout(resolve, TITLE_REOPEN_SUPPRESSION_MS))
Expand All @@ -167,27 +169,27 @@ test('turning the beta opt-in off removes the pill on the next open, and on rest
expect(await popup.click(BETA_SWITCH)).toBe(true)
await popup.waitFor(async () => (await checked()) === 'true', { timeout: 5_000 })

popup = await openStartupArgs()
popup = (await openStartupArgs()).popup
await popup.waitForVisible(PILL, { timeout: 10_000 })
})

test('an opt-in change made while the picker is hidden shows on reopen @linux', async () => {
let popup = await openStartupArgs()
const { popup } = await openStartupArgs()
await popup.waitForVisible(PILL, { timeout: 10_000 })
// Hidden, not swapped: the cached picker keeps its sections, which is what could go stale.
await closeTitlePopupIfOpen(ctx.app)
await ctx.panel.evaluate(`window.api.setSetting('betaFeaturesEnabled', false)`)

popup = await openStartupArgs()
await popup.waitFor(async () => (await pillAriaLabel(popup)) === null, {
timeout: 10_000,
message: 'the pill survived an opt-out made while the picker was hidden',
})
await expectNoBetaArgsPill(
ctx.app,
await openStartupArgs(),
'the pill survived an opt-out made while the picker was hidden',
)

await closeTitlePopupIfOpen(ctx.app)
await ctx.panel.evaluate(`window.api.setSetting('betaFeaturesEnabled', true)`)
popup = await openStartupArgs()
await popup.waitForVisible(PILL, { timeout: 10_000 })
const reopened = await openStartupArgs()
await reopened.popup.waitForVisible(PILL, { timeout: 10_000 })
})

const betaArgsRequests = async (): Promise<number> =>
Expand All @@ -206,7 +208,7 @@ async function commitArgs(popup: WebContentsPage, value: string): Promise<void>
}

test('only the pill asks: another field\'s save asks nothing, an args commit asks once @linux', async () => {
const popup = await openStartupArgs()
const { popup } = await openStartupArgs()
await popup.waitForVisible(PILL, { timeout: 10_000 })
await resetIpcInvocations(ctx.app, 'get-core-beta-args')

Expand All @@ -231,7 +233,7 @@ test('only the pill asks: another field\'s save asks nothing, an args commit ask
})

test("adding the grant's opposite to the startup args removes it @linux", async () => {
const popup = await openStartupArgs()
const { popup } = await openStartupArgs()
await popup.waitForVisible(PILL, { timeout: 10_000 })
// Commit through the input's own change event, as a blur would.
await popup.evaluate(
Expand Down
44 changes: 25 additions & 19 deletions e2e/core-beta-args-pill.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ import {
titlePopupPage,
TITLE_REOPEN_SUPPRESSION_MS,
waitForWebContents,
type WebContentsPage,
} from './support/cdpPages'
import { clearRunningSessions, seedRunningSession } from './support/devHooks'
import {
expectNoBetaArgsPill,
openWithBetaArgsAnswers,
type BetaArgsOpen,
} from './support/betaArgsAnswers'
import { byTestId, TID } from './support/testIds'

test.describe.configure({ mode: 'serial' })
Expand Down Expand Up @@ -73,31 +77,33 @@ test.afterAll(async () => {
})

/** Open the picker on the install's Startup Args and wait until its args field has rendered. */
async function openStartupArgs(): Promise<WebContentsPage> {
async function openStartupArgs(): Promise<BetaArgsOpen> {
await closeTitlePopupIfOpen(ctx.app)
await new Promise((resolve) => setTimeout(resolve, TITLE_REOPEN_SUPPRESSION_MS))
const opened = await ctx.panel.evaluate<boolean>(
`(() => {
window.api.openInstancePicker({ installationId: ${JSON.stringify(INSTALL_ID)}, initialTab: 'config' })
return true
})()`,
)
expect(opened).toBe(true)
await waitForWebContents(ctx.app, 'comfyTitlePopup.html')
const popup = titlePopupPage(ctx.app)
await popup.waitForVisible(byTestId(TID.pickerSettingsSections), { timeout: 15_000 })
await popup.waitForVisible(`${ARGS_FIELD} .ui-input`, { timeout: 10_000 })
return popup
return openWithBetaArgsAnswers(ctx.app, async () => {
const opened = await ctx.panel.evaluate<boolean>(
`(() => {
window.api.openInstancePicker({ installationId: ${JSON.stringify(INSTALL_ID)}, initialTab: 'config' })
return true
})()`,
)
expect(opened).toBe(true)
await waitForWebContents(ctx.app, 'comfyTitlePopup.html')
const popup = titlePopupPage(ctx.app)
await popup.waitForVisible(byTestId(TID.pickerSettingsSections), { timeout: 15_000 })
await popup.waitForVisible(`${ARGS_FIELD} .ui-input`, { timeout: 10_000 })
return popup
})
}

// This fixture has no interpreter, so the settings view's schema discovery fails and the next-launch
// preview (which only reads a cached schema) cannot be computed: the pill must stay away rather than
// guess. The predictable stopped case is `core-beta-args-pill-stopped.test.ts`.
test('a stopped install whose next launch cannot be predicted shows no beta pill @windows @macos @linux', async () => {
const popup = await openStartupArgs()
// The args field is on screen (waited above), so the pill's absence is a real answer.
expect(await popup.evaluate<boolean>(`!!document.querySelector(${JSON.stringify(PILL)})`)).toBe(
false,
await expectNoBetaArgsPill(
ctx.app,
await openStartupArgs(),
'a pill was shown for a next launch that cannot be predicted',
)
})

Expand All @@ -110,7 +116,7 @@ test('a running install shows its grants and links to the beta opt-in @windows @
{ arg: '--enable-asset-hashing', name: null },
],
})
const popup = await openStartupArgs()
const { popup } = await openStartupArgs()

await popup.waitForVisible(PILL, { timeout: 10_000 })
const pill = await popup.evaluate<{ text: string; expanded: string | null }>(
Expand Down
Loading
Loading