Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
45b3f01
refactor(wsi): isolate molecular context child
raylim Sep 24, 2026
c750e4a
test(wsi): authenticate foundation route from frontend origin
raylim Sep 24, 2026
ddedc41
Merge commit 'a438de0bd20206444bacb4916aa174408635ada2' into codex/ws…
raylim Sep 24, 2026
3255253
Merge commit '37ca82415004c399fe494e0b4b33895e1822b663' into codex/ws…
raylim Sep 24, 2026
d39d8cc
Merge commit '38c0449b35ffd7d0652338065b43c1b116f87cea' into codex/ws…
raylim Sep 24, 2026
caa4967
Merge commit '139dcccb44ad4a5d20291d3dd2ab3e42d3cc1c81' into codex/ws…
raylim Sep 24, 2026
7b9ed3a
Merge remote-tracking branch 'fork/codex/wsi-release-hardening' into …
raylim Sep 24, 2026
0622ffd
Merge remote-tracking branch 'fork/codex/wsi-release-hardening' into …
raylim Sep 24, 2026
a40b470
Merge remote-tracking branch 'fork/codex/wsi-release-hardening' into …
raylim Sep 24, 2026
edab3c4
Merge remote-tracking branch 'fork/codex/wsi-release-hardening' into …
raylim Sep 24, 2026
3979a06
Merge remote-tracking branch 'fork/codex/wsi-release-hardening' into …
raylim Sep 24, 2026
5be0025
Merge remote-tracking branch 'fork/codex/wsi-release-hardening' into …
raylim Sep 24, 2026
60e327e
Merge remote-tracking branch 'fork/codex/wsi-release-hardening' into …
raylim Sep 24, 2026
2490b2f
Merge remote-tracking branch 'fork/codex/wsi-release-hardening' into …
raylim Sep 24, 2026
a6db240
Merge remote-tracking branch 'fork/codex/wsi-foundation-auth-fix' int…
raylim Sep 24, 2026
e757fe0
Merge remote-tracking branch 'fork/codex/wsi-foundation-auth-fix' int…
raylim Sep 24, 2026
cf7d81f
Merge remote-tracking branch 'fork/codex/wsi-foundation-auth-fix' int…
raylim Sep 24, 2026
420c307
Merge foundation root-session auth fix into molecular child
raylim Sep 24, 2026
ddfc91d
Merge relative authenticated probe fix into WSI child
raylim Sep 24, 2026
13dcb3d
Merge commit 'f174620dcfc9bb54ce9f437352d363f28183cfe0' into codex/ws…
raylim Sep 24, 2026
cf79c2c
Merge commit '7558f076f4b092ad1c3a1ceb7821ffed1172f27e' into codex/ws…
raylim Sep 24, 2026
087cd69
chore: sync foundation baseline
raylim Sep 24, 2026
e7be515
Merge commit '95ce1ecfd' into codex/wsi-molecular-auth-fix
raylim Sep 24, 2026
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
298 changes: 298 additions & 0 deletions end-to-end-test-playwright/tests/wsi-molecular-mocked.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
import { test, expect } from '../fixtures';
import {
installFoundationMocks,
STUDY_ID,
PATIENT_ID,
IMAGE_ID,
} from './wsi-foundation-mocks';

const SAMPLE_ID = 'wsi-foundation-smoke-sample';

const molecularHierarchy = {
referenceSampleId: SAMPLE_ID,
sampleGroups: [
{
sampleId: SAMPLE_ID,
parts: [
{
partNumber: '1',
partDesignator: '1',
partType: '',
partDescription: 'Molecular specimen',
subspecialty: '',
pathDxTitle: '',
blocks: [
{
blockNumber: 'A1',
blockLabel: 'A1',
slides: [
{
imageId: IMAGE_ID,
stainName: 'H&E initial',
stainGroup: 'H&E (Initial)',
isHne: true,
isIhc: false,
magnification: '',
fileSizeBytes: null,
canServeTiles: true,
barcode: '',
slideType: 'H&E',
sampleId: SAMPLE_ID,
matchLevel: 'BLOCK',
specimenKey: 'block::1::A1',
procedureDateDays: -10,
timepointSource: 'Procedure date',
procedureDateKind: 'RECORDED',
procedureDateSource:
'Recorded procedure date',
procedureDateReason: null,
procedureDateStatus: 'AVAILABLE',
procedureCoordinateSystem:
'patient_first_tumor_sequencing_day_zero',
},
],
},
],
},
],
},
],
};

