|
| 1 | +/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | + |
| 5 | +import { expect, test } from '../../lib/fixtures/standard'; |
| 6 | + |
| 7 | +const ADMIN_PANEL_URL = process.env.ADMIN_PANEL_URL ?? 'http://localhost:8091'; |
| 8 | +const ADMIN_SERVER_URL = process.env.ADMIN_SERVER_URL ?? 'http://localhost:8095'; |
| 9 | + |
| 10 | +// Admin panel tests only run locally (stage/prod require SSO) |
| 11 | +test.skip(({ target }) => target.name !== 'local'); |
| 12 | + |
| 13 | +test.describe('Admin Panel', () => { |
| 14 | + test('admin panel loads and renders navigation', async ({ page }) => { |
| 15 | + await page.goto(ADMIN_PANEL_URL); |
| 16 | + await expect( |
| 17 | + page.getByRole('link', { name: /account search/i }) |
| 18 | + ).toBeVisible(); |
| 19 | + }); |
| 20 | + |
| 21 | + test('admin panel heartbeat is healthy', async () => { |
| 22 | + const res = await fetch(`${ADMIN_PANEL_URL}/__lbheartbeat__`); |
| 23 | + expect(res.status).toBe(200); |
| 24 | + }); |
| 25 | + |
| 26 | + test('admin server heartbeat is healthy', async () => { |
| 27 | + const res = await fetch(`${ADMIN_SERVER_URL}/__lbheartbeat__`); |
| 28 | + expect(res.status).toBe(200); |
| 29 | + }); |
| 30 | + |
| 31 | + test('account search by email returns account data via API', async ({ |
| 32 | + target, |
| 33 | + testAccountTracker, |
| 34 | + }) => { |
| 35 | + const credentials = testAccountTracker.generateAccountDetails(); |
| 36 | + await target.createAccount(credentials.email, credentials.password); |
| 37 | + |
| 38 | + const res = await fetch( |
| 39 | + `${ADMIN_SERVER_URL}/api/account/by-email?email=${encodeURIComponent(credentials.email)}`, |
| 40 | + { |
| 41 | + headers: { |
| 42 | + 'oidc-claim-id-token-email': 'test-admin@mozilla.com', |
| 43 | + 'remote-groups': 'vpn_fxa_admin_panel_prod', |
| 44 | + }, |
| 45 | + } |
| 46 | + ); |
| 47 | + expect(res.status).toBe(200); |
| 48 | + const data = await res.json(); |
| 49 | + expect(data.email).toBe(credentials.email); |
| 50 | + }); |
| 51 | + |
| 52 | + test('account search from UI shows results', async ({ |
| 53 | + target, |
| 54 | + page, |
| 55 | + testAccountTracker, |
| 56 | + }) => { |
| 57 | + const credentials = testAccountTracker.generateAccountDetails(); |
| 58 | + await target.createAccount(credentials.email, credentials.password); |
| 59 | + |
| 60 | + await page.goto(`${ADMIN_PANEL_URL}/account-search`); |
| 61 | + |
| 62 | + const searchInput = page.getByRole('textbox'); |
| 63 | + await searchInput.fill(credentials.email); |
| 64 | + await searchInput.press('Enter'); |
| 65 | + |
| 66 | + await expect(page.getByText(credentials.email)).toBeVisible({ |
| 67 | + timeout: 10000, |
| 68 | + }); |
| 69 | + }); |
| 70 | +}); |
0 commit comments