Skip to content

Commit baf4b50

Browse files
committed
fix(e2e): enable SwiftShader for WebGL on Linux CI
Chrome 137+ deprecated automatic SwiftShader fallback for WebGL. Without --enable-unsafe-swiftshader, WebGL context creation silently fails on GPU-less CI runners, causing black views and test timeouts. Also simplifies bug report generation: use raw userAgent instead of parsed browser string, inline bugReport in addError, and trim the E2E test to just verify the copy button appears.
1 parent fceaccd commit baf4b50

File tree

4 files changed

+25
-73
lines changed

4 files changed

+25
-73
lines changed

src/store/messages.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,17 @@ export const useMessageStore = defineStore('message', {
5656
addError(title: string, opts?: ErrorOptions) {
5757
console.error(title, opts?.error ?? opts?.details);
5858

59-
const details =
60-
opts?.details ??
61-
(opts?.error ? (opts.error.stack ?? String(opts.error)) : undefined);
62-
63-
const id = this._addMessage(
64-
{ type: MessageType.Error, title },
65-
{ details, persist: opts?.persist ?? false }
59+
return this._addMessage(
60+
{
61+
type: MessageType.Error,
62+
title,
63+
bugReport: generateBugReport(opts?.error),
64+
},
65+
{
66+
details: opts?.details ?? opts?.error?.stack,
67+
persist: opts?.persist ?? false,
68+
}
6669
);
67-
68-
this.byID[id].bugReport = generateBugReport(opts?.error);
69-
70-
return id;
7170
},
7271
/**
7372
* Adds a warning message.

src/utils/bugReport.ts

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,8 @@ const MAX_ERROR_LENGTH = 4000;
99

1010
const COMPOUND_EXTENSIONS = ['nii.gz', 'iwi.cbor', 'seg.nrrd'];
1111

12-
const parseBrowserInfo = (): string => {
13-
if (typeof navigator === 'undefined') return 'unknown';
14-
15-
const { userAgent: ua } = navigator;
16-
17-
const patterns: [string, RegExp][] = [
18-
['Firefox', /Firefox\/([\d.]+)/],
19-
['Edge', /Edg\/([\d.]+)/],
20-
['Chrome', /Chrome\/([\d.]+)/],
21-
['Safari', /Version\/([\d.]+).*Safari/],
22-
];
23-
24-
const match = patterns
25-
.map(([name, re]) => {
26-
const m = ua.match(re);
27-
return m ? `${name} ${m[1]}` : null;
28-
})
29-
.find(Boolean);
30-
31-
const browser = match ?? 'Unknown';
32-
33-
const os = ['Windows', 'Mac', 'Linux', 'Android', 'iPhone', 'iPad'].find(
34-
(name) => ua.includes(name)
35-
);
36-
37-
const osLabel =
38-
os === 'Mac'
39-
? 'macos'
40-
: os === 'iPhone' || os === 'iPad'
41-
? 'ios'
42-
: (os?.toLowerCase() ?? 'unknown');
43-
44-
return `${browser} (${osLabel})`;
45-
};
12+
const getBrowserInfo = (): string =>
13+
typeof navigator !== 'undefined' ? navigator.userAgent : 'unknown';
4614

4715
const getSourceFormat = (name: string, isDicom: boolean): string => {
4816
if (isDicom) return 'DICOM';
@@ -91,7 +59,10 @@ const collectDatasetInfo = (): string[] => {
9159
: 'unknown';
9260

9361
const segCount = segmentGroupStore.orderByParent[id]?.length ?? 0;
94-
const segPart = segCount > 0 ? ` (segment groups: ${segCount})` : '';
62+
const segPart =
63+
segCount > 0
64+
? ` (segment groups: ${segCount} as ${segmentGroupStore.saveFormat})`
65+
: '';
9566

9667
return ` [${i}] ${dims} ${dataType} from ${sourceFormat}${segPart}`;
9768
});
@@ -104,22 +75,18 @@ export const generateBugReport = (error?: Error): string => {
10475
const lines = [
10576
'--- VolView Bug Report ---',
10677
`Build: volview ${versions.volview} (${sha}) | vtk.js: ${versions['vtk.js']}, itk-wasm: ${versions['itk-wasm']}`,
107-
`Browser: ${parseBrowserInfo()}`,
78+
`Browser: ${getBrowserInfo()}`,
10879
'',
10980
'Error:',
11081
formatError(error),
11182
];
11283

113-
try {
114-
const datasets = collectDatasetInfo();
115-
const segmentGroupStore = useSegmentGroupStore();
84+
const datasets = collectDatasetInfo();
85+
const segmentGroupStore = useSegmentGroupStore();
11686

117-
lines.push('', `Datasets: ${datasets.length}`);
118-
lines.push(...datasets);
119-
lines.push(`Save format: ${segmentGroupStore.saveFormat}`);
120-
} catch {
121-
lines.push('', 'Datasets: unavailable');
122-
}
87+
lines.push('', `Datasets: ${datasets.length}`);
88+
lines.push(...datasets);
89+
lines.push(`Save format: ${segmentGroupStore.saveFormat}`);
12390

12491
lines.push('--- End Report ---');
12592

tests/specs/bug-report.e2e.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { volViewPage } from '../pageobjects/volview.page';
22
import { writeManifestToFile } from './utils';
33

44
describe('Bug report generation', () => {
5-
it('should attach bug report to error messages', async () => {
5+
it('should show Copy Bug Report button on error', async () => {
66
// Trigger an error by loading a malformed URL
77
const manifest = { resources: [{ url: 'bad-url-to-trigger-error' }] };
88
await writeManifestToFile(manifest, 'bugReportTest.json');
@@ -22,20 +22,5 @@ describe('Bug report generation', () => {
2222
},
2323
{ timeout: 5000, timeoutMsg: 'Expected Copy Bug Report button' }
2424
);
25-
26-
// Verify bug report content via the store
27-
const report = await browser.execute(() => {
28-
// Access the Pinia store from the app instance
29-
const app = document.querySelector('#app') as any;
30-
const pinia = app?.__vue_app__?.config?.globalProperties?.$pinia;
31-
if (!pinia) return '';
32-
const store = pinia.state.value.message;
33-
if (!store) return '';
34-
const firstId = store.msgList[0];
35-
return store.byID[firstId]?.bugReport ?? '';
36-
});
37-
38-
expect(report).toContain('--- VolView Bug Report ---');
39-
expect(report).toContain('Browser:');
4025
});
4126
});

wdio.chrome.conf.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ if (process.env.CI || process.env.GITHUB_ACTIONS) {
66
chromeArgs.push(
77
'--no-sandbox',
88
'--disable-dev-shm-usage',
9-
'--disable-infobars'
9+
'--disable-infobars',
10+
'--enable-unsafe-swiftshader'
1011
);
1112
}
1213

0 commit comments

Comments
 (0)