Skip to content

Commit

Permalink
fix(web): minor bug fixes (#9696)
Browse files Browse the repository at this point in the history
Co-authored-by: Mirone <[email protected]>
  • Loading branch information
OlegDev1 and Saul-Mirone authored Jan 27, 2025
1 parent 73b4437 commit e3fac97
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 6 deletions.
5 changes: 0 additions & 5 deletions blocksuite/affine/shared/src/consts/bracket-pairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ export const BRACKET_PAIRS: BracketPair[] = [
left: '"',
right: '"',
},
{
name: 'angle bracket',
left: '<',
right: '>',
},
{
name: 'fullwidth single quote',
left: '‘',
Expand Down
2 changes: 1 addition & 1 deletion blocksuite/blocks/src/_common/transformers/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function exportDocs(collection: Workspace, docs: Store[]) {
snapshots
.filter((snapshot): snapshot is DocSnapshot => !!snapshot)
.map(async snapshot => {
const snapshotName = `${snapshot.meta.id}.snapshot.json`;
const snapshotName = `${snapshot.meta.title || 'untitled'}.snapshot.json`;
await zip.file(snapshotName, JSON.stringify(snapshot, null, 2));
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ export const EditDocPropertyMenuItems = ({
onChange={handleNameChange}
placeholder={t['unnamed']()}
onKeyDown={onKeyDown}
size="large"
style={{ borderRadius: 4 }}
/>
)}
</div>
Expand Down
14 changes: 14 additions & 0 deletions tests/affine-local/e2e/blocksuite/code/crud.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';

import { initCodeBlockByOneStep } from './utils';

test.describe('Code Block Autocomplete Operations', () => {
test('angle brackets are not supported', async ({ page }) => {
// open the home page and insert the code block
await initCodeBlockByOneStep(page);
await page.keyboard.type('<');
const codeUnit = page.locator('affine-code-unit');
await expect(codeUnit).toHaveText('<');
});
});
23 changes: 23 additions & 0 deletions tests/affine-local/e2e/blocksuite/code/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { openHomePage } from '@affine-test/kit/utils/load-page';
import {
addCodeBlock,
clickNewPageButton,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import type { Page } from '@playwright/test';

export const gotoContentFromTitle = async (page: Page) => {
await page.keyboard.press('Enter');
};

export const createNewPage = async (page: Page) => {
await clickNewPageButton(page);
};

export const initCodeBlockByOneStep = async (page: Page) => {
await openHomePage(page);
await createNewPage(page);
await waitForEditorLoad(page);
await gotoContentFromTitle(page);
await addCodeBlock(page);
};
7 changes: 7 additions & 0 deletions tests/kit/src/utils/page-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ export const addDatabase = async (page: Page, title?: string) => {
}
};

export const addCodeBlock = async (page: Page) => {
await page.keyboard.press('/');
await expect(page.locator('affine-slash-menu .slash-menu')).toBeVisible();
await page.keyboard.type('code');
await page.getByTestId('Code Block').click();
};

export const addDatabaseRow = async (page: Page, databaseTitle: string) => {
const db = page.locator(`affine-database-table`, {
has: page.locator(`affine-database-title:has-text("${databaseTitle}")`),
Expand Down

0 comments on commit e3fac97

Please sign in to comment.