Events 3.0: auto-connect, demo people in Accounts, e2e; import.finish checks the subs
- contracts 1.8.0 / Accounts 1.1.0: import.finish lists the subs the product relies on; Accounts checks each is held, not deleted and known to it (the count+hash failed a second move after Undo once someone had joined through Accounts). - Events: connects to the church's Accounts once the Hub lists it; moveNewPeople (demo data, people added after the move); set-demo moves demo people; e2e/sign-in-accounts.spec.ts with Accounts in memory and an e2e-only /api rewrite. test:accounts 14/14; Jest auto-connect tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* The church's Accounts for Cross Events' end-to-end tests (3.0.0, playwright.config.ts): the real
|
||||
* Accounts backend on 127.0.0.1:5221 with its in-memory database (no Postgres of its own), behind
|
||||
* its pages on 127.0.0.1:3221 (`next dev` in apps/accounts/frontend). Its own address (127.0.0.1)
|
||||
* differs from the Events site's (localhost), so their cookies stay apart as on two domains.
|
||||
*
|
||||
* Test helper: POST /test/link { installId, url, secret } links Events, as Connect would.
|
||||
*/
|
||||
import http from 'node:http';
|
||||
import { ed25519PublicToPem, generateEd25519 } from '@crosscode/contracts/signing';
|
||||
import { createApp } from '../../../accounts/backend/src/app.ts';
|
||||
import { createCtx } from '../../../accounts/backend/src/context.ts';
|
||||
import { loadConfig } from '../../../accounts/backend/src/lib/config.ts';
|
||||
import { MemoryMessenger } from '../../../accounts/backend/src/lib/messages.ts';
|
||||
import { createProvider } from '../../../accounts/backend/src/oidc/provider.ts';
|
||||
import { memoryDb } from '../../../accounts/backend/tests/support/memoryDb.ts';
|
||||
|
||||
const WEB = 'http://127.0.0.1:3221';
|
||||
const db = memoryDb();
|
||||
const ctx = createCtx(loadConfig({ ACCOUNTS_URL: WEB, NODE_ENV: 'test', JOBS_ENABLED: 'false', LINKS_ALLOW_PRIVATE: 'true', HUB_URL: 'http://127.0.0.1:1', TRUST_PROXY: 'true' }), db as never, { messenger: new MemoryMessenger() });
|
||||
await ctx.settings.setMany({
|
||||
hub_install_id: '7e2d1c0b-9a8f-4e6d-8c5b-4a3f2e1d0c9b',
|
||||
church_profile: JSON.stringify({ name: 'E2E Church', shortName: 'E2E' }),
|
||||
});
|
||||
const provider = await createProvider(ctx);
|
||||
const app = createApp(ctx, provider);
|
||||
|
||||
http.createServer((req, res) => {
|
||||
if (req.method === 'POST' && req.url === '/test/link') {
|
||||
let body = '';
|
||||
req.on('data', (c) => { body += c; });
|
||||
req.on('end', async () => {
|
||||
const { installId, url, secret } = JSON.parse(body) as { installId: string; url: string; secret: string };
|
||||
const data = { product: 'events', url, publicKey: ed25519PublicToPem(generateEd25519().publicKey), secret: ctx.secrets.encrypt(secret), connectedAt: new Date() };
|
||||
await db.productLink.upsert({ where: { installId }, create: { installId, ...data }, update: data });
|
||||
res.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify({ ok: true }));
|
||||
});
|
||||
return;
|
||||
}
|
||||
app(req, res);
|
||||
}).listen(5221, '127.0.0.1', () => console.log('[e2e] Accounts on 5221'));
|
||||
Reference in New Issue
Block a user