Some checks failed
Use-case regression gate / usecase-regressions (push) Failing after 6m43s
Assistant: codex Assistant-Model: gpt-6.1-sol Assistant-Session: 01a119cf-56d0-7fa3-840b-eb8732e1db0b
71 lines
3.7 KiB
JavaScript
71 lines
3.7 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { chromium } from 'playwright';
|
|
|
|
const base = new URL(process.argv[2]);
|
|
if (base.protocol !== 'http:' || !['localhost', '127.0.0.1'].includes(base.hostname)) {
|
|
throw new Error('Sharing checks require an isolated loopback server');
|
|
}
|
|
const browser = await chromium.launch({headless: true});
|
|
try {
|
|
const context = await browser.newContext();
|
|
await context.route('**/*', route => new URL(route.request().url()).origin === base.origin
|
|
? route.continue() : route.abort());
|
|
const page = await context.newPage();
|
|
page.setDefaultTimeout(10000);
|
|
async function login(subject) {
|
|
await page.goto(`${base.origin}/auth/dev-login/`);
|
|
await page.getByLabel('Subject').fill(subject);
|
|
await page.getByLabel('Tenant').fill('tenant:sharing-test');
|
|
await page.getByRole('button', {name: 'Establish session'}).click();
|
|
await page.waitForURL('**/app/');
|
|
}
|
|
const detail = `${base.origin}/app/spaces/shared-browser/`;
|
|
await login('sharing-reader');
|
|
await page.goto(`${base.origin}/account/data/`);
|
|
const readerId = await page.locator('main code').first().innerText();
|
|
assert.match(readerId, /^[0-9a-f-]{36}$/);
|
|
await login('sharing-owner');
|
|
await page.goto(detail);
|
|
await page.getByRole('link', {name: 'Share space', exact: true}).click();
|
|
await page.getByLabel('Member ID').fill(readerId);
|
|
await page.getByLabel('Access', {exact: true}).selectOption('viewer');
|
|
await page.getByRole('button', {name: 'Update access'}).click();
|
|
await page.waitForURL('**/sharing/');
|
|
assert.match(await page.locator('main').innerText(), /Space access updated/);
|
|
await login('sharing-reader');
|
|
await page.goto(`${detail}?page=notes`);
|
|
assert.match(await page.locator('#page-content').innerText(), /Original notes/);
|
|
assert.equal(await page.getByRole('link', {name: 'Share space', exact: true}).count(), 0);
|
|
assert.equal(await page.getByRole('link', {name: 'Edit page', exact: true}).count(), 0);
|
|
await login('sharing-owner');
|
|
await page.goto(`${detail}pages/notes/edit/`);
|
|
const otherTab = await context.newPage();
|
|
await otherTab.goto(`${detail}pages/notes/edit/`);
|
|
await page.getByLabel('Body (markdown)').fill('First saved notes');
|
|
await page.getByRole('button', {name: 'Save page'}).click();
|
|
await page.waitForURL('**?page=notes');
|
|
await otherTab.getByLabel('Body (markdown)').fill('Unsaved second-tab notes');
|
|
await otherTab.getByRole('button', {name: 'Save page'}).click();
|
|
assert.match(await otherTab.locator('main').innerText(), /Reopen it and merge/);
|
|
assert.equal(await otherTab.getByLabel('Body (markdown)').inputValue(), 'Unsaved second-tab notes');
|
|
await otherTab.close();
|
|
await page.goto(`${detail}sharing/`);
|
|
await page.getByLabel('Member ID').fill(readerId);
|
|
await page.getByLabel('Access', {exact: true}).selectOption('owner');
|
|
await page.getByRole('button', {name: 'Update access'}).click();
|
|
await page.waitForURL('**/sharing/');
|
|
await page.goto(`${base.origin}/account/data/`);
|
|
await page.getByLabel('Type DELETE to remove your local account').fill('DELETE');
|
|
await page.getByRole('button', {name: 'Remove local account'}).click();
|
|
await page.waitForURL(base.origin + '/');
|
|
assert.equal(await page.locator('header').getByRole('link', {name: 'Sign in', exact: true}).count(), 1);
|
|
await login('sharing-reader');
|
|
await page.goto(`${detail}?page=notes`);
|
|
assert.match(await page.locator('#page-content').innerText(), /First saved notes/);
|
|
await page.goto(`${base.origin}/account/data/`);
|
|
assert.match(await page.locator('main').innerText(), /Before removal/);
|
|
assert.equal(await page.getByRole('button', {name: 'Remove local account'}).count(), 0);
|
|
console.log('Sharing, concurrent edits and retained-content exit passed');
|
|
} finally {
|
|
await browser.close();
|
|
}
|