From 683a0cf98c35bb7c5598f4533110f3b94de1a7c8 Mon Sep 17 00:00:00 2001 From: shadowusr Date: Tue, 7 Nov 2023 16:58:15 +0300 Subject: [PATCH] fix: minor bug fixes and review fixes --- lib/constants/database.ts | 4 +++- lib/db-utils/common.ts | 2 +- lib/tests-tree-builder/gui.ts | 3 ++- test/func/packages/webpack.common.js | 2 +- test/unit/lib/gui/tool-runner/index.js | 6 ++++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/constants/database.ts b/lib/constants/database.ts index 15b0502b2..cc9cd381b 100644 --- a/lib/constants/database.ts +++ b/lib/constants/database.ts @@ -1,3 +1,5 @@ +import {ValueOf} from 'type-fest'; + // TODO: change to enums export const DB_TYPES = {int: 'INT', text: 'TEXT'} as const; export const DB_COLUMNS = { @@ -41,4 +43,4 @@ export const DATABASE_URLS_JSON_NAME = 'databaseUrls.json'; export const DB_COLUMN_INDEXES = SUITES_TABLE_COLUMNS.reduce((acc: Record, {name}, index) => { acc[name] = index; return acc; -}, {}) as { [K in (typeof SUITES_TABLE_COLUMNS)[number]['name']]: number }; +}, {}) as { [K in ValueOf]: number }; diff --git a/lib/db-utils/common.ts b/lib/db-utils/common.ts index 931dcb614..599d4a0e9 100644 --- a/lib/db-utils/common.ts +++ b/lib/db-utils/common.ts @@ -77,7 +77,7 @@ export const mergeTables = ({db, dbPaths, getExistingTables = (): string[] => [] } }; -function createTableQuery(tableName: string, columns: ReadonlyDeep<{name: string, readonly type: string }[]>): string { +function createTableQuery(tableName: string, columns: ReadonlyDeep<{name: string, type: string }[]>): string { const formattedColumns = columns .map(({name, type}) => `${name} ${type}`) .join(', '); diff --git a/lib/tests-tree-builder/gui.ts b/lib/tests-tree-builder/gui.ts index 2d7b1e364..ffd88676f 100644 --- a/lib/tests-tree-builder/gui.ts +++ b/lib/tests-tree-builder/gui.ts @@ -54,6 +54,7 @@ export class GuiTestsTreeBuilder extends BaseTestsTreeBuilder { return this._tree.results.byId[testResultId]; } + /* Returns "real" last test result - one that wasn't generated by clicking accept button */ getLastActualResult(formattedResult: ReporterTestResult): TreeResult | undefined { let attempt = formattedResult.attempt - 1; while (attempt >= 0) { @@ -166,7 +167,7 @@ export class GuiTestsTreeBuilder extends BaseTestsTreeBuilder { : null; const countUpdated = result.imageIds.reduce((acc, currImageId) => { - return acc + Number(isUpdatedStatus(this._tree.images.byId[currImageId].status)); + return isUpdatedStatus(this._tree.images.byId[currImageId].status) ? acc + 1 : acc; }, 0); const shouldRemoveResult = isUpdatedStatus(image.status) && countUpdated === 1; diff --git a/test/func/packages/webpack.common.js b/test/func/packages/webpack.common.js index 7751452db..8c0d00022 100644 --- a/test/func/packages/webpack.common.js +++ b/test/func/packages/webpack.common.js @@ -17,7 +17,7 @@ module.exports = { loader: 'babel-loader', exclude: /node_modules/, options: { - configFile: path.resolve(__dirname, '../../../.babelrc') + configFile: path.resolve(__dirname, '../../../babel.config.json') } } ] diff --git a/test/unit/lib/gui/tool-runner/index.js b/test/unit/lib/gui/tool-runner/index.js index 6ede82edb..624eb54c8 100644 --- a/test/unit/lib/gui/tool-runner/index.js +++ b/test/unit/lib/gui/tool-runner/index.js @@ -352,11 +352,13 @@ describe('lib/gui/tool-runner/index', () => { it('should revert reference, if ReportBuilder.undoAcceptImages resolved "shouldRevertReference"', async () => { const stateName = 'plain'; - const {gui, tests} = await mkUndoTestData_({shouldRevertReference: true}, {stateName}); + const {gui, tests} = await mkUndoTestData_({ + shouldRevertReference: true, removedResult: 'some-result' + }, {stateName}); await gui.undoAcceptImages(tests); - assert.calledOnceWith(revertReferenceImage, sinon.match({fullName: 'some-title'}), 'plain'); + assert.calledOnceWith(revertReferenceImage, 'some-result', sinon.match({fullName: 'some-title'}), 'plain'); }); it('should update expected path', async () => {