refactor: extract cuesheet permissions

This commit is contained in:
Carlos Valente
2026-02-20 20:49:08 +01:00
committed by Carlos Valente
parent 5be504ce8f
commit df588b8845
9 changed files with 290 additions and 75 deletions
+20 -8
View File
@@ -132,14 +132,16 @@ test.describe('Sharing from cuesheet', () => {
await page.close();
});
test('Sharing a link with readonly permissions', async ({ page }) => {
test('Sharing a link with readonly permissions', async ({ page }, testInfo) => {
const alias = `cuesheet-read-test-${testInfo.retry}-${Date.now()}`;
await page.goto('http://localhost:4001/cuesheet');
await expect(page.getByTestId('cuesheet')).toBeVisible();
await page.getByRole('button', { name: 'Share...' }).click();
// configure share for readonly
await page.getByRole('textbox').fill('cuesheet-read-test');
await page.locator('input[name="alias"]').fill(alias);
await page.getByText('Custom write').click();
await page.getByText('Custom read').click();
await page.getByTestId('lockNav').click();
@@ -151,9 +153,16 @@ test.describe('Sharing from cuesheet', () => {
await page.getByTestId('write-duration').click();
await page.getByTestId('write-note').click();
// disable any custom write permissions if they exist
const customWriteSwitches = page.locator('[data-testid^="write-custom-"]');
const customWriteSwitchCount = await customWriteSwitches.count();
for (let i = 0; i < customWriteSwitchCount; i++) {
await customWriteSwitches.nth(i).click();
}
// create and verify link
await page.getByRole('button', { name: 'Create share link' }).click();
await expect(page.getByTestId('copy-link')).toContainText('preset/cuesheet-read-test');
await expect(page.getByTestId('copy-link')).toContainText(`preset/${alias}`);
await expect(page.getByTestId('copy-link')).toContainText('n=1');
// verify the preset
@@ -177,14 +186,16 @@ test.describe('Sharing from cuesheet', () => {
await expect(page.getByRole('cell', { name: 'Duration' })).toBeVisible();
});
test('Sharing a link with scoped read-write permissions', async ({ page }) => {
test('Sharing a link with scoped read-write permissions', async ({ page }, testInfo) => {
const alias = `cuesheet-scope-test-${testInfo.retry}-${Date.now()}`;
await page.goto('http://localhost:4001/cuesheet');
await expect(page.getByTestId('cuesheet')).toBeVisible();
await page.getByRole('button', { name: 'Share...' }).click();
// configure share for readonly
await page.getByRole('textbox').fill('cuesheet-scope-test');
await page.locator('input[name="alias"]').fill(alias);
await page.getByText('Custom write').click();
await page.getByText('Custom read').click();
await page.getByTestId('lockNav').click();
@@ -203,7 +214,7 @@ test.describe('Sharing from cuesheet', () => {
// create and verify link
await page.getByRole('button', { name: 'Create share link' }).click();
await expect(page.getByTestId('copy-link')).toContainText('preset/cuesheet-scope-test');
await expect(page.getByTestId('copy-link')).toContainText(`preset/${alias}`);
await expect(page.getByTestId('copy-link')).toContainText('n=1');
// verify the preset
@@ -220,8 +231,9 @@ test.describe('Sharing from cuesheet', () => {
// Verify that the title is visible and editable
await expect(page.getByTestId('cuesheet-event').getByRole('cell', { name: 'title' })).toBeVisible();
await page.getByTestId('cuesheet-event').getByTestId('cuesheet-editor-title').click();
await expect(page.getByTestId('cuesheet-event').getByTestId('cuesheet-editor-title').locator('input')).toBeVisible();
const titleEditor = page.getByTestId('cuesheet-event').getByTestId('cuesheet-editor-title');
await titleEditor.click();
await expect(titleEditor).toBeEditable();
// other elements are not there
await expect(page.getByRole('cell', { name: 'Duration' })).toBeHidden();