async function installMolecularMocks(
page: import('@playwright/test').Page,
options: { enrichment?: boolean } = {}
) {
const enrichmentRequests = await installFoundationMocks(page);
const portalRequests: string[] = [];
const enrichmentDetails: Array<{ url: string; postData?: string }> = [];
page.on('request', request => {
if (
/molecular-profiles|mutations\/fetch|cna-genes|structural-variant|mutation-counts/.test(
request.url()
)
) {
portalRequests.push(request.url());
}
if (/\/proxy\/|oncokb|civicdb|civic/i.test(request.url())) {
enrichmentRequests.push(request.url());
enrichmentDetails.push({
url: request.url(),
postData: request.postData() || undefined,
});
}
});

await page.route('**/config_service', route =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
app_name: 'wsi-molecular-smoke',
authenticationMethod: 'none',
msk_wsi_tile_server_url: '/wsi',
msk_wsi_authentication_enabled: false,
show_oncokb: options.enrichment === true,
show_civic: options.enrichment === true,
}),
})
);
if (options.enrichment) {
await page.route('**/proxy/**', route =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify([
{
query: { id: '3845_G12D_Missense_Mutation' },
oncogenic: 'Oncogenic',
},
]),
})
);
await page.route('**civicdb.org/api/graphql', route =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
data: {
genes: {
pageInfo: {
endCursor: null,
hasNextPage: false,
startCursor: null,
hasPreviousPage: false,
},
nodes: [
{
id: 3845,
name: 'KRAS',
link: '/genes/3845',
description: 'KRAS CIViC summary',
variants: {
pageInfo: {
endCursor: null,
hasNextPage: false,
startCursor: null,
hasPreviousPage: false,
},
nodes: [],
},
},
],
},
},
}),
})
);
}
await page.route(
`**/api/wsi/v2/hierarchy/${STUDY_ID}/${PATIENT_ID}`,
route =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(molecularHierarchy),
})
);
await page.route(`**/api/studies/${STUDY_ID}/samples**`, route =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify([
{
sampleId: SAMPLE_ID,
patientId: PATIENT_ID,
studyId: STUDY_ID,
sequenced: true,
},
]),
})
);
await page.route(`**/api/studies/${STUDY_ID}/molecular-profiles**`, route =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify([
{
molecularProfileId: 'wsi-mutations',
molecularAlterationType: 'MUTATION_EXTENDED',
},
]),
})
);
await page.route('**/api/mutations/fetch**', route =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify([
{
sampleId: SAMPLE_ID,
entrezGeneId: 3845,
gene: { hugoGeneSymbol: 'KRAS', entrezGeneId: 3845 },
proteinChange: 'p.G12D',
mutationType: 'Missense_Mutation',
proteinPosStart: 12,
proteinPosEnd: 12,
},
]),
})
);
await page.route('**/api/mutation-counts-by-position/fetch', route =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify([]),
})
);
return { enrichmentRequests, enrichmentDetails, portalRequests };
}

test.describe('WSI molecular child contract', () => {
test('loads molecular rows through portal APIs without changing tile routing', async ({
page,
}) => {
const {
enrichmentRequests,
portalRequests,
} = await installMolecularMocks(page);
const errors: string[] = [];
page.on('pageerror', error => errors.push(error.message));

await page.goto(
`/wsi/patient/${PATIENT_ID}?studyId=${STUDY_ID}#wsi:slide=${IMAGE_ID}`
);

await expect(page.getByTitle('Fit to view')).toBeVisible({
timeout: 30000,
});
await expect(
page.getByTestId('wsi-metadata-sidebar')
).toContainText('KRAS', { timeout: 30000 });
expect(
portalRequests.some(url => url.includes('/api/mutations/fetch'))
).toBe(true);
expect(enrichmentRequests).toEqual([]);
expect(errors).toEqual([]);
});

test('uses enabled enrichment through the portal proxy without breaking viewing', async ({
page,
}) => {
const {
enrichmentRequests,
enrichmentDetails,
portalRequests,
} = await installMolecularMocks(page, { enrichment: true });
const errors: string[] = [];
page.on('pageerror', error => errors.push(error.message));

await page.goto(
`/wsi/patient/${PATIENT_ID}?studyId=${STUDY_ID}#wsi:slide=${IMAGE_ID}`
);

await expect(page.getByTitle('Fit to view')).toBeVisible({
timeout: 30000,
});
await expect(
page.getByTestId('wsi-metadata-sidebar')
).toContainText('KRAS', { timeout: 30000 });
await expect
.poll(() => enrichmentRequests.length, { timeout: 30000 })
.toBeGreaterThan(0);

expect(
enrichmentDetails.some(detail => {
const pathPart = detail.url.split('/').pop() || '';
try {
return Buffer.from(pathPart, 'base64')
.toString('utf8')
.includes('/annotate/mutations/byProteinChange');
} catch (_) {
return false;
}
})
).toBe(true);
const mutationRequest = enrichmentDetails.find(detail =>
detail.url.includes('/proxy/')
);
expect(mutationRequest?.postData).toBeTruthy();
const mutationBody = JSON.parse(
Buffer.from(String(mutationRequest?.postData), 'base64').toString(
'utf8'
)
);
expect(mutationBody).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: '3845_G12D_Missense_Mutation',
alteration: 'G12D',
}),
])
);
expect(
portalRequests.some(url => url.includes('/api/mutations/fetch'))
).toBe(true);
expect(errors).toEqual([]);
});
});
Loading
Loading