feat(frontend): require landlord profile completion
This commit is contained in:
1 parent
983a080cc7
commit
12316b8604
18 files changed
+838
-217
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import { expect, Page, test } from '@playwright/test';
|
||||
|
||||
async function mockUser(page: Page, authenticated: boolean): Promise<void> {
|
||||
async function mockUser(page: Page, authenticated: boolean, completeProfile = true): Promise<void> {
|
||||
await page.unroute('**/api/user');
|
||||
await page.unroute('**/api/landlord-profile');
|
||||
await page.route('**/api/user', async (route) => {
|
||||
await route.fulfill({
|
||||
contentType: 'application/json',
|
||||
@@ -10,6 +11,23 @@ async function mockUser(page: Page, authenticated: boolean): Promise<void> {
|
||||
: { authenticated: false, username: '', email: '' },
|
||||
});
|
||||
});
|
||||
if (!authenticated) return;
|
||||
|
||||
const profile = {
|
||||
firstName: 'Alice',
|
||||
lastName: 'Martin',
|
||||
email: 'alice@example.com',
|
||||
phone: completeProfile ? '+33600000000' : '',
|
||||
address: completeProfile ? '1 rue de Paris' : '',
|
||||
complete: completeProfile,
|
||||
version: 0,
|
||||
};
|
||||
await page.route('**/api/landlord-profile', async (route) => {
|
||||
if (route.request().method() === 'PUT') {
|
||||
Object.assign(profile, route.request().postDataJSON(), { complete: true, version: 1 });
|
||||
}
|
||||
await route.fulfill({ contentType: 'application/json', json: profile });
|
||||
});
|
||||
}
|
||||
|
||||
async function mockEmptyApartmentList(page: Page): Promise<void> {
|
||||
@@ -49,6 +67,25 @@ test('starts the OIDC login flow from the sign-in screen', async ({ page }) => {
|
||||
await expect(page).toHaveURL(/\/oauth2\/authorization\/oidc$/);
|
||||
});
|
||||
|
||||
test('requires a newly connected landlord to complete their profile', async ({ page }) => {
|
||||
await mockUser(page, true, false);
|
||||
|
||||
await page.goto('/');
|
||||
|
||||
const dialog = page.getByRole('dialog');
|
||||
await expect(dialog.getByRole('heading', { name: 'Complétez votre profil' })).toBeVisible();
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(dialog.getByRole('button', { name: 'Déconnexion' })).toBeVisible();
|
||||
|
||||
await dialog.getByLabel('Téléphone').fill('+33612345678');
|
||||
await dialog.getByLabel('Adresse postale').fill('1 rue des Lilas, Lyon');
|
||||
await dialog.getByRole('button', { name: 'Enregistrer le profil' }).click();
|
||||
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(page.getByTestId('primary-navigation')).toBeVisible();
|
||||
});
|
||||
|
||||
test('persists a dark appearance preference from Settings', async ({ page }) => {
|
||||
await mockUser(page, true);
|
||||
await mockEmptyApartmentList(page);
|
||||
|
||||
Reference in new issue
Block a user