Files
SRCmail/integration/tests/helpers/config.ts
T
Stefan HildebrandtandLinus Rath 578339c400 test(integration): composer From offers shared/group identities (#569)
Provision a Stalwart group (team@example.org) with carol as a member before her
first login, and assert the composer's From selector offers the group address.
This confirms the group-membership scenario of #569 already works out of the
box: Stalwart returns the group's send-as identity on the member's own account,
so the app's normal single-account identity load surfaces it (identities.length
> 1 -> the From <select> renders with team@).

- stalwart: create the `team` Group in plan-accounts and add carol via
  User.memberGroupIds in the entrypoint (id resolved after apply, like
  DOMAIN_ID). carol, not alice/bob, so the sync specs stay unshared.
- helpers: GROUP config, openComposer/composerFromOptions, and JmapClient
  accounts + sharedAccountNames (Identity/get needs the submission capability).
- composer: add data-testid="composer-from" to the From <select> and its
  single-identity <span> fallback.

Ref: https://github.com/bulwarkmail/webmail/issues/569
2026-07-16 17:59:52 +02:00

57 lines
2.2 KiB
TypeScript

/**
* Shared configuration for the integration tests. Values mirror the Stalwart
* bootstrap (integration/stalwart/*) and the docker-compose port mappings.
* Everything is overridable via env so the suite can run against a differently
* mapped stack (e.g. remote CI) without code changes.
*/
export const DOMAIN = process.env.IT_DOMAIN ?? 'example.org';
/** Shared password for every test mailbox (TEST_ACCOUNT_PASSWORD in .env). */
export const ACCOUNT_PASSWORD = process.env.IT_ACCOUNT_PASSWORD ?? 'test-pass-123';
/** Webmail app origin (containerised, published on the host). */
export const WEBMAIL_URL = process.env.IT_WEBMAIL_URL ?? 'http://localhost:3000';
/** Stalwart JMAP + admin base URL (host-published). */
export const JMAP_URL = process.env.IT_JMAP_URL ?? 'http://localhost:8025';
/** Stalwart SMTP submission listener (host-published, maps to container 587). */
export const SMTP_HOST = process.env.IT_SMTP_HOST ?? 'localhost';
export const SMTP_PORT = Number(process.env.IT_SMTP_PORT ?? 1025);
/** Recovery admin — `user:password`, used for stalwart-cli style admin JMAP. */
export const ADMIN_CREDENTIALS = process.env.IT_ADMIN ?? 'admin:bootstrap-secret';
export interface TestAccount {
/** Local part, e.g. "alice". */
user: string;
/** Full address, e.g. "alice@example.org". */
email: string;
password: string;
}
function acct(user: string): TestAccount {
return { user, email: `${user}@${DOMAIN}`, password: ACCOUNT_PASSWORD };
}
/** The mailboxes provisioned by the Stalwart bootstrap plan. */
export const ACCOUNTS = {
alice: acct('alice'),
bob: acct('bob'),
carol: acct('carol'),
} as const;
export type AccountKey = keyof typeof ACCOUNTS;
/**
* The shared *group* account provisioned by the bootstrap (a Stalwart Group
* principal, not a login). `carol` is made a member before her first login, so
* she sees the group's folders under "Shared" and can send as its address.
* Groups have no password of their own — access is via a member's session.
* (carol, rather than alice/bob, keeps the sync specs' accounts unshared.)
*/
export const GROUP = {
team: { user: 'team', email: `team@${DOMAIN}`, memberOf: 'carol' as AccountKey },
} as const;