Import the client, server, skills, tests, and build scripts as the starting point for the rebuild, then trim the surfaces this project does not ship: Electron desktop packaging, the marketing website, and the ESP32 firmware tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows. Rename the package and CLI entry points to hermes-ui, drop the prepare hook so npm ci no longer triggers a build, and drop the removed tsconfig and nodemon references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs so the documented package map and hard rules match this repository. reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
47 lines
2.1 KiB
TypeScript
47 lines
2.1 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
import { mockHermesApi, TEST_ACCESS_KEY } from './fixtures'
|
|
|
|
test('redirects protected routes to the login screen without a token', async ({ page }) => {
|
|
const api = await mockHermesApi(page)
|
|
|
|
await page.goto('/#/hermes/jobs')
|
|
|
|
await expect(page).toHaveURL(/#\/$/)
|
|
await expect(page.getByRole('heading', { name: 'Hermes Studio' })).toBeVisible()
|
|
await expect(page.getByPlaceholder('Username')).toBeVisible()
|
|
await expect(page.getByPlaceholder('Password')).toBeVisible()
|
|
expect(api.unexpectedRequests).toEqual([])
|
|
})
|
|
|
|
test('rejects invalid credentials without persisting a token', async ({ page }) => {
|
|
const api = await mockHermesApi(page, { tokenValidationStatus: 401 })
|
|
|
|
await page.goto('/')
|
|
await page.getByPlaceholder('Username').fill('playwright')
|
|
await page.getByPlaceholder('Password').fill('bad-password')
|
|
await page.getByRole('button', { name: 'Login' }).click()
|
|
|
|
await expect(page.getByText('Invalid username or password')).toBeVisible()
|
|
await expect(page).toHaveURL(/#\/$/)
|
|
await expect(page.evaluate(() => window.localStorage.getItem('hermes_api_key'))).resolves.toBeNull()
|
|
expect(api.unexpectedRequests).toEqual([])
|
|
})
|
|
|
|
test('logs in with password through the BFF before entering the app', async ({ page }) => {
|
|
const api = await mockHermesApi(page)
|
|
|
|
await page.goto('/')
|
|
await page.getByPlaceholder('Username').fill('playwright')
|
|
await page.getByPlaceholder('Password').fill('correct-password')
|
|
await page.getByRole('button', { name: 'Login' }).click()
|
|
|
|
await expect(page).toHaveURL(/#\/hermes\/chat$/)
|
|
await expect(page.evaluate(() => window.localStorage.getItem('hermes_api_key'))).resolves.toBe(TEST_ACCESS_KEY)
|
|
await expect.poll(() => api.requests.some((request) => request.pathname === '/health')).toBe(true)
|
|
|
|
const loginRequest = api.requests.find((request) => request.pathname === '/api/auth/login')
|
|
expect(loginRequest?.method).toBe('POST')
|
|
expect(loginRequest?.postData).toBe(JSON.stringify({ username: 'playwright', password: 'correct-password' }))
|
|
expect(api.unexpectedRequests).toEqual([])
|
|
})
|