- e2e/: full Playwright suite covering every spec case (staff auth/UI, welcome + session check-in, attendee access/gating, connections, profile visibility, speaker material, sponsor, feedback, E2E journeys, role security matrix). 46/46 passing. - apps/convivo: add data-testid attributes (gate, tabs, scanner, toggles) to support the E2E suite. - test_cases.md: spec-case-to-test coverage map (all cases fully covered). - .gitignore: ignore e2e node_modules/reports/test-results.
172 lines
6.6 KiB
TypeScript
172 lines
6.6 KiB
TypeScript
import { test, expect } from './base';
|
|
import { APP_URL, ID } from '../src/helpers/config';
|
|
import { login } from '../src/helpers/auth';
|
|
import { createUser } from '../src/helpers/multi';
|
|
import { signInJwt, userRpc } from '../src/helpers/api';
|
|
import { db } from '../src/helpers/db';
|
|
import { AppPage } from '../src/pages/AppPage';
|
|
import { ProfilePage } from '../src/pages/ProfilePage';
|
|
import { ConnectionsPage } from '../src/pages/ConnectionsPage';
|
|
|
|
/**
|
|
* §24–§26 Profile Email/LinkedIn visibility.
|
|
*
|
|
* Visibility is enforced by the `lanyard_lookup` / `get_public_contacts` RPCs
|
|
* (which respect the contact's show_email / show_linkedin toggles). We verify
|
|
* the persisted setting (DB) and the value another user actually sees (via the
|
|
* public RPC, which is what the app's connection detail + scan use).
|
|
*/
|
|
|
|
/** What another user sees for a contact (via the public directory RPC). */
|
|
async function publicView(viewerJwt: string, targetEmail: string) {
|
|
const rows = await userRpc<{ email: string; show_email: boolean; linkedin_url: string | null }[]>(
|
|
viewerJwt,
|
|
'get_public_contacts',
|
|
{},
|
|
);
|
|
return rows.find((r) => r.email === targetEmail) ?? null;
|
|
}
|
|
|
|
test.describe('Profile visibility', () => {
|
|
test('CONV-PROFILE-001 Show Email enabled → visible to another user', async ({ browser }) => {
|
|
const a = await createUser(browser, 'userA');
|
|
const b = await createUser(browser, 'userB');
|
|
try {
|
|
const aApp = new AppPage(a.page, APP_URL);
|
|
const aProfile = new ProfilePage(a.page);
|
|
|
|
// A enables Show Email and saves.
|
|
await login(a.page, APP_URL, ID.attendeeA);
|
|
await aApp.waitForAdmitted();
|
|
await aApp.gotoTab('profile');
|
|
await aProfile.setShowEmail(true);
|
|
await aProfile.save();
|
|
|
|
// The setting persists (DB).
|
|
expect(db.contact(ID.attendeeA.email)?.showEmail).toBe(true);
|
|
|
|
// B can see A's email (via the public RPC the app uses).
|
|
const bJwt = await signInJwt(ID.attendeeB.email, ID.attendeeB.qrToken);
|
|
const view = await publicView(bJwt, ID.attendeeA.email);
|
|
expect(view?.show_email).toBe(true);
|
|
} finally {
|
|
await a.close();
|
|
await b.close();
|
|
}
|
|
});
|
|
|
|
test('CONV-PROFILE-002 Show Email disabled → hidden from another user', async ({ browser }) => {
|
|
const a = await createUser(browser, 'userA');
|
|
const b = await createUser(browser, 'userB');
|
|
try {
|
|
const aApp = new AppPage(a.page, APP_URL);
|
|
const aProfile = new ProfilePage(a.page);
|
|
|
|
// A disables Show Email and saves.
|
|
await login(a.page, APP_URL, ID.attendeeA);
|
|
await aApp.waitForAdmitted();
|
|
await aApp.gotoTab('profile');
|
|
await aProfile.setShowEmail(false);
|
|
await aProfile.save();
|
|
|
|
// The setting persists (DB).
|
|
expect(db.contact(ID.attendeeA.email)?.showEmail).toBe(false);
|
|
|
|
// B cannot see A's email (the public RPC omits it).
|
|
const bJwt = await signInJwt(ID.attendeeB.email, ID.attendeeB.qrToken);
|
|
const view = await publicView(bJwt, ID.attendeeA.email);
|
|
expect(view?.show_email).toBe(false);
|
|
} finally {
|
|
await a.close();
|
|
await b.close();
|
|
}
|
|
});
|
|
|
|
test('CONV-PROFILE-003 Show LinkedIn enabled → visible to another user', async ({ browser }) => {
|
|
const a = await createUser(browser, 'userA');
|
|
const b = await createUser(browser, 'userB');
|
|
try {
|
|
const aApp = new AppPage(a.page, APP_URL);
|
|
const aProfile = new ProfilePage(a.page);
|
|
|
|
// A sets a LinkedIn URL, enables Show LinkedIn, and saves.
|
|
await login(a.page, APP_URL, ID.attendeeA);
|
|
await aApp.waitForAdmitted();
|
|
await aApp.gotoTab('profile');
|
|
await aProfile.setLinkedinUrl('https://linkedin.com/in/mia-moser');
|
|
await aProfile.setShowLinkedin(true);
|
|
await aProfile.save();
|
|
|
|
// The setting persists (DB).
|
|
expect(db.contact(ID.attendeeA.email)?.showLinkedin).toBe(true);
|
|
|
|
// B can see A's LinkedIn (via the public RPC).
|
|
const bJwt = await signInJwt(ID.attendeeB.email, ID.attendeeB.qrToken);
|
|
const view = await publicView(bJwt, ID.attendeeA.email);
|
|
expect(view?.linkedin_url).toBe('https://linkedin.com/in/mia-moser');
|
|
} finally {
|
|
await a.close();
|
|
await b.close();
|
|
}
|
|
});
|
|
|
|
test('CONV-PROFILE-004 Show LinkedIn disabled → hidden from another user', async ({ browser }) => {
|
|
const a = await createUser(browser, 'userA');
|
|
const b = await createUser(browser, 'userB');
|
|
try {
|
|
const aApp = new AppPage(a.page, APP_URL);
|
|
const aProfile = new ProfilePage(a.page);
|
|
|
|
// A sets a LinkedIn URL but disables Show LinkedIn, and saves.
|
|
await login(a.page, APP_URL, ID.attendeeA);
|
|
await aApp.waitForAdmitted();
|
|
await aApp.gotoTab('profile');
|
|
await aProfile.setLinkedinUrl('https://linkedin.com/in/mia-moser');
|
|
await aProfile.setShowLinkedin(false);
|
|
await aProfile.save();
|
|
|
|
// The setting persists (DB).
|
|
expect(db.contact(ID.attendeeA.email)?.showLinkedin).toBe(false);
|
|
|
|
// B cannot see A's LinkedIn (the public RPC omits it).
|
|
const bJwt = await signInJwt(ID.attendeeB.email, ID.attendeeB.qrToken);
|
|
const view = await publicView(bJwt, ID.attendeeA.email);
|
|
expect(view?.linkedin_url).toBeNull();
|
|
} finally {
|
|
await a.close();
|
|
await b.close();
|
|
}
|
|
});
|
|
|
|
test('CONV-PROFILE-005 visibility settings behave consistently across roles', async ({ browser }) => {
|
|
// Representative users from each role: staff, attendee, speaker, sponsor.
|
|
const roles = [ID.staff, ID.attendeeA, ID.speaker, ID.sponsor];
|
|
const contexts = [];
|
|
for (const r of roles) contexts.push(await createUser(browser, r.label));
|
|
try {
|
|
// Each role enables Show Email and saves; the setting persists and is
|
|
// respected (visible) regardless of role.
|
|
for (let i = 0; i < roles.length; i++) {
|
|
const ctx = contexts[i];
|
|
const app = new AppPage(ctx.page, APP_URL);
|
|
const profile = new ProfilePage(ctx.page);
|
|
await login(ctx.page, APP_URL, roles[i]);
|
|
await app.waitForAdmitted();
|
|
await app.gotoTab('profile');
|
|
await profile.setShowEmail(true);
|
|
await profile.save();
|
|
expect(db.contact(roles[i].email)?.showEmail).toBe(true);
|
|
}
|
|
|
|
// A viewer (attendee B) sees each role's email as visible.
|
|
const bJwt = await signInJwt(ID.attendeeB.email, ID.attendeeB.qrToken);
|
|
for (const r of roles) {
|
|
const view = await publicView(bJwt, r.email);
|
|
expect(view?.show_email, `${r.label} show_email should be visible`).toBe(true);
|
|
}
|
|
} finally {
|
|
for (const c of contexts) await c.close();
|
|
}
|
|
});
|
|
});
|