fix(core): local workspace collections (#4378)
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
// todo
|
|
||||||
export function useLocationTitle(): string {
|
|
||||||
return 'AFFiNE';
|
|
||||||
}
|
|
||||||
@@ -93,14 +93,15 @@ const pageCollectionBaseAtom = atomWithObservable<Collection[]>(get => {
|
|||||||
// initial value
|
// initial value
|
||||||
subscriber.next([]);
|
subscriber.next([]);
|
||||||
if (useLocalStorage) {
|
if (useLocalStorage) {
|
||||||
getCollections(localCRUD).then(collections => {
|
|
||||||
subscriber.next(collections);
|
|
||||||
});
|
|
||||||
const fn = () => {
|
const fn = () => {
|
||||||
getCollections(localCRUD).then(collections => {
|
getCollections(localCRUD).then(async collections => {
|
||||||
subscriber.next(collections);
|
const workspaceId = (await currentWorkspacePromise).id;
|
||||||
|
subscriber.next(
|
||||||
|
collections.filter(c => c.workspaceId === workspaceId)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
fn();
|
||||||
callbackSet.add(fn);
|
callbackSet.add(fn);
|
||||||
return () => {
|
return () => {
|
||||||
callbackSet.delete(fn);
|
callbackSet.delete(fn);
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import {
|
|||||||
getBlockSuiteEditorTitle,
|
getBlockSuiteEditorTitle,
|
||||||
waitForEditorLoad,
|
waitForEditorLoad,
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
|
import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';
|
||||||
|
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
|
||||||
import type { Page } from '@playwright/test';
|
import type { Page } from '@playwright/test';
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
@@ -16,10 +18,13 @@ const createAndPinCollection = async (
|
|||||||
page: Page,
|
page: Page,
|
||||||
options?: {
|
options?: {
|
||||||
collectionName?: string;
|
collectionName?: string;
|
||||||
|
skipInitialPage?: boolean;
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
await openHomePage(page);
|
if (!options?.skipInitialPage) {
|
||||||
await waitForEditorLoad(page);
|
await openHomePage(page);
|
||||||
|
await waitForEditorLoad(page);
|
||||||
|
}
|
||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
await getBlockSuiteEditorTitle(page).click();
|
await getBlockSuiteEditorTitle(page).click();
|
||||||
await getBlockSuiteEditorTitle(page).fill('test page');
|
await getBlockSuiteEditorTitle(page).fill('test page');
|
||||||
@@ -65,6 +70,22 @@ test('Show collections items in sidebar', async ({ page }) => {
|
|||||||
await deleteCollection.click();
|
await deleteCollection.click();
|
||||||
await page.waitForTimeout(50);
|
await page.waitForTimeout(50);
|
||||||
expect(await items.count()).toBe(0);
|
expect(await items.count()).toBe(0);
|
||||||
|
await createAndPinCollection(page, {
|
||||||
|
skipInitialPage: true,
|
||||||
|
});
|
||||||
|
expect(await items.count()).toBe(1);
|
||||||
|
|
||||||
|
await clickSideBarCurrentWorkspaceBanner(page);
|
||||||
|
await createLocalWorkspace(
|
||||||
|
{
|
||||||
|
name: 'Test 1',
|
||||||
|
},
|
||||||
|
page
|
||||||
|
);
|
||||||
|
await waitForEditorLoad(page);
|
||||||
|
expect(await items.count()).toBe(0);
|
||||||
|
await clickSideBarCurrentWorkspaceBanner(page);
|
||||||
|
await page.getByTestId('workspace-card').nth(0).click();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('pin and unpin collection', async ({ page }) => {
|
test('pin and unpin collection', async ({ page }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user