Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): too many digits after decimal point in table calculations #9471

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions blocksuite/affine/data-view/src/core/statistics/number.ts
Original file line number Diff line number Diff line change
@@ -30,7 +30,9 @@ export const numberStatsFunctions: StatisticsConfig[] = [
if (numbers.length === 0) {
return 'None';
}
return (numbers.reduce((a, b) => a + b, 0) / numbers.length).toString();
return parseFloat(
(numbers.reduce((a, b) => a + b, 0) / numbers.length).toFixed(2)
).toString();
},
}),
createStatisticConfig({
@@ -49,7 +51,7 @@ export const numberStatsFunctions: StatisticsConfig[] = [
const a = arr[index];
const b = arr[index - 1];
if (a == null || b == null) return 'None';
result = (a + b) / 2;
result = parseFloat(((a + b) / 2).toFixed(2));
}
return result?.toString() ?? 'None';
},
@@ -120,7 +122,7 @@ export const numberStatsFunctions: StatisticsConfig[] = [
if (min == null || max == null) {
return 'None';
}
return (max - min).toString();
return parseFloat((max - min).toFixed(2)).toString();
},
}),
];

Unchanged files with check annotations Beta

const menu = await openExplorerNodeMenu(page, tag);
await menu.getByTestId('rename-tag').tap();
const focusedTestid = await getAttrOfActiveElement(page);
expect(focusedTestid).toEqual('rename-input');

Check failure on line 67 in tests/affine-mobile/e2e/explorer-tag.spec.ts

GitHub Actions / E2E Mobile Test (2)

[Mobile Safari] › explorer-tag.spec.ts:59:5 › rename a tag from explorer

1) [Mobile Safari] › explorer-tag.spec.ts:59:5 › rename a tag from explorer ────────────────────── Error: expect(received).toEqual(expected) // deep equality Expected: "rename-input" Received: null 65 | await menu.getByTestId('rename-tag').tap(); 66 | const focusedTestid = await getAttrOfActiveElement(page); > 67 | expect(focusedTestid).toEqual('rename-input'); | ^ 68 | await page.keyboard.type(appendedName); 69 | await menu.getByTestId('rename-confirm').tap(); 70 | await expect(tag).not.toBeVisible(); at /home/runner/work/AFFiNE/AFFiNE/tests/affine-mobile/e2e/explorer-tag.spec.ts:67:25
await page.keyboard.type(appendedName);
await menu.getByTestId('rename-confirm').tap();
await expect(tag).not.toBeVisible();
await page.keyboard.press('@');
const doc1 = page.locator('.linked-doc-popover').getByText('PDF page');

Check failure on line 212 in tests/affine-local/e2e/attachment-preview.spec.ts

GitHub Actions / E2E Test (1)

attachment-preview.spec.ts:145:5 › should preview PDF in embed view

1) attachment-preview.spec.ts:145:5 › should preview PDF in embed view ─────────────────────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for locator('.linked-doc-popover').getByText('PDF preview') 210 | 211 | const doc0 = page.locator('.linked-doc-popover').getByText('PDF preview'); > 212 | await doc0.click(); | ^ 213 | 214 | await page.keyboard.press('@'); 215 | at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/attachment-preview.spec.ts:212:16
await doc1.click();
const inlineLink = page.locator('affine-reference').nth(0);

Check failure on line 286 in tests/affine-local/e2e/links.spec.ts

GitHub Actions / E2E Test (3)

links.spec.ts:249:5 › allow switching to embed view when linking to the other document with mode

