Files
wehub-resource-sync 3a28426bf4
Lint and Format Check / lint-and-format (push) Failing after 0s
Check Migrations / Check for duplicate migration numbers (push) Failing after 1s
CI Pre-merge Check / CI Pre-merge Check (push) Failing after 2m17s
chore: import upstream snapshot with attribution
2026-07-13 12:23:40 +08:00

33 lines
1.2 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { mockLoggedOutApi, mockSelfHostingDashboardApi } from './fixtures/api';
test('signs in with mocked self-hosting admin credentials', async ({ page }) => {
await mockSelfHostingDashboardApi(page);
await page.goto('/dashboard/login');
await expect(page.getByRole('heading', { name: 'Insforge Admin' })).toBeVisible();
await page.locator('input[name="username"]').fill('admin');
await page.locator('input[type="password"]').fill('test-admin-password-for-ci');
const loginResponse = page.waitForResponse(
(response) =>
response.url().includes('/api/auth/admin/sessions') && response.request().method() === 'POST'
);
await page.getByRole('button', { name: 'Sign in' }).click();
expect((await loginResponse).status()).toBe(200);
await expect(page).toHaveURL(/\/dashboard$/);
});
test('redirects unauthenticated dashboard visitors to the self-hosting login page', async ({
page,
}) => {
await mockLoggedOutApi(page);
await page.goto('/dashboard');
await expect(page).toHaveURL(/\/dashboard\/login$/);
await expect(page.getByRole('heading', { name: 'Insforge Admin' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Sign in' })).toBeVisible();
});