Support script and URL sources, automatic Sessionize polling, staff-linked service sessions, chronological agenda blocks, and inline Placeholders. Fix demo mode to use the active event date and document deployed behavior with regression coverage. 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]>
58 lines
3.5 KiB
TypeScript
58 lines
3.5 KiB
TypeScript
import { test, expect, type Page } from '@playwright/test';
|
|
|
|
const adminUrl = process.env.CONVIVO_ADMIN_URL || 'http://localhost:3001';
|
|
const source = 'https://sessionize.com/api/v2/z0s5f2j2/view/GridSmart';
|
|
|
|
async function openEvent(page: Page) {
|
|
const user = { id: '99999999-9999-4999-8999-999999999999', email: '[email protected]', aud: 'authenticated', role: 'authenticated', app_metadata: {}, user_metadata: {} };
|
|
const payload = Buffer.from(JSON.stringify({ sub: user.id, exp: Math.floor(Date.now() / 1000) + 3600 })).toString('base64url');
|
|
const session = { user, access_token: `eyJhbGciOiJIUzI1NiJ9.${payload}.test`, refresh_token: 'mock-refresh-token', expires_in: 3600, token_type: 'bearer' };
|
|
const event = { id: 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa', name: 'Grid Conference', is_active: true,
|
|
start_date: '2026-10-23', end_date: '2026-10-23', sessionize_endpoint: null,
|
|
num_registrations: 4, num_sessions: 21, num_speakers: 4 };
|
|
const writes: Record<string, unknown>[] = [];
|
|
await page.route('**/auth/v1/**', route => route.fulfill({ json: new URL(route.request().url()).pathname.endsWith('/user') ? user : session }));
|
|
await page.route('**/rest/v1/**', async route => {
|
|
const url = new URL(route.request().url());
|
|
const path = url.pathname;
|
|
if (path.endsWith('/events')) {
|
|
if (route.request().method() === 'PATCH') {
|
|
writes.push(route.request().postDataJSON());
|
|
return route.fulfill({ status: 204 });
|
|
}
|
|
return route.fulfill({ json: url.searchParams.has('is_active') ? event : [event] });
|
|
}
|
|
if (path.endsWith('/contacts')) {
|
|
const contact = { email: user.email, full_name: 'Admin', is_admin: true };
|
|
return route.fulfill({ json: url.searchParams.has('email') ? contact : [contact] });
|
|
}
|
|
return route.fulfill({ json: [] });
|
|
});
|
|
await page.goto(`${adminUrl}/auth/callback#access_token=${session.access_token}&refresh_token=${session.refresh_token}&type=magiclink`);
|
|
await expect(page.getByRole('button', { name: 'Sign out', exact: true })).toBeVisible();
|
|
await page.locator('.nav').getByRole('button', { name: /Events/ }).click();
|
|
await page.getByRole('button', { name: 'Edit', exact: true }).click();
|
|
return writes;
|
|
}
|
|
|
|
for (const [format, value] of [['URL', source], ['script', `<script type="text/javascript"\n src="${source}"></script>`]]) {
|
|
test(`saves ${format} as a normalized Sessionize source`, async ({ page }, testInfo) => {
|
|
await page.setViewportSize({ width: 1280, height: 900 });
|
|
const writes = await openEvent(page);
|
|
await page.getByLabel('Sessionize endpoint').fill(value);
|
|
await page.screenshot({ path: testInfo.outputPath(`sessionize-${format}.png`), fullPage: true });
|
|
await page.getByRole('button', { name: 'Save', exact: true }).click();
|
|
await expect.poll(() => writes.length).toBe(1);
|
|
expect(writes[0].sessionize_endpoint).toBe(source);
|
|
});
|
|
}
|
|
|
|
test('rejects invalid source without saving or executing pasted scripts', async ({ page }) => {
|
|
const writes = await openEvent(page);
|
|
await page.getByLabel('Sessionize endpoint').fill('<script src="https://example.org/script.js">window.testExecuted=true</script>');
|
|
await page.getByRole('button', { name: 'Save', exact: true }).click();
|
|
await expect(page.getByRole('alert')).toHaveText('Use a Sessionize HTTPS All or GridSmart endpoint');
|
|
expect(writes).toHaveLength(0);
|
|
expect(await page.evaluate(() => 'testExecuted' in window)).toBe(false);
|
|
await expect(page.getByLabel('Sessionize endpoint')).toBeVisible();
|
|
}); |