Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Copilot Test Automatically / Setup Test (push) Failing after 1s
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped
127 lines
4.4 KiB
TypeScript
127 lines
4.4 KiB
TypeScript
import { test } from '@affine-test/kit/playwright';
|
|
import {
|
|
confirmCreateJournal,
|
|
openHomePage,
|
|
} from '@affine-test/kit/utils/load-page';
|
|
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
|
|
import { expect, type Locator, type Page } from '@playwright/test';
|
|
|
|
type MaybeDate = string | number | Date;
|
|
function isSameDay(d1: MaybeDate, d2: MaybeDate) {
|
|
const date1 = new Date(d1);
|
|
const date2 = new Date(d2);
|
|
return (
|
|
date1.getFullYear() === date2.getFullYear() &&
|
|
date1.getMonth() === date2.getMonth() &&
|
|
date1.getDate() === date2.getDate()
|
|
);
|
|
}
|
|
|
|
function getJournalRow(page: Page) {
|
|
return page.locator(
|
|
'[data-testid="doc-property-row"][data-info-id="journal"]'
|
|
);
|
|
}
|
|
async function isJournalEditor(page: Page, maybeDate?: string | number | Date) {
|
|
// journal header
|
|
const header = page.getByTestId('header');
|
|
const weekPicker = header.getByTestId('journal-week-picker');
|
|
await expect(weekPicker).toBeVisible();
|
|
|
|
// journal title
|
|
const journalTitle = page.getByTestId('journal-title');
|
|
await expect(journalTitle).toBeVisible();
|
|
|
|
if (maybeDate) {
|
|
const date = (await journalTitle.getByTestId('date').textContent()) ?? '';
|
|
expect(isSameDay(date, maybeDate)).toBeTruthy();
|
|
}
|
|
}
|
|
async function openPagePropertiesAndAddJournal(page: Page) {
|
|
const collapse = page.getByTestId('page-info-collapse');
|
|
const open = await collapse.getAttribute('aria-expanded');
|
|
if (open?.toLowerCase() !== 'true') {
|
|
await collapse.click();
|
|
}
|
|
|
|
// add if not exists
|
|
if ((await getJournalRow(page).count()) === 0) {
|
|
const addPropertyButton = page.getByTestId('add-property-button');
|
|
if (!(await addPropertyButton.isVisible())) {
|
|
await page.getByTestId('property-collapsible-button').click();
|
|
}
|
|
await addPropertyButton.click();
|
|
await page
|
|
.locator('[role="menuitem"][data-property-type="journal"]')
|
|
.click();
|
|
await page.keyboard.press('Escape');
|
|
}
|
|
// expand if collapsed
|
|
else if (!(await getJournalRow(page).isVisible())) {
|
|
await page.getByTestId('property-collapsible-button').click();
|
|
}
|
|
|
|
const journalRow = getJournalRow(page);
|
|
await expect(journalRow).toBeVisible();
|
|
return journalRow;
|
|
}
|
|
async function toggleJournal(row: Locator, value: boolean) {
|
|
const checkbox = row.locator('input[type="checkbox"]');
|
|
const state = await checkbox.inputValue();
|
|
const checked = state === 'on';
|
|
if (checked !== value) {
|
|
await checkbox.click();
|
|
const newState = await checkbox.inputValue();
|
|
const newChecked = newState === 'on';
|
|
expect(newChecked).toBe(value);
|
|
}
|
|
}
|
|
async function createPageAndTurnIntoJournal(page: Page) {
|
|
await page.getByTestId('sidebar-new-page-button').click();
|
|
await waitForEditorLoad(page);
|
|
const journalRow = await openPagePropertiesAndAddJournal(page);
|
|
await toggleJournal(journalRow, true);
|
|
return journalRow;
|
|
}
|
|
|
|
test('Create a journal from sidebar', async ({ page }) => {
|
|
await openHomePage(page);
|
|
await page.getByTestId('slider-bar-journals-button').click();
|
|
await confirmCreateJournal(page);
|
|
await waitForEditorLoad(page);
|
|
await isJournalEditor(page);
|
|
});
|
|
|
|
test('Create a page and turn it into a journal', async ({ page }) => {
|
|
await openHomePage(page);
|
|
await createPageAndTurnIntoJournal(page);
|
|
await isJournalEditor(page, new Date());
|
|
});
|
|
|
|
test('Should show duplicated tag when create journal on same day', async ({
|
|
page,
|
|
}) => {
|
|
await openHomePage(page);
|
|
await createPageAndTurnIntoJournal(page);
|
|
const journalRow2 = await createPageAndTurnIntoJournal(page);
|
|
await expect(journalRow2.getByTestId('conflict-tag')).toBeVisible();
|
|
});
|
|
|
|
test('Resolve duplicated journal', async ({ page }) => {
|
|
await openHomePage(page);
|
|
await createPageAndTurnIntoJournal(page);
|
|
const journalRow2 = await createPageAndTurnIntoJournal(page);
|
|
await journalRow2.getByTestId('conflict-tag').click();
|
|
const journalPanel = page.getByTestId('sidebar-journal-panel');
|
|
await expect(journalPanel).toBeVisible();
|
|
const conflictList = journalPanel.getByTestId('journal-conflict-list');
|
|
await expect(conflictList).toBeVisible();
|
|
const conflictItems = conflictList.getByTestId('journal-conflict-item');
|
|
const first = conflictItems.first();
|
|
await first.getByTestId('journal-conflict-edit').click();
|
|
await page.getByTestId('journal-conflict-remove-mark').click();
|
|
|
|
await expect(journalRow2.getByTestId('conflict-tag')).not.toBeVisible();
|
|
await expect(conflictList).not.toBeVisible();
|
|
});
|