From 3a4f2dfd94e7502054d2728fa4501ca675f974d5 Mon Sep 17 00:00:00 2001 From: Brian Lambert Date: Mon, 12 Aug 2024 10:32:29 -0700 Subject: [PATCH] =?UTF-8?q?Fixes=20the=20Data=20Explorer=20100x100=20smoke?= =?UTF-8?q?=20test=20so=20that=20numbers=20are=20considered=20to=20be=20eq?= =?UTF-8?q?ual=20if=20they=20are=20within=20=C2=B10.05=20of=20one=20anothe?= =?UTF-8?q?r=20(#4318)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data-explorer-100x100.test.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/test/smoke/src/areas/positron/dataexplorer/data-explorer-100x100.test.ts b/test/smoke/src/areas/positron/dataexplorer/data-explorer-100x100.test.ts index e11e3f7a52a..e666d89cee7 100644 --- a/test/smoke/src/areas/positron/dataexplorer/data-explorer-100x100.test.ts +++ b/test/smoke/src/areas/positron/dataexplorer/data-explorer-100x100.test.ts @@ -21,7 +21,6 @@ export function setupDataExplorer100x100Test(logger: Logger) { // Shared before/after handling. installAllHandlers(logger); - /** * Tests the data explorer. * @param app The application. @@ -91,8 +90,20 @@ export function setupDataExplorer100x100Test(logger: Logger) { // Get the cell. const cell = await app.code.waitForElement(`#data-grid-row-cell-content-${columnIndex}-${rowIndex} .text-container .text-value`); - // Test the cell. - expect(cell.textContent, `${rowIndex},${columnIndex}`).toStrictEqual(row[columnIndex]); + // Get the cell value and test value. + const secsRemover = (value: string) => value.replace(/^(.*)( secs)$/, '$1'); + const cellValue = secsRemover(cell.textContent); + const testValue = secsRemover(row[columnIndex]); + + // If the test value is a number, perform a numerical "close enough" comparison; + // otherwise, perform a strict equal comparison. + if (testValue.match(/^-?\d*\.?\d*$/)) { + expect( + Math.abs(Number.parseFloat(cellValue) - Number.parseFloat(testValue)) + ).toBeLessThan(0.05); + } else { + expect(cell.textContent, `${rowIndex},${columnIndex}`).toStrictEqual(row[columnIndex]); + } // Move to the next cell. await app.workbench.positronDataExplorer.arrowRight(); @@ -219,7 +230,7 @@ export function setupDataExplorer100x100Test(logger: Logger) { /** * Data Explorer 100x100 - R. */ - describe.skip('Data Explorer 100x100 - R', function () { + describe('Data Explorer 100x100 - R', function () { /** * Before hook. */ @@ -259,7 +270,7 @@ export function setupDataExplorer100x100Test(logger: Logger) { app.workspacePathOrFolder, 'data-files', '100x100', - process.platform === 'linux' ? 'r-100x100-linux.tsv' : 'r-100x100.tsv' + 'r-100x100.tsv' ) ); });