Skip to content

Commit

Permalink
Fixes the Data Explorer 100x100 smoke test so that numbers are consid…
Browse files Browse the repository at this point in the history
…ered to be equal if they are within ±0.05 of one another (#4318)
  • Loading branch information
softwarenerd authored Aug 12, 2024
1 parent 93044c6 commit 3a4f2df
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export function setupDataExplorer100x100Test(logger: Logger) {
// Shared before/after handling.
installAllHandlers(logger);


/**
* Tests the data explorer.
* @param app The application.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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'
)
);
});
Expand Down

0 comments on commit 3a4f2df

Please sign in to comment.