All files / suite/blong-suite/test portalMerge.play.ts

100% Statements 51/51
100% Branches 3/3
100% Functions 0/0
100% Lines 51/51

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 521x 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  
/**
 * Two realms, one portal — the composition proof in the full-stack suite.
 *
 * `marine` contributes a model-driven menu and `blong` answers `portalConfigGet` for
 * its own hand-written pages, so this suite is the case the portal composition
 * exists for (see `core/blong-browser/src/portalConfig.ts`). Before it, the realm
 * loaded last decided the whole menu — here `blong`, which is why marine's pages
 * disappeared from it — and the suite's own configured title was replaced too.
 */
import {expect, test} from '@feasibleone/blong-browser/playwright';
 
test.use({blongPermissions: true});
 
test('the suite portal carries both realms’ menus', async ({portal}) => {
    await expect(portal.page.locator('.blong-portal-menubar')).toBeVisible();
    await expect(portal.page.getByTestId('portal-menu-marine')).toBeVisible();
    await expect(portal.page.getByTestId('portal-menu-blong')).toBeVisible();
    // The third menu is a realm whose whole page is the deployment's own records: the
    // deployment loads it, so the suite's portal carries the group (@@D-946).
    await expect(portal.page.getByTestId('portal-menu-viewer')).toBeVisible();
    // The title the suite configured, kept because the first provider to set one is
    // the model aggregator — which reads that same `ui.portal.portal` slice. It is the
    // suite's brand name now (`ui.portal.portal.brand`), not the package name.
    await expect(portal.page.locator('.blong-portal-brand')).toHaveText('Marine Biology');
    await expect(portal.page.locator('.blong-portal-menubar')).toHaveScreenshot(
        'portal-merged.png',
    );
});
 
test('a page of each realm opens from the composed menu', async ({portal}) => {
    await portal.menuClick('marine.coral.browse');
    await portal.waitForTableData();
    await portal.menuClick('blong.template.browse');
    await portal.waitForTableData();
    // `:visible` scopes to the open tab: a composed portal keeps every page it has
    // opened in the DOM, so a sibling panel's rows match the plain selector and a
    // hidden one is what `.first()` finds.
    await expect(portal.page.locator('.p-datatable-tbody tr:visible').first()).toBeVisible();
});
 
test('the deployment reads its own records from the portal', async ({portal}) => {
    // The viewer page is the deployment's account of itself: the tab opens from the
    // composed menu, and the records it draws are the ones the running process wrote —
    // the `release`/`dev` destination in the suite's own config, received by the realm's
    // adapter. A page that loads nothing is the failure this asserts against.
    await portal.menuClick('viewer.log');
    const page = portal.page.locator('[data-stream]');
    // The record grid is the viewer's own, not a model table: `.wx-row` is the row the
    // grid library renders a record into.
    await expect(page.locator('.wx-row').first()).toBeVisible();
});