Skip to content

Commit

Permalink
feat(core): add basic tests for page journal property
Browse files Browse the repository at this point in the history
  • Loading branch information
CatsJuice committed Oct 18, 2024
1 parent 3a9e90d commit 2f9dbef
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const BlocksuiteEditorJournalDocTitle = ({ page }: { page: Doc }) => {
const day = journalDate?.format('dddd') ?? null;

return (
<div className="doc-title-container">
<span>{localizedJournalDate}</span>
<div className="doc-title-container" data-testid="journal-title">
<span data-testid="date">{localizedJournalDate}</span>
{isTodayJournal ? (
<span className={styles.titleTodayTag}>{t['com.affine.today']()}</span>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const JournalWeekDatePicker = ({

return (
<WeekDatePicker
data-testid="journal-week-picker"
handleRef={handleRef}
style={weekStyle}
value={date}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export const DocPropertyRow = ({
hideEmpty={hideEmpty}
hide={hide}
data-testid="doc-property-row"
data-info-id={propertyInfo.id}
>
<PropertyName
defaultOpenMenu={defaultOpenEditMenu}
Expand Down Expand Up @@ -414,6 +415,7 @@ export const DocPropertiesTableBody = forwardRef<
variant="plain"
prefix={<PlusIcon />}
className={styles.propertyActionButton}
data-testid="add-property-button"
>
{t['com.affine.page-properties.add-property']()}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const JournalValue = () => {
style: { padding: 20 },
}}
rootOptions={{
modal: true,
open: showDatePicker,
onOpenChange: setShowDatePicker,
}}
Expand All @@ -112,12 +113,18 @@ export const JournalValue = () => {
/>
}
>
<div className={styles.date}>{displayDate}</div>
<div data-testid="date-selector" className={styles.date}>
{displayDate}
</div>
</Menu>
) : null}

{checked && conflict ? (
<div className={styles.duplicateTag} onClick={handleOpenDuplicate}>
<div
data-testid="conflict-tag"
className={styles.duplicateTag}
onClick={handleOpenDuplicate}
>
{t['com.affine.page-properties.property.journal-duplicated']()}
</div>
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const PageItem = ({

return (
<WorkbenchLink
data-testid="journal-conflict-item"
aria-label={title}
to={`/${docId}`}
className={clsx(className, styles.pageItem)}
Expand Down Expand Up @@ -118,9 +119,6 @@ export const EditorJournalPanel = () => {

const customDayRenderer = useCallback(
(cell: DateCell) => {
// TODO(@catsjuice): add a dot to indicate journal
// has performance issue for now, better to calculate it in advance
// const hasJournal = !!getJournalsByDate(cell.date.format('YYYY-MM-DD'))?.length;
const hasJournal = allJournalDates.has(cell.date.format('YYYY-MM-DD'));
return (
<button
Expand All @@ -145,7 +143,11 @@ export const EditorJournalPanel = () => {
);

return (
<div className={styles.journalPanel} data-is-journal={isJournal}>
<div
className={styles.journalPanel}
data-is-journal={isJournal}
data-testid="sidebar-journal-panel"
>
<div data-mobile={mobile} className={styles.calendar}>
<DatePicker
weekDays={t['com.affine.calendar-date-picker.week-days']()}
Expand Down Expand Up @@ -330,7 +332,11 @@ const ConflictList = ({
);

return (
<div className={clsx(styles.journalConflictWrapper, className)} {...attrs}>
<div
data-testid="journal-conflict-list"
className={clsx(styles.journalConflictWrapper, className)}
{...attrs}
>
{docRecords.map(docRecord => {
const isCurrent = docRecord.id === currentDoc.id;
return (
Expand All @@ -355,6 +361,7 @@ const ConflictList = ({
e.stopPropagation();
handleRemoveJournalMark(docRecord.id);
}}
data-testid="journal-conflict-remove-mark"
>
{t[
'com.affine.page-properties.property.journal-remove'
Expand All @@ -367,7 +374,10 @@ const ConflictList = ({
</>
}
>
<IconButton icon={<EditIcon />} />
<IconButton
data-testid="journal-conflict-edit"
icon={<EditIcon />}
/>
</Menu>
}
/>
Expand Down
113 changes: 113 additions & 0 deletions tests/affine-local/e2e/journal.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import { test } from '@affine-test/kit/playwright';
import { 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();
}

if ((await getJournalRow(page).count()) === 0) {
await page.getByTestId('add-property-button').click();

Check failure on line 45 in tests/affine-local/e2e/journal.spec.ts

View workflow job for this annotation

GitHub Actions / E2E Test (2)

journal.spec.ts:82:5 › Create a page and turn it into a journal

1) journal.spec.ts:82:5 › Create a page and turn it into a journal ─────────────────────────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for getByTestId('add-property-button') - locator resolved to <button type="button" id="radix-:r2u:" data-state="closed" data-size="default" data-mobile="false" aria-haspopup="menu" data-variant="plain" aria-expanded="false" data-testid="add-property-button" class="button_button__ph3zqme table_propertyActionButton__y8p28lg">…</button> - attempting click action - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #1 - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #2 - waiting 20ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #3 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #4 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #5 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #6 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #7 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #8 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #9 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #10 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #11 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #12 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #13 - waiting 500ms 43 | 44 | if ((await getJournalRow(page).count()) === 0) { > 45 | await page.getByTestId('add-property-button').click(); | ^ 46 | await page 47 | .locator('[role="menuitem"][data-property-type="journal"]') 48 | .click(); at openPagePropertiesAndAddJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:45:51) at createPageAndTurnIntoJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:70:22) at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:84:3

Check failure on line 45 in tests/affine-local/e2e/journal.spec.ts

View workflow job for this annotation

GitHub Actions / E2E Test (2)

journal.spec.ts:82:5 › Create a page and turn it into a journal

1) journal.spec.ts:82:5 › Create a page and turn it into a journal ─────────────────────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for getByTestId('add-property-button') - locator resolved to <button type="button" id="radix-:r2u:" data-state="closed" data-size="default" data-mobile="false" aria-haspopup="menu" data-variant="plain" aria-expanded="false" data-testid="add-property-button" class="button_button__ph3zqme table_propertyActionButton__y8p28lg">…</button> - attempting click action - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #1 - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #2 - waiting 20ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #3 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #4 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #5 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #6 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #7 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #8 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #9 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #10 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #11 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #12 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #13 - waiting 500ms 43 | 44 | if ((await getJournalRow(page).count()) === 0) { > 45 | await page.getByTestId('add-property-button').click(); | ^ 46 | await page 47 | .locator('[role="menuitem"][data-property-type="journal"]') 48 | .click(); at openPagePropertiesAndAddJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:45:51) at createPageAndTurnIntoJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:70:22) at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:84:3

Check failure on line 45 in tests/affine-local/e2e/journal.spec.ts

View workflow job for this annotation

GitHub Actions / E2E Test (2)

journal.spec.ts:82:5 › Create a page and turn it into a journal

1) journal.spec.ts:82:5 › Create a page and turn it into a journal ─────────────────────────────── Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for getByTestId('add-property-button') - locator resolved to <button type="button" id="radix-:r2u:" data-state="closed" data-size="default" data-mobile="false" aria-haspopup="menu" data-variant="plain" aria-expanded="false" data-testid="add-property-button" class="button_button__ph3zqme table_propertyActionButton__y8p28lg">…</button> - attempting click action - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #1 - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #2 - waiting 20ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #3 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #4 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #5 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #6 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #7 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #8 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #9 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #10 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #11 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #12 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #13 - waiting 500ms 43 | 44 | if ((await getJournalRow(page).count()) === 0) { > 45 | await page.getByTestId('add-property-button').click(); | ^ 46 | await page 47 | .locator('[role="menuitem"][data-property-type="journal"]') 48 | .click(); at openPagePropertiesAndAddJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:45:51) at createPageAndTurnIntoJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:70:22) at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:84:3

Check failure on line 45 in tests/affine-local/e2e/journal.spec.ts

View workflow job for this annotation

GitHub Actions / E2E Test (2)

journal.spec.ts:82:5 › Create a page and turn it into a journal

1) journal.spec.ts:82:5 › Create a page and turn it into a journal ─────────────────────────────── Retry #3 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for getByTestId('add-property-button') - locator resolved to <button type="button" id="radix-:r2u:" data-state="closed" data-size="default" data-mobile="false" aria-haspopup="menu" data-variant="plain" aria-expanded="false" data-testid="add-property-button" class="button_button__ph3zqme table_propertyActionButton__y8p28lg">…</button> - attempting click action - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #1 - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #2 - waiting 20ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #3 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #4 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #5 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #6 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #7 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #8 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #9 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #10 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #11 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #12 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #13 - waiting 500ms 43 | 44 | if ((await getJournalRow(page).count()) === 0) { > 45 | await page.getByTestId('add-property-button').click(); | ^ 46 | await page 47 | .locator('[role="menuitem"][data-property-type="journal"]') 48 | .click(); at openPagePropertiesAndAddJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:45:51) at createPageAndTurnIntoJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:70:22) at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:84:3

Check failure on line 45 in tests/affine-local/e2e/journal.spec.ts

View workflow job for this annotation

GitHub Actions / E2E Test (2)

journal.spec.ts:88:5 › Should show duplicated tag when create journal on same day

2) journal.spec.ts:88:5 › Should show duplicated tag when create journal on same day ───────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for getByTestId('add-property-button') - locator resolved to <button type="button" id="radix-:r2u:" data-state="closed" data-size="default" data-mobile="false" aria-haspopup="menu" data-variant="plain" aria-expanded="false" data-testid="add-property-button" class="button_button__ph3zqme table_propertyActionButton__y8p28lg">…</button> - attempting click action - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #1 - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #2 - waiting 20ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #3 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #4 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #5 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #6 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #7 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #8 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #9 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #10 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #11 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #12 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #13 - waiting 500ms 43 | 44 | if ((await getJournalRow(page).count()) === 0) { > 45 | await page.getByTestId('add-property-button').click(); | ^ 46 | await page 47 | .locator('[role="menuitem"][data-property-type="journal"]') 48 | .click(); at openPagePropertiesAndAddJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:45:51) at createPageAndTurnIntoJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:70:22) at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:92:3

Check failure on line 45 in tests/affine-local/e2e/journal.spec.ts

View workflow job for this annotation

GitHub Actions / E2E Test (2)

journal.spec.ts:88:5 › Should show duplicated tag when create journal on same day

2) journal.spec.ts:88:5 › Should show duplicated tag when create journal on same day ───────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for getByTestId('add-property-button') - locator resolved to <button type="button" id="radix-:r2u:" data-state="closed" data-size="default" data-mobile="false" aria-haspopup="menu" data-variant="plain" aria-expanded="false" data-testid="add-property-button" class="button_button__ph3zqme table_propertyActionButton__y8p28lg">…</button> - attempting click action - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #1 - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #2 - waiting 20ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #3 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #4 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #5 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #6 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #7 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #8 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #9 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #10 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #11 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #12 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #13 - waiting 500ms 43 | 44 | if ((await getJournalRow(page).count()) === 0) { > 45 | await page.getByTestId('add-property-button').click(); | ^ 46 | await page 47 | .locator('[role="menuitem"][data-property-type="journal"]') 48 | .click(); at openPagePropertiesAndAddJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:45:51) at createPageAndTurnIntoJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:70:22) at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:92:3

Check failure on line 45 in tests/affine-local/e2e/journal.spec.ts

View workflow job for this annotation

GitHub Actions / E2E Test (2)

journal.spec.ts:88:5 › Should show duplicated tag when create journal on same day

2) journal.spec.ts:88:5 › Should show duplicated tag when create journal on same day ───────────── Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for getByTestId('add-property-button') - locator resolved to <button type="button" id="radix-:r2u:" data-state="closed" data-size="default" data-mobile="false" aria-haspopup="menu" data-variant="plain" aria-expanded="false" data-testid="add-property-button" class="button_button__ph3zqme table_propertyActionButton__y8p28lg">…</button> - attempting click action - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #1 - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #2 - waiting 20ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #3 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #4 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #5 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #6 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #7 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #8 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #9 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #10 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #11 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #12 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #13 - waiting 500ms 43 | 44 | if ((await getJournalRow(page).count()) === 0) { > 45 | await page.getByTestId('add-property-button').click(); | ^ 46 | await page 47 | .locator('[role="menuitem"][data-property-type="journal"]') 48 | .click(); at openPagePropertiesAndAddJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:45:51) at createPageAndTurnIntoJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:70:22) at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:92:3

Check failure on line 45 in tests/affine-local/e2e/journal.spec.ts

View workflow job for this annotation

GitHub Actions / E2E Test (2)

journal.spec.ts:88:5 › Should show duplicated tag when create journal on same day

2) journal.spec.ts:88:5 › Should show duplicated tag when create journal on same day ───────────── Retry #3 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for getByTestId('add-property-button') - locator resolved to <button type="button" id="radix-:r2u:" data-state="closed" data-size="default" data-mobile="false" aria-haspopup="menu" data-variant="plain" aria-expanded="false" data-testid="add-property-button" class="button_button__ph3zqme table_propertyActionButton__y8p28lg">…</button> - attempting click action - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #1 - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #2 - waiting 20ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #3 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #4 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #5 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #6 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #7 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #8 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #9 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #10 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #11 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #12 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #13 - waiting 500ms 43 | 44 | if ((await getJournalRow(page).count()) === 0) { > 45 | await page.getByTestId('add-property-button').click(); | ^ 46 | await page 47 | .locator('[role="menuitem"][data-property-type="journal"]') 48 | .click(); at openPagePropertiesAndAddJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:45:51) at createPageAndTurnIntoJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:70:22) at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:92:3

Check failure on line 45 in tests/affine-local/e2e/journal.spec.ts

View workflow job for this annotation

GitHub Actions / E2E Test (2)

journal.spec.ts:97:5 › Resolve duplicated journal

3) journal.spec.ts:97:5 › Resolve duplicated journal ───────────────────────────────────────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for getByTestId('add-property-button') - locator resolved to <button type="button" id="radix-:r2u:" data-state="closed" data-size="default" data-mobile="false" aria-haspopup="menu" data-variant="plain" aria-expanded="false" data-testid="add-property-button" class="button_button__ph3zqme table_propertyActionButton__y8p28lg">…</button> - attempting click action - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #1 - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #2 - waiting 20ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #3 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #4 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #5 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #6 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #7 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #8 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #9 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #10 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #11 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #12 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #13 - waiting 500ms 43 | 44 | if ((await getJournalRow(page).count()) === 0) { > 45 | await page.getByTestId('add-property-button').click(); | ^ 46 | await page 47 | .locator('[role="menuitem"][data-property-type="journal"]') 48 | .click(); at openPagePropertiesAndAddJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:45:51) at createPageAndTurnIntoJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:70:22) at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:99:3

Check failure on line 45 in tests/affine-local/e2e/journal.spec.ts

View workflow job for this annotation

GitHub Actions / E2E Test (2)

journal.spec.ts:97:5 › Resolve duplicated journal

3) journal.spec.ts:97:5 › Resolve duplicated journal ───────────────────────────────────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for getByTestId('add-property-button') - locator resolved to <button type="button" id="radix-:r2u:" data-state="closed" data-size="default" data-mobile="false" aria-haspopup="menu" data-variant="plain" aria-expanded="false" data-testid="add-property-button" class="button_button__ph3zqme table_propertyActionButton__y8p28lg">…</button> - attempting click action - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #1 - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #2 - waiting 20ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #3 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #4 - waiting 100ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #5 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #6 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #7 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #8 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #9 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #10 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #11 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #12 - waiting 500ms - waiting for element to be visible, enabled and stable - element is not visible - retrying click action, attempt #13 - waiting 500ms 43 | 44 | if ((await getJournalRow(page).count()) === 0) { > 45 | await page.getByTestId('add-property-button').click(); | ^ 46 | await page 47 | .locator('[role="menuitem"][data-property-type="journal"]') 48 | .click(); at openPagePropertiesAndAddJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:45:51) at createPageAndTurnIntoJournal (/home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:70:22) at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/journal.spec.ts:99:3
await page
.locator('[role="menuitem"][data-property-type="journal"]')
.click();
await page.keyboard.press('Escape');
}

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 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();
});

0 comments on commit 2f9dbef

Please sign in to comment.