44 lines
2.0 KiB
JavaScript
44 lines
2.0 KiB
JavaScript
// The topbar org selector: choosing a member org reloads the dashboard into it,
|
|
// Tasks and Workflows then show only that org's work, and the API refuses an
|
|
// org the caller is not a member of.
|
|
const assert = require('node:assert/strict');
|
|
const { ORG, ABSENT, selectOrg } = require('./helpers/org-helpers.cjs');
|
|
|
|
module.exports = async ({ page, go, shot, settled, tolerate }) => {
|
|
tolerate(ABSENT);
|
|
await go('/tasks');
|
|
await page.getByText('Fix flaky login test').first().waitFor();
|
|
const picker = page.getByRole('combobox', { name: 'Organisation' });
|
|
await picker.waitFor();
|
|
const offered = await (async () => {
|
|
await picker.click();
|
|
const names = await page.getByRole('option').allInnerTexts();
|
|
await page.keyboard.press('Escape');
|
|
return names;
|
|
})();
|
|
assert.deepEqual(offered.sort(), ['Beta', 'E2E'], 'selector must offer exactly the orgs the caller belongs to');
|
|
await go('/workflows');
|
|
await page.getByText('Parked', { exact: true }).first().waitFor();
|
|
await shot('home-org-workflows');
|
|
|
|
await picker.click();
|
|
await Promise.all([page.waitForEvent('load'), page.getByRole('option', { name: 'Beta', exact: true }).click()]);
|
|
await settled('/workflows');
|
|
await page.getByRole('combobox', { name: 'Organisation' }).waitFor();
|
|
assert.equal(await page.getByText('Parked', { exact: true }).count(), 0, 'workflow run counts leaked across orgs');
|
|
await shot('beta-workflows');
|
|
await go('/tasks');
|
|
await page.getByText('No tasks yet').waitFor();
|
|
assert.equal(await page.getByText('Fix flaky login test').count(), 0, 'tasks leaked across orgs');
|
|
await shot('beta-tasks');
|
|
|
|
// The selector never writes an org the caller is outside of; the server decides.
|
|
const refused = await selectOrg(page, ORG.outsider);
|
|
assert.equal(refused.status(), 403, 'selecting a non-member org must be forbidden');
|
|
await go('/tasks');
|
|
await page.getByText('No tasks yet').waitFor();
|
|
assert.equal((await selectOrg(page, ORG.home)).status(), 204);
|
|
await go('/tasks');
|
|
await page.getByText('Fix flaky login test').first().waitFor();
|
|
};
|