feat(core): make some tabs in sidebar persistent for all docs page (#10014)

close AF-2164

![CleanShot 2025-02-07 at 14.23.36.gif](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/LakojjjzZNf6ogjOVwKE/deb15a06-32e9-40bf-8a15-07a3c2fa8227.gif)
This commit is contained in:
CatsJuice
2025-02-10 14:58:26 +00:00
parent c78d6b81c6
commit f774868f0e
11 changed files with 68 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
/* eslint-disable unicorn/prefer-dom-node-dataset */
/* oxlint-disable unicorn/prefer-dom-node-dataset */
import { test } from '@affine-test/kit/playwright';
import {
changeFilter,
@@ -80,13 +80,16 @@ test('use monthpicker to modify the month of datepicker', async ({ page }) => {
await clickDatePicker(page);
const lastMonth = new Date();
lastMonth.setMonth(lastMonth.getMonth() - 1);
await selectMonthFromMonthPicker(page, lastMonth);
await checkDatePickerMonth(page, lastMonth);
const datePicker = page.locator(
'[role="dialog"] [data-testid="date-picker-calendar"]'
);
await selectMonthFromMonthPicker(datePicker, lastMonth);
await checkDatePickerMonth(datePicker, lastMonth);
// change month
const nextMonth = new Date();
nextMonth.setMonth(nextMonth.getMonth() + 1);
await selectMonthFromMonthPicker(page, nextMonth);
await checkDatePickerMonth(page, nextMonth);
await selectMonthFromMonthPicker(datePicker, nextMonth);
await checkDatePickerMonth(datePicker, nextMonth);
});
test('allow creation of filters by tags', async ({ page }) => {

View File

@@ -1,4 +1,4 @@
import type { Page } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import { expect } from '@playwright/test';
import { clickNewPageButton, getBlockSuiteEditorTitle } from './page-logic';
@@ -49,7 +49,7 @@ export const getPagesCount = async (page: Page) => {
}
// locator is not a HTMLElement, so we can't use dataset
// eslint-disable-next-line unicorn/prefer-dom-node-dataset
// oxlint-disable-next-line unicorn/prefer-dom-node-dataset
const count = await locator.getAttribute('data-total-count');
return count ? parseInt(count) : 0;
};
@@ -67,7 +67,7 @@ export const clickDatePicker = async (page: Page) => {
await page.locator('[data-testid="filter-arg"]').locator('input').click();
};
const clickMonthPicker = async (page: Page) => {
const clickMonthPicker = async (page: Page | Locator) => {
await page.locator('[data-testid="month-picker-button"]').click();
};
@@ -78,7 +78,10 @@ export const fillDatePicker = async (page: Page, date: Date) => {
.fill(dateFormat(date));
};
export const selectMonthFromMonthPicker = async (page: Page, date: Date) => {
export const selectMonthFromMonthPicker = async (
page: Page | Locator,
date: Date
) => {
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const year = date.getFullYear();
// Open the month picker popup
@@ -103,7 +106,10 @@ export const selectMonthFromMonthPicker = async (page: Page, date: Date) => {
await selectMonth();
};
export const checkDatePickerMonth = async (page: Page, date: Date) => {
export const checkDatePickerMonth = async (
page: Page | Locator,
date: Date
) => {
expect(
await page.getByTestId('month-picker-button').evaluate(e => e.dataset.month)
).toBe(date.getMonth().toString());