feat(app): artifact viewer shows CSV and TSV files as tables

This commit is contained in:
2026-10-23 15:02:17 +01:00
parent 89675dcfa8
commit 5ac8fcc6ef
14 changed files with 411 additions and 91 deletions
+16 -16
View File
@@ -44,7 +44,7 @@ JsonMap _file(
};
/// The recorded steps for one probe state. `default` carries two visits that
/// both record `result.csv` plus a partial capture on the second visit.
/// both record `result.zip` plus a partial capture on the second visit.
List<JsonMap> _steps(String origin, String state) {
if (state == 'unavailable') {
return <JsonMap>[
@@ -76,9 +76,9 @@ List<JsonMap> _steps(String origin, String state) {
'control': <String, dynamic>{'visit': 1},
'artifacts': [
_file(
'result.csv',
url: state == 'unsafe' ? '//evil.test/result.csv' : '',
contentType: 'text/csv',
'result.zip',
url: state == 'unsafe' ? '//evil.test/result.zip' : '',
contentType: 'application/zip',
sizeBytes: 2048,
),
],
@@ -130,9 +130,9 @@ List<JsonMap> _steps(String origin, String state) {
'control': <String, dynamic>{'visit': 1},
'artifacts': [
_file(
'report.csv',
url: '$origin/fixture/report.csv',
contentType: 'text/csv',
'report.zip',
url: '$origin/fixture/report.zip',
contentType: 'application/zip',
sizeBytes: 23,
),
_file(
@@ -188,9 +188,9 @@ List<JsonMap> _steps(String origin, String state) {
'control': <String, dynamic>{'visit': 1},
'artifacts': [
_file(
'report.csv',
url: '$origin/fixture/report.csv',
contentType: 'text/csv',
'report.zip',
url: '$origin/fixture/report.zip',
contentType: 'application/zip',
sizeBytes: 23,
),
],
@@ -225,9 +225,9 @@ List<JsonMap> _steps(String origin, String state) {
'control': <String, dynamic>{'visit': 1},
'artifacts': [
_file(
'result.csv',
url: '$origin/fixture/result.csv',
contentType: 'text/csv',
'result.zip',
url: '$origin/fixture/result.zip',
contentType: 'application/zip',
sizeBytes: 2048,
),
_file(
@@ -251,9 +251,9 @@ List<JsonMap> _steps(String origin, String state) {
'control': <String, dynamic>{'visit': 2},
'artifacts': [
_file(
'result.csv',
url: '$origin/fixture/result-2.csv',
contentType: 'text/csv',
'result.zip',
url: '$origin/fixture/result-2.zip',
contentType: 'application/zip',
sizeBytes: 4096,
),
],
+22 -22
View File
@@ -118,9 +118,9 @@ const server = createServer(async (req, res) => {
res.end('missing artifact\n');
return;
}
if (pathname.endsWith('/report.csv')) {
if (pathname.endsWith('/report.zip')) {
res.writeHead(200, {
'content-type': 'text/csv',
'content-type': 'application/zip',
'content-length': probeCsv.length,
});
res.end(probeCsv);
@@ -460,7 +460,7 @@ try {
await clickExact('Artifacts');
const galleryBody = await bodyText();
for (const recorded of ['build.log', 'shot.png', 'text/csv', 'implementer · visit 1', 'reviewer · visit 2']) {
for (const recorded of ['build.log', 'shot.png', 'application/zip', 'implementer · visit 1', 'reviewer · visit 2']) {
if (!galleryBody.includes(recorded)) {
throw new Error(`Gallery is missing recorded row ${recorded}: ${JSON.stringify(galleryBody)}`);
}
@@ -468,16 +468,16 @@ try {
if (!galleryBody.includes('Artifacts · 6 recorded')) {
throw new Error(`Gallery summary missing: ${JSON.stringify(galleryBody)}`);
}
const resultRows = (await labels()).filter((label) => label.startsWith('result.csv')).length;
const resultRows = (await labels()).filter((label) => label.startsWith('result.zip')).length;
if (resultRows < 2) {
throw new Error(`Duplicate result.csv rows missing: ${JSON.stringify(await labels())}`);
throw new Error(`Duplicate result.zip rows missing: ${JSON.stringify(await labels())}`);
}
evidence.checks.push({ check: 'the gallery lists the actual recorded rows, not nav labels', value: true });
await capture('a1w-material-gallery');
await clickLowestPrefix('result.csv');
await clickLowestPrefix('result.zip');
const selectedBody = await bodyText();
for (const fact of ['reviewer · visit 2', 'text/csv · 4.0\u00a0KiB', 'Artifacts · 1 recorded · partial capture', '2 files excluded from artifact capture.']) {
for (const fact of ['reviewer · visit 2', 'application/zip · 4.0\u00a0KiB', 'Artifacts · 1 recorded · partial capture', '2 files excluded from artifact capture.']) {
if (!selectedBody.includes(fact)) {
throw new Error(`Selected visit-2 facts missing ${fact}: ${JSON.stringify(selectedBody)}`);
}
@@ -504,7 +504,7 @@ try {
await navigate(`${origin}/?origin=${encodeURIComponent(origin)}&state=unsafe`);
await clickExact('Artifacts');
await clickLowestPrefix('result.csv');
await clickLowestPrefix('result.zip');
const unsafeBody = await bodyText();
if (!unsafeBody.includes('The recorded artifact URL cannot be opened safely.')) {
throw new Error(`Unsafe url wording missing: ${JSON.stringify(unsafeBody)}`);
@@ -517,7 +517,7 @@ try {
await navigate(`${origin}/?origin=${encodeURIComponent(origin)}&state=nourl`);
await clickExact('Artifacts');
await clickLowestPrefix('result.csv');
await clickLowestPrefix('result.zip');
const nourlBody = await bodyText();
if (!nourlBody.includes('No artifact URL recorded.')) {
throw new Error(`No-url wording missing: ${JSON.stringify(nourlBody)}`);
@@ -678,7 +678,7 @@ try {
}
evidence.checks.push({ check: 'Cupertino lists the same recorded rows', value: true });
await capture('a1w-cupertino-gallery');
await clickLowestPrefix('result.csv');
await clickLowestPrefix('result.zip');
if (!(await hasLabel('Open')) || !(await hasLabel('Copy link'))) {
throw new Error(`Cupertino selection offers no actions: ${JSON.stringify(await labels())}`);
}
@@ -692,10 +692,10 @@ try {
// Cupertino dark: the gallery and its dialog on the dark host.
await openGallery(`platform=cupertino&theme=dark&origin=${encodeURIComponent(origin)}`);
await capture('a1w-cupertino-dark-gallery');
await clickLowestPrefix('result.csv');
await clickLowestPrefix('result.zip');
const darkLabels = await labels();
const darkTitle = darkLabels.find((label) => label.startsWith('result.csv'));
const titleRect = await rectOfPrefix('result.csv');
const darkTitle = darkLabels.find((label) => label.startsWith('result.zip'));
const titleRect = await rectOfPrefix('result.zip');
const darkText = [await bodyText(), ...darkLabels].join('\n');
if (!darkText.includes('Artifacts · 1 recorded · partial capture')) {
throw new Error(`Dark Cupertino dialog did not render: ${JSON.stringify(darkText)}`);
@@ -723,7 +723,7 @@ try {
}
}
await capture(`${prefix}-gallery`, 320, 720, 1);
await clickLowestPrefix('result.csv');
await clickLowestPrefix('result.zip');
const facts = await bodyText();
if (!facts.includes('Artifacts · 3 recorded') &&
!facts.includes('Artifacts · 1 recorded · partial capture')) {
@@ -863,7 +863,7 @@ try {
}, session);
const before = await targetCount();
await navigate(galleryView(`&state=files${extra}`, platform), 'Artifacts');
await clickExact('report.csv');
await clickExact('report.zip');
await delay(500);
if (!(await hasLabel('Download')) || !(await hasLabel('Share'))) {
throw new Error(`${platform} selection lost its file actions: ${JSON.stringify(await labels())}`);
@@ -887,23 +887,23 @@ try {
if (downloaded.downloads.length !== 1) {
throw new Error(`${platform} did not request exactly one download: ${JSON.stringify(downloaded)}`);
}
if (download.name !== 'report.csv') {
if (download.name !== 'report.zip') {
throw new Error(`${platform} download name was ${JSON.stringify(download.name)}`);
}
if (!download.href.startsWith('blob:')) {
throw new Error(`${platform} download used a non-blob href: ${JSON.stringify(download.href)}`);
}
if (object.type !== 'text/csv' || object.size !== probeCsv.length) {
throw new Error(`${platform} blob was ${object.type}/${object.size}, expected text/csv/${probeCsv.length}`);
if (object.type !== 'application/zip' || object.size !== probeCsv.length) {
throw new Error(`${platform} blob was ${object.type}/${object.size}, expected application/zip/${probeCsv.length}`);
}
if (!sameBytes(object.bytes, Array.from(probeCsv))) {
throw new Error(`${platform} download bytes differed from the served artifact`);
}
if (!(await bodyText()).includes('Downloaded report.csv.')) {
if (!(await bodyText()).includes('Downloaded report.zip.')) {
throw new Error(`${platform} download did not report its file: ${JSON.stringify(await bodyText())}`);
}
evidence.checks.push({
check: `${platform} Download hands the host report.csv, text/csv, ${probeCsv.length} exact bytes`,
check: `${platform} Download hands the host report.zip, application/zip, ${probeCsv.length} exact bytes`,
value: true,
name: download.name,
mime: object.type,
@@ -928,7 +928,7 @@ try {
if (shared.shares.length !== 1 || shared.shares[0].length !== 1) {
throw new Error(`${platform} share received ${JSON.stringify(shared.shares)}`);
}
if (file.name !== 'report.csv' || file.type !== 'text/csv' || file.size !== probeCsv.length) {
if (file.name !== 'report.zip' || file.type !== 'application/zip' || file.size !== probeCsv.length) {
throw new Error(`${platform} shared file was ${JSON.stringify(file)}`);
}
if (!sameBytes(file.bytes, Array.from(probeCsv))) {
@@ -941,7 +941,7 @@ try {
throw new Error(`${platform} file actions opened a browser tab`);
}
evidence.checks.push({
check: `${platform} Share hands the host a report.csv, text/csv, ${probeCsv.length} byte file`,
check: `${platform} Share hands the host a report.zip, application/zip, ${probeCsv.length} byte file`,
value: true,
name: file.name,
mime: file.type,