fix: preserve week-long sessions and add profile mascot
Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
fbc827c2b8
commit
f32289f583
18 files changed
+240
-25
No files matched your search
@@ -4,6 +4,46 @@ const appUrl = process.env.CONVIVO_BASE_URL || 'http://localhost:3000';
|
||||
const notice = 'If this email belongs to an eligible admin account, a sign-in link has been sent.';
|
||||
const invalidLink = 'This sign-in link is invalid or expired. Please request a new link.';
|
||||
|
||||
test.describe('Profile Manfred', () => {
|
||||
for (const viewport of [{ width: 360, height: 800 }, { width: 1280, height: 900 }]) {
|
||||
test(`randomizes on entry and refresh without shifting the layout at ${viewport.width}px`, async ({ page }, testInfo) => {
|
||||
await page.setViewportSize(viewport);
|
||||
await page.addInitScript(() => {
|
||||
Math.random = () => Number(sessionStorage.getItem('test-manfred-choice') || '0.01');
|
||||
});
|
||||
const { session } = await mockApi(page, { registered: true, checkedIn: true });
|
||||
await page.goto(`${appUrl}/auth/callback#access_token=${session.access_token}&refresh_token=${session.refresh_token}&type=magiclink`);
|
||||
await expect(page.getByTestId('tab-home')).toBeVisible();
|
||||
const mascot = page.getByTestId('profile-manfred');
|
||||
const poses = ['confident', 'coffee', 'celebrating', 'waving'];
|
||||
for (const [index, pose] of poses.entries()) {
|
||||
await page.evaluate((choice) => sessionStorage.setItem('test-manfred-choice', String(choice)), (index + 0.1) / 4);
|
||||
await page.getByTestId('tab-profile').click();
|
||||
await expect(mascot).toHaveAttribute('src', `/manfred/${pose}.webp`);
|
||||
await expect.poll(() => mascot.evaluate((image: HTMLImageElement) => image.complete && image.naturalWidth > 0)).toBe(true);
|
||||
await page.getByTestId('profile-linkedin-url').fill(`https://linkedin.com/in/test-${index}`);
|
||||
await expect(mascot).toHaveAttribute('src', `/manfred/${pose}.webp`);
|
||||
await page.locator('.screen').evaluate((screen) => { screen.scrollTop = 0; });
|
||||
const bounds = await mascot.boundingBox();
|
||||
expect(bounds).not.toBeNull();
|
||||
expect(bounds!.y).toBeGreaterThanOrEqual(0);
|
||||
expect(bounds!.width).toBe(76);
|
||||
expect(bounds!.height).toBe(76);
|
||||
expect(bounds!.x + bounds!.width).toBeLessThanOrEqual(viewport.width);
|
||||
const heading = await page.locator('.screen > div .h1').boundingBox();
|
||||
expect(heading!.x + heading!.width).toBeLessThan(bounds!.x);
|
||||
if (index === poses.length - 1) await page.screenshot({ path: testInfo.outputPath(`profile-manfred-${viewport.width}.png`), fullPage: true });
|
||||
await page.getByTestId('tab-home').click();
|
||||
await expect(mascot).toHaveCount(0);
|
||||
}
|
||||
await page.evaluate(() => sessionStorage.setItem('test-manfred-choice', '0.01'));
|
||||
await page.reload();
|
||||
await page.getByTestId('tab-profile').click();
|
||||
await expect(mascot).toHaveAttribute('src', '/manfred/confident.webp');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function mockSession(email: string) {
|
||||
const user = {
|
||||
id: '11111111-1111-4111-8111-111111111111', aud: 'authenticated', role: 'authenticated', email,
|
||||
@@ -68,7 +108,8 @@ async function mockApi(page: Page, options: { email?: string; admin?: boolean; r
|
||||
async function openEntry(page: Page) {
|
||||
await page.goto(appUrl);
|
||||
await page.getByTestId('login-splash').click();
|
||||
await expect(page.getByLabel('QR code or admin email')).toBeVisible();
|
||||
await expect(page.getByLabel('QR Code')).toBeVisible();
|
||||
await expect(page.getByLabel('QR Code')).toHaveAttribute('placeholder', 'QR Code');
|
||||
}
|
||||
|
||||
test.describe('Convivo admin email entry', () => {
|
||||
@@ -76,8 +117,8 @@ test.describe('Convivo admin email entry', () => {
|
||||
test(`ineligible ${email} gets private confirmation without OTP`, async ({ page }) => {
|
||||
const { calls } = await mockApi(page, { email, admin: false });
|
||||
await openEntry(page);
|
||||
await page.getByLabel('QR code or admin email').fill(email);
|
||||
await page.getByLabel('QR code or admin email').press('Enter');
|
||||
await page.getByLabel('QR Code').fill(email);
|
||||
await page.getByLabel('QR Code').press('Enter');
|
||||
await expect(page.getByRole('status')).toHaveText(notice);
|
||||
expect(calls.otp).toBe(0);
|
||||
expect(calls.lanyards).toBe(0);
|
||||
@@ -89,7 +130,7 @@ test.describe('Convivo admin email entry', () => {
|
||||
const { calls } = await mockApi(page);
|
||||
await page.route('**/rest/v1/rpc/can_request_admin_magic_link', (route) => route.fulfill({ status: 401, json: { message: 'Sensitive eligibility detail' } }));
|
||||
await openEntry(page);
|
||||
await page.getByLabel('QR code or admin email').fill('[email protected]');
|
||||
await page.getByLabel('QR Code').fill('[email protected]');
|
||||
await page.getByTestId('scanner-manual-go').click();
|
||||
await expect(page.getByRole('alert')).toHaveText('Unable to send a sign-in link right now. Please try again later.');
|
||||
expect(calls.otp).toBe(0);
|
||||
@@ -101,7 +142,7 @@ test.describe('Convivo admin email entry', () => {
|
||||
await mockApi(page);
|
||||
await page.route('**/auth/v1/otp**', (route) => route.fulfill({ status: responseStatus, json: { message: 'Sensitive account detail' } }));
|
||||
await openEntry(page);
|
||||
await page.getByLabel('QR code or admin email').fill('[email protected]');
|
||||
await page.getByLabel('QR Code').fill('[email protected]');
|
||||
await page.getByTestId('scanner-manual-go').click();
|
||||
if (responseStatus === 400 || responseStatus === 422) {
|
||||
await expect(page.getByRole('status')).toHaveText(notice);
|
||||
@@ -110,7 +151,7 @@ test.describe('Convivo admin email entry', () => {
|
||||
await expect(page.getByTestId('scanner-manual-go')).toBeEnabled();
|
||||
}
|
||||
await expect(page.getByText('Sensitive account detail')).toHaveCount(0);
|
||||
await expect(page.getByLabel('QR code or admin email')).toBeEnabled();
|
||||
await expect(page.getByLabel('QR Code')).toBeEnabled();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -125,7 +166,7 @@ test.describe('Convivo admin email entry', () => {
|
||||
await route.fulfill({ status: 202, json: { ok: true } });
|
||||
});
|
||||
await openEntry(page);
|
||||
const entry = page.getByLabel('QR code or admin email');
|
||||
const entry = page.getByLabel('QR Code');
|
||||
await expect(entry).toHaveAttribute('type', 'text');
|
||||
await entry.fill(' [email protected] ');
|
||||
await expect(page.getByTestId('scanner-manual-go')).toHaveText('Send magic link');
|
||||
@@ -154,9 +195,9 @@ test.describe('Convivo admin email entry', () => {
|
||||
else await route.fulfill({ status: 503, json: { error: 'Sensitive server detail' } });
|
||||
});
|
||||
await openEntry(page);
|
||||
await page.getByLabel('QR code or admin email').fill('[email protected]');
|
||||
await page.getByLabel('QR Code').fill('[email protected]');
|
||||
await page.getByTestId('scanner-manual-go').click();
|
||||
await expect(page.getByLabel('QR code or admin email')).toBeDisabled();
|
||||
await expect(page.getByLabel('QR Code')).toBeDisabled();
|
||||
await expect(page.getByRole('button', { name: 'Sending...' })).toBeDisabled();
|
||||
release();
|
||||
await expect(page.getByRole('status')).toHaveText(notice);
|
||||
@@ -172,7 +213,7 @@ test.describe('Convivo admin email entry', () => {
|
||||
const { calls } = await mockApi(page);
|
||||
await page.route('**/auth/v1/otp**', (route) => route.abort());
|
||||
await openEntry(page);
|
||||
const entry = page.getByLabel('QR code or admin email');
|
||||
const entry = page.getByLabel('QR Code');
|
||||
await entry.fill('admin@');
|
||||
await entry.press('Enter');
|
||||
await expect(page.getByRole('alert')).toHaveText('Enter a valid email address.');
|
||||
@@ -251,7 +292,7 @@ test.describe('Convivo admin email entry', () => {
|
||||
await expect(page.getByRole('alert')).toHaveText(invalidLink);
|
||||
await expect(page).toHaveURL(`${appUrl}/`);
|
||||
expect(await page.evaluate(() => Object.keys(localStorage).filter((key) => key.endsWith('-auth-token')))).toEqual([]);
|
||||
await page.getByLabel('QR code or admin email').fill('[email protected]');
|
||||
await page.getByLabel('QR Code').fill('[email protected]');
|
||||
await page.getByRole('button', { name: 'Send magic link', exact: true }).click();
|
||||
await expect(page.getByRole('status')).toHaveText(notice);
|
||||
await expect(page.getByRole('alert')).toHaveCount(0);
|
||||
@@ -280,8 +321,8 @@ test.describe('Convivo admin email entry', () => {
|
||||
await route.fulfill({ json: mockSession('[email protected]') });
|
||||
});
|
||||
await openEntry(page);
|
||||
await page.getByLabel('QR code or admin email').fill('CVV-TEST-1234');
|
||||
await page.getByLabel('QR code or admin email').press('Enter');
|
||||
await page.getByLabel('QR Code').fill('CVV-TEST-1234');
|
||||
await page.getByLabel('QR Code').press('Enter');
|
||||
await expect(page.getByTestId('staff-login-password')).toBeVisible();
|
||||
await expect(page.getByTestId('login-confirm')).toBeDisabled();
|
||||
await page.getByTestId('staff-login-password').fill('mock-staff-password');
|
||||
@@ -298,7 +339,7 @@ test.describe('Convivo admin email entry', () => {
|
||||
await mockApi(page, { admin: false, registered: true, checkedIn: true });
|
||||
await page.route('**/auth/v1/token**', (route) => route.fulfill({ status: 400, json: { error: 'invalid_grant', error_description: 'Invalid login credentials' } }));
|
||||
await openEntry(page);
|
||||
await page.getByLabel('QR code or admin email').fill('CVV-TEST-1234');
|
||||
await page.getByLabel('QR Code').fill('CVV-TEST-1234');
|
||||
await page.getByTestId('scanner-manual-go').click();
|
||||
await page.getByTestId('attendee-login-email').fill('[email protected]');
|
||||
await page.getByTestId('login-confirm').click();
|
||||
@@ -310,17 +351,17 @@ test.describe('Convivo admin email entry', () => {
|
||||
await page.setViewportSize({ width: 375, height: 812 });
|
||||
const { calls } = await mockApi(page);
|
||||
await openEntry(page);
|
||||
await page.getByLabel('QR code or admin email').fill('[email protected]');
|
||||
await page.getByLabel('QR Code').fill('[email protected]');
|
||||
await page.getByRole('button', { name: 'Send magic link', exact: true }).click();
|
||||
await expect(page.getByRole('status')).toHaveText(notice);
|
||||
const button = await page.getByTestId('scanner-manual-go').boundingBox();
|
||||
const input = await page.getByLabel('QR code or admin email').boundingBox();
|
||||
const input = await page.getByLabel('QR Code').boundingBox();
|
||||
expect(button).not.toBeNull();
|
||||
expect(input).not.toBeNull();
|
||||
expect(input!.x + input!.width).toBeLessThanOrEqual(button!.x);
|
||||
expect(button!.x + button!.width).toBeLessThanOrEqual(375);
|
||||
await page.screenshot({ path: '/tmp/convivo-admin-entry-mobile.png', fullPage: true });
|
||||
await page.getByLabel('QR code or admin email').fill('CVV-TEST-1234');
|
||||
await page.getByLabel('QR Code').fill('CVV-TEST-1234');
|
||||
await expect(page.getByTestId('scanner-manual-go')).toHaveText('Go');
|
||||
await expect(page.getByTestId('scanner-manual-go')).toBeEnabled();
|
||||
await page.getByTestId('scanner-manual-go').click();
|
||||
@@ -333,7 +374,7 @@ test.describe('Convivo admin email entry', () => {
|
||||
const { calls } = await mockApi(page);
|
||||
await page.goto(`${appUrl}/auth/callback${suffix}`);
|
||||
await expect(page.getByRole('alert')).toHaveText(invalidLink);
|
||||
await expect(page.getByLabel('QR code or admin email')).toBeVisible();
|
||||
await expect(page.getByLabel('QR Code')).toBeVisible();
|
||||
await expect(page).toHaveURL(`${appUrl}/`);
|
||||
expect(calls.exchanges).toBe(0);
|
||||
expect(calls.users).toBe(0);
|
||||
@@ -346,7 +387,7 @@ test.describe('Convivo admin email entry', () => {
|
||||
const email = '[email protected]';
|
||||
const { calls } = await mockApi(page, { email, admin: false, registered: true, checkedIn });
|
||||
await openEntry(page);
|
||||
await page.getByLabel('QR code or admin email').fill('CVV-TEST-1234');
|
||||
await page.getByLabel('QR Code').fill('CVV-TEST-1234');
|
||||
await page.getByTestId('scanner-manual-go').click();
|
||||
await page.getByTestId('attendee-login-email').fill(email);
|
||||
await page.getByTestId('login-confirm').click();
|
||||
|
||||
Reference in new issue
Block a user