45 lines
2.1 KiB
JavaScript
45 lines
2.1 KiB
JavaScript
// The sidebar org switcher: 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('button', { name: /^Organisation: / });
|
|
await picker.waitFor();
|
|
const offered = await (async () => {
|
|
await picker.click();
|
|
await page.getByRole('menuitem').first().waitFor();
|
|
const names = (await page.getByRole('menuitem').allInnerTexts()).map(t => t.trim().split('\n').pop().trim());
|
|
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('menuitem', { name: 'Beta' }).click()]);
|
|
await settled('/workflows');
|
|
await page.getByRole('button', { 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();
|
|
};
|