startup-rpc-budget.e2e.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Cold boot may issue at most two settings/describe calls regardless of client
  2. // plugin count. No model call or replay fixture is involved.
  3. import type { Browser, Page } from 'playwright'
  4. import { chromium } from 'playwright'
  5. import { afterAll, beforeAll, describe, expect, it } from 'vitest'
  6. import { launchWebScaffold, watchConsole, type WebScaffold } from './scaffold.ts'
  7. import { newEnglishPage } from './support.ts'
  8. /** One eager read plus one first-connection reset closes the pre-subscription commit window. */
  9. const DESCRIBE_BUDGET = 2
  10. let scaffold: WebScaffold
  11. let browser: Browser
  12. let page: Page
  13. beforeAll(async () => {
  14. scaffold = await launchWebScaffold()
  15. browser = await chromium.launch()
  16. })
  17. afterAll(async () => {
  18. await page?.close()
  19. await browser?.close()
  20. await scaffold?.close()
  21. })
  22. describe('startup RPC budget', () => {
  23. it('keeps cold-boot settings.describe at the mirror count', async () => {
  24. page = await newEnglishPage(browser)
  25. watchConsole(page)
  26. const calls: string[] = []
  27. page.on('request', (request) => {
  28. const url = new URL(request.url())
  29. if (url.pathname.startsWith('/api/')) calls.push(url.pathname.slice('/api/'.length))
  30. })
  31. await page.goto(scaffold.authenticatedUrl)
  32. // Boot settles when the workspace picker is interactive; the trailing wait
  33. // absorbs the first-connection reset wave the budget must include.
  34. await page.getByRole('textbox', { name: 'Choose workspace' }).waitFor({ timeout: 30_000 })
  35. await page.waitForTimeout(3000)
  36. const describeCount = calls.filter(method => method === 'settings/describe').length
  37. expect(describeCount, `startup /api calls:\n${calls.join('\n')}`).toBe(DESCRIBE_BUDGET)
  38. })
  39. })