settings.test.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { test, expect, type TestFixtures } from "./playwright-base-test"
  2. import {
  3. findWebview,
  4. upsertApiConfiguration,
  5. verifyExtensionInstalled,
  6. clickSaveSettingsButton,
  7. waitForTooltipsToDismiss,
  8. } from "../helpers"
  9. test.describe("Settings", () => {
  10. test("screenshots", async ({ workbox: page, takeScreenshot }: TestFixtures) => {
  11. await verifyExtensionInstalled(page)
  12. await upsertApiConfiguration(page)
  13. // Open the settings then move the mouse to avoid triggering the tooltip
  14. const webviewFrame = await findWebview(page)
  15. await page.locator('[aria-label*="Settings"], [title*="Settings"]').first().click()
  16. await page.mouse.move(0, 0) // Move cursor to top-left corner to avoid triggering hover states
  17. await clickSaveSettingsButton(webviewFrame)
  18. await expect(webviewFrame.locator('[role="tablist"]')).toBeVisible({ timeout: 10000 })
  19. console.log("✅ Settings view loaded")
  20. await expect(webviewFrame.locator('[data-testid="settings-tab-list"]')).toBeVisible()
  21. console.log("✅ Settings tab list visible")
  22. const tabButtons = webviewFrame.locator('[role="tab"]')
  23. const tabCount = await tabButtons.count()
  24. console.log(`✅ Found ${tabCount} settings tabs`)
  25. // Take screenshot of each tab (except for the last two)
  26. // MCP settings page is flakey and the info page has the version which changes
  27. for (let i = 0; i < tabCount - 2; i++) {
  28. const tabButton = tabButtons.nth(i)
  29. await tabButton.click()
  30. await page.waitForTimeout(500)
  31. const tabText = await tabButton.textContent()
  32. const tabName = tabText?.trim() || `tab-${i}`
  33. const testId = await tabButton.getAttribute("data-testid")
  34. const sectionId = testId?.replace("tab-", "") || `section-${i}`
  35. await clickSaveSettingsButton(webviewFrame) // To avoid flakey screenshots
  36. await waitForTooltipsToDismiss(webviewFrame) // Wait for tooltips to dismiss before screenshot
  37. await takeScreenshot(`${i}-settings-${sectionId}-${tabName.toLowerCase().replace(/\s+/g, "-")}`)
  38. }
  39. console.log("✅ All settings tabs screenshots completed")
  40. })
  41. })