guanghu/e2e/settings-oauth.spec.ts
冰朔 8739805f99
Some checks failed
Auto-update PR branches / Update open PR branches (push) Has been cancelled
CI / Frontend Static Quality Checks (push) Has been cancelled
CI / Frontend Tests & Coverage (push) Has been cancelled
CI / Rust Tests & Quality Checks (push) Has been cancelled
CI / Linux build verification (push) Has been cancelled
Release (Alpha) / Compute alpha version (push) Has been cancelled
Release (Alpha) / Build release artifacts (push) Has been cancelled
Release (Alpha) / GitHub Release (alpha) (push) Has been cancelled
Release (Alpha) / Update docs and release pages (push) Has been cancelled
Deploy docs / Build VitePress site (push) Has been cancelled
Deploy docs / Deploy to GitHub Pages (push) Has been cancelled
光湖开源源码快照 · Tolaria AGPL 分叉基线 · 独立更新链
2026-07-05 17:45:16 +08:00

52 lines
1.8 KiB
TypeScript

import { test, expect } from '@playwright/test'
test('settings shows connected GitHub state with username', async ({ page }) => {
await page.goto('http://localhost:5243/')
await page.waitForLoadState('networkidle')
await page.waitForTimeout(500)
// Open settings
await page.keyboard.press('Meta+Comma')
await page.waitForTimeout(500)
// Verify settings panel opened
await expect(page.getByTestId('settings-panel')).toBeVisible()
// Mock data starts with github connected — verify connected state
const connected = page.getByTestId('github-connected')
await expect(connected).toBeVisible({ timeout: 5000 })
await expect(connected).toContainText('lucaong')
await expect(connected).toContainText('Connected')
// Verify disconnect button
await expect(page.getByTestId('github-disconnect')).toBeVisible()
// Verify NO token input field
await expect(page.getByTestId('settings-key-github-token')).not.toBeVisible()
await page.screenshot({ path: 'test-results/settings-oauth-connected.png' })
})
test('disconnect shows Login with GitHub button', async ({ page }) => {
await page.goto('http://localhost:5243/')
await page.waitForLoadState('networkidle')
await page.waitForTimeout(500)
// Open settings
await page.keyboard.press('Meta+Comma')
await page.waitForTimeout(500)
// Click disconnect
const disconnectBtn = page.getByTestId('github-disconnect')
await expect(disconnectBtn).toBeVisible({ timeout: 5000 })
await disconnectBtn.click()
await page.waitForTimeout(300)
// Login button should now be visible
const loginBtn = page.getByTestId('github-login')
await expect(loginBtn).toBeVisible({ timeout: 3000 })
await expect(loginBtn).toContainText('Login with GitHub')
await page.screenshot({ path: 'test-results/settings-oauth-login.png' })
})