From 6d81c81ab2e6872402c2c7aae41d5f203b99cb4d Mon Sep 17 00:00:00 2001
From: syuilo <4439005+syuilo@users.noreply.github.com>
Date: Thu, 23 Jul 2026 21:46:19 +0900
Subject: [PATCH] chore(gh): fix tests
---
.../diagnostics-backend/test/render-md.test.ts | 14 ++++----------
.../diagnostics-frontend/test/report.test.ts | 8 ++++----
.../diagnostics-shared/test/format.test.ts | 18 +++++++++---------
.../test/heap-snapshot-render.test.ts | 6 +++---
.../test/metric-table.test.ts | 18 +++++++++---------
5 files changed, 29 insertions(+), 35 deletions(-)
diff --git a/packages-private/diagnostics-backend/test/render-md.test.ts b/packages-private/diagnostics-backend/test/render-md.test.ts
index fb1226bda3..8b8305be60 100644
--- a/packages-private/diagnostics-backend/test/render-md.test.ts
+++ b/packages-private/diagnostics-backend/test/render-md.test.ts
@@ -64,7 +64,7 @@ test('throws when filtering leaves fewer than two heap snapshots per side', asyn
})).toThrow('At least two samples per side are required');
});
-test('reports the difference of medians and leaves a paired-looking PSS delta uncoloured', async () => {
+test('omits a paired-looking PSS delta that stays within observed noise', async () => {
const base = replacePssSamples(await loadFixture('base'), [290_000, 292_900, 295_800, 298_700, 301_600]);
const head = replacePssSamples(await loadFixture('head'), [292_900, 296_300, 298_700, 301_600, 290_000]);
@@ -78,16 +78,10 @@ test('reports the difference of medians and leaves a paired-looking PSS delta un
baseHeapSnapshotUrl: 'https://example.invalid/base',
headHeapSnapshotUrl: 'https://example.invalid/head',
});
- const row = findMetricRow(markdown, 'PSS');
- expect(row).toContain('295.8 MB
± 2.9 MB');
- expect(row).toContain('296.3 MB
± 3.4 MB');
- expect(row).toContain('$\\text{+0.5 MB}$');
- expect(row).toContain('4.5 MB');
- expect(row.split('|')).toHaveLength(7);
- expect(row).not.toMatch(/within noise|increase|decrease|inconclusive/);
- expect(row).not.toContain('\\color{orange}');
- expect(findMetricRow(markdown, 'USS')).not.toContain('\\color{orange}');
+ expect(markdown).not.toContain('| **PSS** |');
+ expect(markdown).toContain('Only metrics showing significant changes are displayed.');
+ expect(markdown).not.toContain('⚠️ **Warning**: Memory usage (PSS)');
});
test('keeps the convergence warning without suppressing table colour or the PSS warning', async () => {
diff --git a/packages-private/diagnostics-frontend/test/report.test.ts b/packages-private/diagnostics-frontend/test/report.test.ts
index 200ba8ed1e..8b8fb459cd 100644
--- a/packages-private/diagnostics-frontend/test/report.test.ts
+++ b/packages-private/diagnostics-frontend/test/report.test.ts
@@ -251,7 +251,7 @@ test('renders a directional encoded byte delta at the absolute threshold', async
const row = requireMetricRow(await renderReport(null, { base, head }), 'Encoded network');
- expect(row).toContain('$\\color{orange}{\\text{+10 KB}}$');
+ expect(row).toContain('$\\color{orange}{\\text{+10 KB}}$');
});
test('colours absolute and relative deltas together when the row is significant', async () => {
@@ -268,9 +268,9 @@ test('colours absolute and relative deltas together when the row is significant'
const row = requireMetricRow(await renderReport(null, { base, head }), 'Encoded network');
- expect(row).toContain('100 MB
± 0 B');
- expect(row).toContain('$\\color{orange}{\\text{+20 KB}}$
$\\color{orange}{\\text{+0\\\\%}}$');
- expect(row).toContain('| 0 B |');
+ expect(row).toContain('100 MB
± 0 B');
+ expect(row).toContain('$\\color{orange}{\\text{+20 KB}}$
$\\color{orange}{\\text{+0\\\\%}}$');
+ expect(row).toContain('| 0 B |');
expect(row.split('|')).toHaveLength(7);
});
diff --git a/packages-private/diagnostics-shared/test/format.test.ts b/packages-private/diagnostics-shared/test/format.test.ts
index e391d86283..51cb5940f1 100644
--- a/packages-private/diagnostics-shared/test/format.test.ts
+++ b/packages-private/diagnostics-shared/test/format.test.ts
@@ -20,15 +20,15 @@ import {
describe('formatBytes', () => {
// 1024ではなく1000区切り。単位が2桁以上なら小数を落とす
test.each([
- [0, '0 B'],
- [999, '999 B'],
- [1_000, '1 KB'],
- [1_500, '1.5 KB'],
- [15_000, '15 KB'],
- [1_234_567, '1.2 MB'],
- [12_345_678, '12 MB'],
- [1_500_000_000, '1.5 GB'],
- [1_500_000_000_000, '1,500 GB'],
+ [0, '0 B'],
+ [999, '999 B'],
+ [1_000, '1 KB'],
+ [1_500, '1.5 KB'],
+ [15_000, '15 KB'],
+ [1_234_567, '1.2 MB'],
+ [12_345_678, '12 MB'],
+ [1_500_000_000, '1.5 GB'],
+ [1_500_000_000_000, '1,500 GB'],
])('formats %i as %s', (input, expected) => {
expect(formatBytes(input)).toBe(expected);
});
diff --git a/packages-private/diagnostics-shared/test/heap-snapshot-render.test.ts b/packages-private/diagnostics-shared/test/heap-snapshot-render.test.ts
index b02b72a1c4..9fd9bdad14 100644
--- a/packages-private/diagnostics-shared/test/heap-snapshot-render.test.ts
+++ b/packages-private/diagnostics-shared/test/heap-snapshot-render.test.ts
@@ -45,7 +45,7 @@ describe('renderHeapSnapshotTable', () => {
report([1_100_000, 1_200_000, 1_300_000]),
));
- expect(row).toContain('$\\text{+100 KB}$');
+ expect(row).toContain('$\\text{+100 KB}$');
expect(row).not.toContain('within noise');
expect(row).not.toContain('\\color{orange}');
});
@@ -56,7 +56,7 @@ describe('renderHeapSnapshotTable', () => {
report([1_200_000, 1_200_000, 1_200_000]),
));
- expect(row).toContain('$\\color{orange}{\\text{+200 KB}}$');
+ expect(row).toContain('$\\color{orange}{\\text{+200 KB}}$');
expect(row).toContain('$\\color{orange}{\\text{+20\\\\%}}$');
expect(row).not.toContain('increase');
});
@@ -67,7 +67,7 @@ describe('renderHeapSnapshotTable', () => {
report([1_050_000, 1_050_000, 1_050_000]),
));
- expect(row).toContain('$\\text{+50 KB}$
$\\text{+5\\\\%}$');
+ expect(row).toContain('$\\text{+50 KB}$
$\\text{+5\\\\%}$');
expect(row.split('|')[4]).not.toContain('\\color{');
});
diff --git a/packages-private/diagnostics-shared/test/metric-table.test.ts b/packages-private/diagnostics-shared/test/metric-table.test.ts
index 127a02f8b5..c414d5111f 100644
--- a/packages-private/diagnostics-shared/test/metric-table.test.ts
+++ b/packages-private/diagnostics-shared/test/metric-table.test.ts
@@ -33,7 +33,7 @@ describe('renderMetricComparisonTable', () => {
expect(table.split('\n')).toStrictEqual([
'| Metric | @ Base | @ Head | Δ | MAD |',
'| --- | ---: | ---: | ---: | ---: |',
- '| Metric | 100 units
± 0 units | 120 units
± 0 units | $\\color{orange}{\\text{+20 units}}$
$\\color{orange}{\\text{+20\\\\%}}$ | 0 units |',
+ '| Metric | 100 units
± 0 units | 120 units
± 0 units | $\\color{orange}{\\text{+20~units}}$
$\\color{orange}{\\text{+20\\\\%}}$ | 0 units |',
]);
});
@@ -52,7 +52,7 @@ describe('renderMetricComparisonTable', () => {
expect(table.split('\n')).toStrictEqual([
'| Metric | @ Base | @ Head | Δ | MAD |',
'| --- | ---: | ---: | ---: | ---: |',
- '| Metric | 100 units | 120 units | $\\color{orange}{\\text{+20 units}}$ | 0 units |',
+ '| Metric | 100 units | 120 units | $\\color{orange}{\\text{+20~units}}$ | 0 units |',
'| | | | | |',
]);
});
@@ -62,7 +62,7 @@ describe('renderMetricComparisonTable', () => {
const head = samples(109, 109, 109);
const table = renderMetricComparisonTable(base, head, [defaultRow]);
- expect(table).toContain('$\\text{+9 units}$
$\\text{+9\\\\%}$');
+ expect(table).toContain('$\\text{+9~units}$
$\\text{+9\\\\%}$');
expect(table).not.toContain('\\color{');
expect(renderMetricComparisonTable(base, head, [defaultRow], {
onlySignificantChanges: true,
@@ -85,7 +85,7 @@ describe('renderMetricComparisonTable', () => {
{ onlySignificantChanges: true },
);
- expect(table).toContain('$\\color{orange}{\\text{+10 units}}$');
+ expect(table).toContain('$\\color{orange}{\\text{+10~units}}$');
expect(table).toContain('$\\color{orange}{\\text{+10\\\\%}}$');
});
@@ -106,11 +106,11 @@ describe('renderMetricComparisonTable', () => {
[defaultRow],
);
- expect(inside).toContain('$\\text{+9 units}$');
+ expect(inside).toContain('$\\text{+9~units}$');
expect(inside).not.toContain('\\color{');
- expect(boundary).toContain('$\\text{+30 units}$');
+ expect(boundary).toContain('$\\text{+30~units}$');
expect(boundary).not.toContain('\\color{');
- expect(outside).toContain('$\\color{orange}{\\text{+31 units}}$');
+ expect(outside).toContain('$\\color{orange}{\\text{+31~units}}$');
expect(outside).toContain('$\\color{orange}{\\text{+31\\\\%}}$');
});
@@ -121,7 +121,7 @@ describe('renderMetricComparisonTable', () => {
[defaultRow],
);
- expect(table).toContain('$\\color{green}{\\text{-20 units}}$');
+ expect(table).toContain('$\\color{green}{\\text{-20~units}}$');
expect(table).toContain('$\\color{green}{\\text{-16.7\\\\%}}$');
});
@@ -132,7 +132,7 @@ describe('renderMetricComparisonTable', () => {
[defaultRow],
);
- expect(table).toContain('$\\color{orange}{\\text{+20 units}}$
-');
+ expect(table).toContain('$\\color{orange}{\\text{+20~units}}$
-');
});
test('propagates the minimum sample contract', () => {