feat(core): add a two-step confirm page to create new journal (#13240)

close AF-2750;

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Introduced a new workspace journals page with date-based navigation,
placeholder UI, and the ability to create daily journals directly from
the page.
* Added a "Today" button for quick navigation to the current day's
journal when viewing other dates.

* **Improvements**
* Enhanced the journal document title display with improved date
formatting and flexible styling.
* Expanded the active state for the journal sidebar button to cover all
journal-related routes.
* Updated journal navigation to open existing entries directly or
navigate to filtered journal listings.

* **Bug Fixes**
* Improved date handling and navigation logic for journal entries to
ensure accurate redirection and creation flows.

* **Style**
* Added new styles for the workspace journals page, including headers,
placeholders, and buttons.

* **Localization**
* Added English translations for journal placeholder text and create
journal prompts.

* **Tests**
* Added confirmation steps in journal creation flows to improve test
reliability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Cats Juice
2025-07-17 10:32:01 +08:00
committed by GitHub
parent 3949714618
commit 46a2ad750f
14 changed files with 304 additions and 30 deletions
+1
View File
@@ -78,6 +78,7 @@ test('tab title will change when navigating', async ({ page }) => {
// go to today's journal
await page.getByTestId('slider-bar-journals-button').click();
await page.getByTestId('confirm-create-journal-button').click();
await expect(page.locator('.doc-title-container')).toContainText('Today');
const dateString = await page
.locator('.doc-title-container > span:first-of-type')
+5 -1
View File
@@ -1,5 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page';
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';
@@ -84,6 +87,7 @@ async function createPageAndTurnIntoJournal(page: Page) {
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);
});
+7 -1
View File
@@ -1,5 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page';
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';
@@ -183,6 +186,7 @@ test('set default template for journal', async ({ page }) => {
// by default create a journal, should not use template
await page.getByTestId('slider-bar-journals-button').click();
await confirmCreateJournal(page);
await waitForEditorLoad(page);
await expect(
page.getByText('This is a journal template doc')
@@ -200,6 +204,7 @@ test('set default template for journal', async ({ page }) => {
const prevWeekButton = page.getByTestId('week-picker-prev');
await prevWeekButton.click();
await page.getByTestId('week-picker-day').first().click();
await confirmCreateJournal(page);
await waitForEditorLoad(page);
await expect(page.getByText('This is a page template doc')).toBeVisible();
@@ -212,6 +217,7 @@ test('set default template for journal', async ({ page }) => {
// create a new journal
await prevWeekButton.click();
await page.getByTestId('week-picker-day').first().click();
await confirmCreateJournal(page);
await waitForEditorLoad(page);
await expect(page.getByText('This is a journal template doc')).toBeVisible();
});
+6
View File
@@ -15,8 +15,14 @@ export async function open404Page(page: Page) {
await page.goto(`${coreUrl}/404`);
}
export async function confirmCreateJournal(page: Page) {
const confirmButton = page.getByTestId('confirm-create-journal-button');
await confirmButton.click();
}
export async function openJournalsPage(page: Page) {
await page.getByTestId('slider-bar-journals-button').click();
await confirmCreateJournal(page);
await expect(
page.locator('.doc-title-container:has-text("Today")')
).toBeVisible();