Files
docs/src/frontend/apps/e2e/__tests__/app-impress/doc-inherited-share.spec.ts
Anthony LC a01c5f97ca (e2e) e2e instances compatibility
We want to be able to run our e2e tests on
any instance of Docs, to do so we need to make
some adjustments to our tests and configuration.
We will use environment variables to configure
the tests.
2026-04-07 16:11:18 +02:00

99 lines
3.4 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { createDoc, verifyDocName } from './utils-common';
import { updateShareLink } from './utils-share';
import { createRootSubPage } from './utils-sub-pages';
test.describe('Inherited share accesses', () => {
test('it checks inherited accesses', async ({ page, browserName }) => {
await page.goto('/');
const [parentTitle] = await createDoc(page, 'root-doc', browserName, 1);
// Wait for and intercept the POST request to create a new page
await createRootSubPage(page, browserName, 'sub-page');
await page.getByRole('button', { name: 'Share' }).click();
await expect(
page.getByText('People with access via the parent document'),
).toBeVisible();
const users = page.locator('.--docs--doc-share-member-item');
await expect(users).toBeVisible();
await expect(
users.getByText(
process.env[`SIGN_IN_USERNAME_${browserName.toUpperCase()}`] || '',
),
).toBeVisible();
await expect(users.getByText('Owner')).toBeVisible();
await page
.locator('.--docs--doc-inherited-share-content')
.getByRole('link')
.click();
await verifyDocName(page, parentTitle);
});
test('it checks if the link is inherited', async ({ page, browserName }) => {
await page.goto('/');
// Create root doc
await createDoc(page, 'root-doc', browserName, 1);
// Update share link
await page.getByRole('button', { name: 'Share' }).click();
await updateShareLink(page, 'Connected', 'Reading');
await page.getByRole('button', { name: 'OK' }).click();
// Create sub page
await createRootSubPage(page, browserName, 'sub-page');
// Verify share link is like the parent document
await page.getByRole('button', { name: 'Share' }).click();
const docVisibilityCard = page.getByLabel('Doc visibility card');
await expect(docVisibilityCard.getByText('Connected')).toBeVisible();
await expect(docVisibilityCard.getByText('Reading')).toBeVisible();
await docVisibilityCard.getByText('Reading').click();
await page.getByRole('menuitemradio', { name: 'Editing' }).click();
await expect(docVisibilityCard.getByText('Reading')).toBeHidden();
await expect(docVisibilityCard.getByText('Editing')).toBeVisible();
// Verify inherited link
await docVisibilityCard.getByText('Connected').click();
await expect(
page.getByRole('menuitemradio', { name: 'Private' }),
).toBeDisabled();
// Update child link
await page.getByRole('menuitemradio', { name: 'Public' }).click();
await expect(docVisibilityCard.getByText('Connected')).toBeHidden();
await expect(
docVisibilityCard.getByText('Public', {
exact: true,
}),
).toBeVisible();
await expect(
docVisibilityCard.getByText(
'The link sharing rules differ from the parent document',
),
).toBeVisible();
// Restore inherited link
await page.getByRole('button', { name: 'Restore' }).click();
await expect(docVisibilityCard.getByText('Connected')).toBeVisible();
await expect(docVisibilityCard.getByText('Reading')).toBeVisible();
await expect(docVisibilityCard.getByText('Public')).toBeHidden();
await expect(docVisibilityCard.getByText('Editing')).toBeHidden();
await expect(
docVisibilityCard.getByText(
'The link sharing rules differ from the parent document',
),
).toBeHidden();
});
});