Compare commits
4 Commits
feat/FIBER
...
fix/FIBERO
| Author | SHA1 | Date | |
|---|---|---|---|
| 73012d52d3 | |||
| 546c32fc55 | |||
|
|
43379905f9 | ||
| 2b047055a2 |
42
e2e/portal.spec.ts
Normal file
42
e2e/portal.spec.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test.describe('Subscriber Portal', () => {
|
||||||
|
test('portal login page loads', async ({ page }) => {
|
||||||
|
await page.goto('/portal/login');
|
||||||
|
await page.waitForTimeout(2000);
|
||||||
|
await expect(page.locator('input[type="text"], input[placeholder*="account" i]').first()).toBeVisible({ timeout: 10000 });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('portal login page has password field', async ({ page }) => {
|
||||||
|
await page.goto('/portal/login');
|
||||||
|
await page.waitForTimeout(2000);
|
||||||
|
await expect(page.locator('input[type="password"]')).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('portal login page shows FiberOps branding', async ({ page }) => {
|
||||||
|
await page.goto('/portal/login');
|
||||||
|
await page.waitForTimeout(2000);
|
||||||
|
await expect(page.locator('text=FiberOps').first()).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('portal login redirects to dashboard on wrong creds', async ({ page }) => {
|
||||||
|
await page.goto('/portal/login');
|
||||||
|
await page.waitForTimeout(2000);
|
||||||
|
// Fill and submit
|
||||||
|
const inputs = page.locator('input');
|
||||||
|
const count = await inputs.count();
|
||||||
|
if (count >= 3) {
|
||||||
|
await inputs.nth(0).fill('demo-isp');
|
||||||
|
await inputs.nth(1).fill('ACC-000001');
|
||||||
|
await inputs.nth(2).fill('wrongpassword');
|
||||||
|
}
|
||||||
|
// Should stay on login (not crash)
|
||||||
|
const btn = page.locator('button[type="submit"], button:has-text("Login"), button:has-text("Sign In")').first();
|
||||||
|
if (await btn.isVisible()) {
|
||||||
|
await btn.click();
|
||||||
|
await page.waitForTimeout(3000);
|
||||||
|
}
|
||||||
|
// Should not crash — still render something
|
||||||
|
await expect(page.locator('body')).toBeVisible();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const portalApi = axios.create({
|
const portalApi = axios.create({
|
||||||
baseURL: process.env.NEXT_PUBLIC_API_URL || 'https://fiberops-api.juankibin.space',
|
baseURL: process.env.NEXT_PUBLIC_API_URL || 'http://192.168.1.167:3001',
|
||||||
});
|
});
|
||||||
|
|
||||||
portalApi.interceptors.request.use((config) => {
|
portalApi.interceptors.request.use((config) => {
|
||||||
|
|||||||
@@ -30,16 +30,12 @@ export const usePortalAuthStore = create<PortalAuthState>()(
|
|||||||
accountNumber,
|
accountNumber,
|
||||||
password,
|
password,
|
||||||
});
|
});
|
||||||
const { token, subscriber } = res.data;
|
const { accessToken } = res.data;
|
||||||
localStorage.setItem('portal_token', token);
|
localStorage.setItem('portal_token', accessToken);
|
||||||
set({
|
set({
|
||||||
portalToken: token,
|
portalToken: accessToken,
|
||||||
tenantSlug,
|
tenantSlug,
|
||||||
subscriber: {
|
subscriber: { accountNumber, firstName: '', lastName: '' },
|
||||||
accountNumber: subscriber.accountNumber,
|
|
||||||
firstName: subscriber.firstName,
|
|
||||||
lastName: subscriber.lastName,
|
|
||||||
},
|
|
||||||
isAuthenticated: true,
|
isAuthenticated: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user