fix(TMTV): The TMTV CSV file now has the correct name and contents (#5215)

This commit is contained in:
Joe Boccanfuso authored and GitHub committed 2025-07-15 20:09:23 -04:00
1 parent fceb515a68
commit 522d2aa764
9 files changed
+94 -5

No files matched your search

+2 -1
View File
@@ -1,6 +1,7 @@
import { test } from 'playwright-test-coverage';
import { visitStudy, checkForScreenshot, screenShotPaths } from './utils';
import { assertNumberOfModalityLoadBadges } from './utils/assertions';
import { viewportLocator } from './utils/locators';
test.beforeEach(async ({ page }) => {
const studyInstanceUID = '1.3.6.1.4.1.5962.99.1.2968617883.1314880426.1493322302363.3.0';
@@ -24,7 +25,7 @@ test('should launch MPR with unhydrated RTSTRUCT chosen from the data overlay me
);
// Hover over the middle/sagittal viewport so that the data overlay menu is available.
await page.locator('css=div[data-viewportid="mpr-sagittal"]').hover();
await viewportLocator({ viewportId: 'mpr-sagittal', page }).hover();
await page.getByTestId('dataOverlayMenu-mpr-sagittal-btn').click();
await page.getByTestId('AddSegmentationDataOverlay-mpr-sagittal').click();
await page.getByText('SELECT A SEGMENTATION').click();
+2 -1
View File
@@ -1,6 +1,7 @@
import { test } from 'playwright-test-coverage';
import { visitStudy, checkForScreenshot, screenShotPaths } from './utils';
import { assertNumberOfModalityLoadBadges } from './utils/assertions';
import { viewportLocator } from './utils/locators';
test.beforeEach(async ({ page }) => {
const studyInstanceUID = '1.3.12.2.1107.5.2.32.35162.30000015050317233592200000046';
@@ -25,7 +26,7 @@ test('should launch MPR with unhydrated SEG chosen from the data overlay menu',
);
// Hover over the middle/sagittal viewport so that the data overlay menu is available.
await page.locator('css=div[data-viewportid="mpr-sagittal"]').hover();
await viewportLocator({ viewportId: 'mpr-sagittal', page }).hover();
await page.getByTestId('dataOverlayMenu-mpr-sagittal-btn').click();
await page.getByTestId('AddSegmentationDataOverlay-mpr-sagittal').click();
await page.getByText('SELECT A SEGMENTATION').click();
+45
View File
@@ -0,0 +1,45 @@
import { test, expect } from 'playwright-test-coverage';
import { visitStudy, simulateNormalizedClickOnElement } from './utils/index';
import { viewportLocator } from './utils/locators';
import { downloadAsString } from './utils/download';
test('should create and download the TMTV CSV report correctly', async ({ page }) => {
const studyInstanceUID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
const mode = 'tmtv';
await visitStudy(page, studyInstanceUID, mode, 10000);
await page.getByTestId('addSegmentation').click();
await page.getByTestId('Brush-btn').click();
await simulateNormalizedClickOnElement({
locator: viewportLocator({ viewportId: 'ctAXIAL', page }),
normalizedPoint: { x: 0.5, y: 0.5 },
});
await page.waitForTimeout(5000);
const downloadPromise = page.waitForEvent('download');
await page.getByTestId('exportTmtvCsvReport').click();
const download = await downloadPromise;
expect(download.suggestedFilename(), 'Not the correct file name for the TMTV CSV report.').toBe(
'202009231_tmtv.csv'
);
const tmtvCSVReportContent = await downloadAsString(download);
expect(
tmtvCSVReportContent,
'Expected the file to start with specific column/value headers'
).toMatch(
/^id,label,min,max,mean,stdDev,median,skewness,kurtosis,count,maxLPS,minLPS,center,volume,peakValue,peakLPS,lesionGlycolysis,PatientID,PatientName,StudyInstanceUID,SeriesInstanceUID,StudyDate/
);
expect(tmtvCSVReportContent, 'Expected the patient name to be present').toContain(
'Water Phantom'
);
expect(tmtvCSVReportContent).toContain('Patient ID,202009231');
expect(tmtvCSVReportContent).toContain('Study Date,20200923');
expect(tmtvCSVReportContent, 'Expected no objects to be output.').not.toContain(
'[object Object]'
);
});
+15
View File
@@ -0,0 +1,15 @@
import { Readable } from 'stream';
const _streamToString = async (stream: Readable) => {
return new Promise((resolve, reject) => {
const chunks = [];
stream.on('data', chunk => chunks.push(chunk));
stream.on('error', err => reject(err));
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
});
};
export const downloadAsString = async download => {
const stream = await download.createReadStream();
return _streamToString(stream);
};
+11
View File
@@ -0,0 +1,11 @@
import { Locator, Page } from '@playwright/test';
export const viewportLocator = ({
page,
viewportId,
}: {
page: Page;
viewportId: string;
}): Locator => {
return page.locator(`css=div[data-viewportid="${viewportId}"]`);
};