mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat: enable share menu (#1883)
Co-authored-by: JimmFly <yangjinfei001@gmail.com>
This commit is contained in:
65
tests/parallels/affine/affine-public-single-page.spec.ts
Normal file
65
tests/parallels/affine/affine-public-single-page.spec.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { waitMarkdownImported } from '../../libs/page-logic';
|
||||
import { test } from '../../libs/playwright';
|
||||
import { clickNewPageButton } from '../../libs/sidebar';
|
||||
import { createFakeUser, loginUser, openHomePage } from '../../libs/utils';
|
||||
import { createWorkspace } from '../../libs/workspace';
|
||||
|
||||
test.describe('affine single page', () => {
|
||||
test('public single page', async ({ page, browser }) => {
|
||||
await openHomePage(page);
|
||||
const [a] = await createFakeUser();
|
||||
await loginUser(page, a);
|
||||
await waitMarkdownImported(page);
|
||||
const name = `test-${Date.now()}`;
|
||||
await createWorkspace({ name }, page);
|
||||
await waitMarkdownImported(page);
|
||||
await clickNewPageButton(page);
|
||||
const page1Id = page.url().split('/').at(-1);
|
||||
await clickNewPageButton(page);
|
||||
const page2Id = page.url().split('/').at(-1);
|
||||
expect(typeof page2Id).toBe('string');
|
||||
expect(page1Id).not.toBe(page2Id);
|
||||
const title = 'This is page 2';
|
||||
await page.locator('[data-block-is-title="true"]').type(title, {
|
||||
delay: 50,
|
||||
});
|
||||
await page.getByTestId('share-menu-button').click();
|
||||
await page.getByTestId('share-menu-enable-affine-cloud-button').click();
|
||||
const promise = page.evaluate(
|
||||
async () =>
|
||||
new Promise(resolve =>
|
||||
window.addEventListener('affine-workspace:transform', resolve, {
|
||||
once: true,
|
||||
})
|
||||
)
|
||||
);
|
||||
await page.getByTestId('confirm-enable-cloud-button').click();
|
||||
await promise;
|
||||
const newPage2Url = page.url().split('/');
|
||||
newPage2Url[newPage2Url.length - 1] = page2Id as string;
|
||||
await page.goto(newPage2Url.join('/'));
|
||||
await page.waitForSelector('v-line');
|
||||
const currentTitle = await page
|
||||
.locator('[data-block-is-title="true"]')
|
||||
.textContent();
|
||||
expect(currentTitle).toBe(title);
|
||||
await page.getByTestId('share-menu-button').click();
|
||||
await page.getByTestId('affine-share-create-link').click();
|
||||
await page.getByTestId('affine-share-copy-link').click();
|
||||
const url = await page.evaluate(() => navigator.clipboard.readText());
|
||||
expect(url.startsWith('http://localhost:8080/public-workspace/')).toBe(
|
||||
true
|
||||
);
|
||||
await page.waitForTimeout(1000);
|
||||
const context2 = await browser.newContext();
|
||||
const page2 = await context2.newPage();
|
||||
await page2.goto(url);
|
||||
await page2.waitForSelector('v-line');
|
||||
const currentTitle2 = await page2
|
||||
.locator('[data-block-is-title="true"]')
|
||||
.textContent();
|
||||
expect(currentTitle2).toBe(title);
|
||||
});
|
||||
});
|
||||
@@ -3,11 +3,11 @@ import { expect } from '@playwright/test';
|
||||
import { test } from '../libs/playwright';
|
||||
|
||||
test.describe('Debug page broadcast', () => {
|
||||
test('should broadcast a message to all debug pages', async ({ page }) => {
|
||||
test('should have page0', async ({ page }) => {
|
||||
await page.goto(
|
||||
'http://localhost:8080/_debug/init-page?type=importMarkdown'
|
||||
);
|
||||
await page.waitForSelector('rich-text');
|
||||
await page.waitForSelector('v-line');
|
||||
const pageId = await page.evaluate(async () => {
|
||||
// @ts-ignore
|
||||
return globalThis.page.id;
|
||||
|
||||
@@ -49,6 +49,7 @@ test.describe('AFFiNE change log', () => {
|
||||
const editorRightBottomChangeLog = page.locator(
|
||||
'[data-testid=right-bottom-change-log-icon]'
|
||||
);
|
||||
await page.waitForTimeout(50);
|
||||
expect(await editorRightBottomChangeLog.isVisible()).toEqual(true);
|
||||
await page.getByRole('link', { name: 'All pages' }).click();
|
||||
const normalRightBottomChangeLog = page.locator(
|
||||
|
||||
Reference in New Issue
Block a user