All files / realm/blong-party browser-test.ts

100% Statements 106/106
100% Branches 6/6
100% Functions 4/4
100% Lines 106/106

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 1071x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import {browser, realm} from '@feasibleone/blong';
 
/**
 * browser-test.ts — Browser platform suite for blong-party integration tests.
 *
 * Loads the browser-side realms needed by the tap test flows (blong-test for
 * HTTP dispatch, blong-login for authentication helpers, blong-access for the
 * RBAC test handlers) plus a **test-only** blong-party browser realm.
 *
 * The full party browser realm (`./browser.ts`) cannot be loaded by the
 * tap/ts-node runner because its React browser layers (`browser/orchestrator`)
 * import the built blong-browser bundle.  Here the party test realm discovers
 * only the `browser/test/` layer and disables the React `browser/orchestrator`
 * layer via config, so the browser-side registration flow is exercised over
 * HTTP through the backend adapter — API-level coverage that complements the
 * Playwright UI-regression tests.
 */
export default browser(blong => ({
    url: import.meta.url,
    validation: blong.type.Object(
        {
            login: blong.type.Object({}),
            access: blong.type.Object({}),
            party: blong.type.Object({}),
            testClient: blong.type.Object({
                backend: blong.type.Object({
                    namespace: blong.type.Array(blong.type.String()),
                }),
            }),
        },
        {additionalProperties: false},
    ),
    children: [
        /** blong-test: provides test dispatch + backend HTTP adapter */
        async function testClient() {
            return import('@feasibleone/blong-test/browser.ts');
        },
        /** blong-login: browser-side authentication helpers */
        async function login() {
            return import('@feasibleone/blong-login/browser.ts');
        },
        /** blong-access: RBAC realm under test (registration + profile handlers) */
        async function access() {
            return import('@feasibleone/blong-access/browser.ts');
        },
        /**
         * Test-only party browser realm — discovers only the browser/test layer
         * (no React orchestrator components, which the tap runner cannot load).
         * `browser/orchestrator` is disabled via config so the auto layer
         * discovery does not activate it.
         */
        async function party() {
            return realm(() => ({
                url: import.meta.url,
                children: ['./browser/test'],
                config: {
                    default: {
                        'browser/orchestrator': false,
                    },
                    integration: {
                        'browser/orchestrator': false,
                    },
                },
            }));
        },
    ],
    config: {
        default: {},
        dev: {
            login: {},
            access: {},
            party: {},
        },
        integration: {
            testClient: {
                backend: {
                    // Namespaces the browser backend adapter proxies to the server.
                    // `party` carries the ACL matrix probes, which must reach the
                    // gateway so its RBAC check runs, and `core` the unguarded-table
                    // matrix, which reads the same records through `core.resource`.
                    // `blob` carries the scope cookie the portal mints: the call has to reach the
                    // server's gateway, because the authorization list is what decides it (`@@D-845`).
                    namespace: ['access', 'login', 'party', 'blob'],
                },
            },
            login: {},
            access: {},
            party: {},
            // Disable blong-party's React browser layers for this tap run.
            'browser/orchestrator': false,
            watch: {
                test: [
                    'test.registration.flow',
                    'test.acl.matrix',
                    'test.acl.matrix.service',
                    'test.acl.matrix.application',
                    // The failure contract of the two helpers above: a red run has
                    // to mark the cell it failed on (see the feature for why).
                    'test.acl.diagnostics',
                    // The photograph's store: the gateway grants the mint and the cookie answers.
                    'test.photo',
                ],
            },
        },
    },
}));