1) links.spec.ts:249:5 › allow switching to embed view when linking to the other document with mode TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for locator('affine-embed-linked-doc-block') - locator resolved to <affine-embed-linked-doc-block contenteditable="false" data-block-id="MQ_f2bMzMdFDQZEBjmrMb">…</affine-embed-linked-doc-block> - attempting click action 2 × waiting for element to be visible, enabled and stable - element is visible, enabled and stable - scrolling into view if needed - done scrolling - <iframe src="about:blank" id="webpack-dev-server-client-overlay"></iframe> intercepts pointer events - retrying click action - waiting 20ms 2 × waiting for element to be visible, enabled and stable - element is visible, enabled and stable - scrolling into view if needed - done scrolling - <iframe src="about:blank" id="webpack-dev-server-client-overlay"></iframe> intercepts pointer events - retrying click action - waiting 100ms 9 × waiting for element to be visible, enabled and stable - element is visible, enabled and stable - scrolling into view if needed - done scrolling - <iframe src="about:blank" id="webpack-dev-server-client-overlay"></iframe> intercepts pointer events - retrying click action - waiting 500ms 284 | 285 | await expect(cardLink).toBeVisible(); > 286 | await cardLink.click(); | ^ 287 | 288 | // refocus 289 | await cardLink.click(); at /home/runner/work/AFFiNE/AFFiNE/tests/affine-local/e2e/links.spec.ts:286:18
export function assertPointAlmostEqual(
actual: number[],
expected: number[],
precision = 0.001

Check failure on line 773 in blocksuite/tests-legacy/utils/asserts.ts

GitHub Actions / Legacy Blocksuite E2E Test (5)

edgeless/note/resize.spec.ts:138:1 › resize note then auto size and custom size

1) edgeless/note/resize.spec.ts:138:1 › resize note then auto size and custom size ─────────────── Error: expect(received).toBeCloseTo(expected, precision) Expected: 192 Received: 92 Expected precision: 0 Expected difference: < 0.5 Received difference: 100 at utils/asserts.ts:773 771 | expect(a.y).toBeCloseTo(b.y, 0); 772 | expect(a.w).toBeCloseTo(b.w, 0); > 773 | expect(a.h).toBeCloseTo(b.h, 0); | ^ 774 | } 775 | 776 | export function assertDOMRectEqual(a: DOMRect, b: DOMRect) { at assertRectEqual (/home/runner/work/AFFiNE/AFFiNE/blocksuite/tests-legacy/utils/asserts.ts:773:15) at assertNoteRectEqual (/home/runner/work/AFFiNE/AFFiNE/blocksuite/tests-legacy/utils/asserts.ts:766:3) at /home/runner/work/AFFiNE/AFFiNE/blocksuite/tests-legacy/edgeless/note/resize.spec.ts:188:3
) {
assertAlmostEqual(actual[0], expected[0], precision);
assertAlmostEqual(actual[1], expected[1], precision);
const squareShapeButton = page
.locator('edgeless-slide-menu edgeless-tool-icon-button')
.filter({ hasText: shape });
await squareShapeButton.click();

Check failure on line 368 in blocksuite/tests-legacy/utils/actions/edgeless.ts

GitHub Actions / Legacy Blocksuite E2E Test (6)

edgeless/shortcut.spec.ts:119:1 › should not switch shapes in editing

1) edgeless/shortcut.spec.ts:119:1 › should not switch shapes in editing ───────────────────────── TimeoutError: locator.click: Timeout 5000ms exceeded. Call log: - waiting for locator('edgeless-slide-menu edgeless-tool-icon-button').filter({ hasText: 'Square' }) - locator resolved to <edgeless-tool-icon-button role="button">…</edgeless-tool-icon-button> - attempting click action 2 × waiting for element to be visible, enabled and stable - element is not stable - retrying click action - waiting 20ms - waiting for element to be visible, enabled and stable - element is not stable - retrying click action - waiting 100ms - waiting for element to be visible, enabled and stable - element was detached from the DOM, retrying at utils/actions/edgeless.ts:368 366 | .locator('edgeless-slide-menu edgeless-tool-icon-button') 367 | .filter({ hasText: shape }); > 368 | await squareShapeButton.click(); | ^ 369 | break; 370 | } 371 | } at setEdgelessTool (/home/runner/work/AFFiNE/AFFiNE/blocksuite/tests-legacy/utils/actions/edgeless.ts:368:31) at /home/runner/work/AFFiNE/AFFiNE/blocksuite/tests-legacy/edgeless/shortcut.spec.ts:137:3
break;
}
}
await type(page, '/');
await expect(slashMenu).toBeVisible();
await pressEscape(page);

Check failure on line 388 in blocksuite/tests-legacy/slash-menu.spec.ts

GitHub Actions / Legacy Blocksuite E2E Test (10)

slash-menu.spec.ts:365:3 › slash menu should show and hide correctly › should open and close menu when using left right arrow

1) slash-menu.spec.ts:365:3 › slash menu should show and hide correctly › should open and close menu when using left right arrow, Enter, Esc keys Error: Timed out 5000ms waiting for expect(locator).toHaveAttribute(expected) Locator: locator('.slash-menu[data-testid=sub-menu-0]').locator('icon-button').nth(4) Expected string: "true" Received string: "false" Call log: - expect.toHaveAttribute with timeout 5000ms - waiting for locator('.slash-menu[data-testid=sub-menu-0]').locator('icon-button').nth(4) 9 × locator resolved to <icon-button width="100%" tabindex="0" height="44px" hover="false" role="button" text="Other Headings" data-test-disabled="false" data-testid="Other Headings" class="slash-menu-item other-headings">…</icon-button> - unexpected value "false" 386 | await type(page, '/'); 387 | await pressArrowDown(page, 4); > 388 | await expect(slashItems.nth(4)).toHaveAttribute('hover', 'true'); | ^ 389 | await expect(slashItems.nth(4).locator('.text')).toHaveText([ 390 | 'Other Headings', 391 | ]); at /home/runner/work/AFFiNE/AFFiNE/blocksuite/tests-legacy/slash-menu.spec.ts:388:37
await expect(slashMenu).toBeHidden();
await type(page, '/');