fix: export then add test case (#7024)
This commit is contained in:
@@ -89,6 +89,7 @@ export const Modal = forwardRef<HTMLDivElement, ModalProps>(
|
|||||||
className={styles.closeButton}
|
className={styles.closeButton}
|
||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
type="plain"
|
type="plain"
|
||||||
|
data-testid="modal-close-button"
|
||||||
{...closeButtonOptions}
|
{...closeButtonOptions}
|
||||||
>
|
>
|
||||||
<CloseIcon />
|
<CloseIcon />
|
||||||
|
|||||||
@@ -92,8 +92,10 @@ export async function saveDBFileAs(
|
|||||||
): Promise<SaveDBFileResult> {
|
): Promise<SaveDBFileResult> {
|
||||||
try {
|
try {
|
||||||
const db = await ensureSQLiteDB(workspaceId);
|
const db = await ensureSQLiteDB(workspaceId);
|
||||||
|
const fakedResult = getFakedResult();
|
||||||
|
|
||||||
const ret =
|
const ret =
|
||||||
getFakedResult() ??
|
fakedResult ??
|
||||||
(await mainRPC.showSaveDialog({
|
(await mainRPC.showSaveDialog({
|
||||||
properties: ['showOverwriteConfirmation'],
|
properties: ['showOverwriteConfirmation'],
|
||||||
title: 'Save Workspace',
|
title: 'Save Workspace',
|
||||||
@@ -120,9 +122,11 @@ export async function saveDBFileAs(
|
|||||||
|
|
||||||
await fs.copyFile(db.path, filePath);
|
await fs.copyFile(db.path, filePath);
|
||||||
logger.log('saved', filePath);
|
logger.log('saved', filePath);
|
||||||
|
if (!fakedResult) {
|
||||||
mainRPC.showItemInFolder(filePath).catch(err => {
|
mainRPC.showItemInFolder(filePath).catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return { filePath };
|
return { filePath };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('saveDBFileAs', err);
|
logger.error('saveDBFileAs', err);
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ const historyShortcut = async (page: Page, command: 'goBack' | 'goForward') => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test('new page', async ({ page, workspace }) => {
|
test('new page', async ({ page, workspace }) => {
|
||||||
await page.getByTestId('sidebar-new-page-button').click({
|
await page.getByTestId('sidebar-new-page-button').click();
|
||||||
delay: 100,
|
|
||||||
});
|
|
||||||
await page.waitForSelector('v-line');
|
await page.waitForSelector('v-line');
|
||||||
const flavour = (await workspace.current()).meta.flavour;
|
const flavour = (await workspace.current()).meta.flavour;
|
||||||
expect(flavour).toBe('local');
|
expect(flavour).toBe('local');
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import path from 'node:path';
|
|||||||
|
|
||||||
import type { apis } from '@affine/electron-api';
|
import type { apis } from '@affine/electron-api';
|
||||||
import { test } from '@affine-test/kit/electron';
|
import { test } from '@affine-test/kit/electron';
|
||||||
import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';
|
import { getBlockSuiteEditorTitle } from '@affine-test/kit/utils/page-logic';
|
||||||
|
import {
|
||||||
|
clickNewPageButton,
|
||||||
|
clickSideBarCurrentWorkspaceBanner,
|
||||||
|
} from '@affine-test/kit/utils/sidebar';
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
|
|
||||||
@@ -24,38 +28,11 @@ test('check workspace has a DB file', async ({ appInfo, workspace }) => {
|
|||||||
expect(await fs.exists(dbPath)).toBe(true);
|
expect(await fs.exists(dbPath)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('move workspace db file', async ({ page, appInfo, workspace }) => {
|
test('export then add', async ({ page, appInfo, workspace }) => {
|
||||||
const w = await workspace.current();
|
await clickNewPageButton(page);
|
||||||
await page.getByTestId('slider-bar-workspace-setting-button').click();
|
|
||||||
await expect(page.getByTestId('setting-modal')).toBeVisible();
|
|
||||||
|
|
||||||
// goto workspace setting
|
|
||||||
await page.getByTestId('workspace-list-item').click();
|
|
||||||
|
|
||||||
const tmpPath = path.join(appInfo.sessionData, w.meta.id + '-tmp-dir');
|
|
||||||
|
|
||||||
// move db file to tmp folder
|
|
||||||
await page.evaluate(tmpPath => {
|
|
||||||
window.apis?.dialog.setFakeDialogResult({
|
|
||||||
filePath: tmpPath,
|
|
||||||
});
|
|
||||||
}, tmpPath);
|
|
||||||
|
|
||||||
await page.getByTestId('move-folder').click();
|
|
||||||
// check if db file exists
|
|
||||||
await page.waitForSelector('text="Move folder success"');
|
|
||||||
expect(await fs.exists(tmpPath)).toBe(true);
|
|
||||||
// check if db file exists under tmpPath (a file ends with .affine)
|
|
||||||
const files = await fs.readdir(tmpPath);
|
|
||||||
expect(files.some(f => f.endsWith('.affine'))).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
//TODO:fix test
|
|
||||||
test.fixme('export then add', async ({ page, appInfo, workspace }) => {
|
|
||||||
const w = await workspace.current();
|
const w = await workspace.current();
|
||||||
|
|
||||||
await page.focus('.affine-doc-page-block-title');
|
await getBlockSuiteEditorTitle(page).fill('test1');
|
||||||
await page.fill('.affine-doc-page-block-title', 'test1');
|
|
||||||
|
|
||||||
await page.getByTestId('slider-bar-workspace-setting-button').click();
|
await page.getByTestId('slider-bar-workspace-setting-button').click();
|
||||||
await expect(page.getByTestId('setting-modal')).toBeVisible();
|
await expect(page.getByTestId('setting-modal')).toBeVisible();
|
||||||
@@ -78,7 +55,7 @@ test.fixme('export then add', async ({ page, appInfo, workspace }) => {
|
|||||||
|
|
||||||
// export db file to tmp folder
|
// export db file to tmp folder
|
||||||
await page.evaluate(tmpPath => {
|
await page.evaluate(tmpPath => {
|
||||||
window.apis?.dialog.setFakeDialogResult({
|
return window.apis?.dialog.setFakeDialogResult({
|
||||||
filePath: tmpPath,
|
filePath: tmpPath,
|
||||||
});
|
});
|
||||||
}, tmpPath);
|
}, tmpPath);
|
||||||
@@ -94,10 +71,9 @@ test.fixme('export then add', async ({ page, appInfo, workspace }) => {
|
|||||||
// we are reusing the same db file so that we don't need to maintain one
|
// we are reusing the same db file so that we don't need to maintain one
|
||||||
// in the codebase
|
// in the codebase
|
||||||
await clickSideBarCurrentWorkspaceBanner(page);
|
await clickSideBarCurrentWorkspaceBanner(page);
|
||||||
await page.getByTestId('add-or-new-workspace').click();
|
|
||||||
|
|
||||||
await page.evaluate(tmpPath => {
|
await page.evaluate(tmpPath => {
|
||||||
window.apis?.dialog.setFakeDialogResult({
|
return window.apis?.dialog.setFakeDialogResult({
|
||||||
filePath: tmpPath,
|
filePath: tmpPath,
|
||||||
});
|
});
|
||||||
}, tmpPath);
|
}, tmpPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user