Scope skills and memory to request profile
This commit is contained in:
+12
-11
@@ -8,37 +8,38 @@ test('redirects protected routes to the login screen without a token', async ({
|
||||
|
||||
await expect(page).toHaveURL(/#\/$/)
|
||||
await expect(page.getByRole('heading', { name: 'Hermes Web UI' })).toBeVisible()
|
||||
await expect(page.getByPlaceholder('Access token')).toBeVisible()
|
||||
await expect(page.getByPlaceholder('Username')).toBeVisible()
|
||||
await expect(page.getByPlaceholder('Password')).toBeVisible()
|
||||
expect(api.unexpectedRequests).toEqual([])
|
||||
})
|
||||
|
||||
test('rejects an invalid access token without persisting it', async ({ page }) => {
|
||||
test('rejects invalid credentials without persisting a token', async ({ page }) => {
|
||||
const api = await mockHermesApi(page, { tokenValidationStatus: 401 })
|
||||
|
||||
await page.goto('/')
|
||||
await page.getByPlaceholder('Access token').fill('bad-token')
|
||||
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 token')).toBeVisible()
|
||||
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('validates token login through the BFF before entering the app', async ({ page }) => {
|
||||
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('Access token').fill(TEST_ACCESS_KEY)
|
||||
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)
|
||||
|
||||
const validationRequest = api.requests.find((request) => (
|
||||
request.pathname === '/api/hermes/sessions' &&
|
||||
request.headers.authorization === `Bearer ${TEST_ACCESS_KEY}`
|
||||
))
|
||||
expect(validationRequest).toBeTruthy()
|
||||
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([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user