Skip to content

Commit

Permalink
fix: minor bug fixes and review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Nov 7, 2023
1 parent 6d7eefe commit 683a0cf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lib/constants/database.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -41,4 +43,4 @@ export const DATABASE_URLS_JSON_NAME = 'databaseUrls.json';
export const DB_COLUMN_INDEXES = SUITES_TABLE_COLUMNS.reduce((acc: Record<string, number>, {name}, index) => {
acc[name] = index;
return acc;
}, {}) as { [K in (typeof SUITES_TABLE_COLUMNS)[number]['name']]: number };
}, {}) as { [K in ValueOf<typeof DB_COLUMNS>]: number };
2 changes: 1 addition & 1 deletion lib/db-utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(', ');
Expand Down
3 changes: 2 additions & 1 deletion lib/tests-tree-builder/gui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion test/func/packages/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
]
Expand Down
6 changes: 4 additions & 2 deletions test/unit/lib/gui/tool-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 683a0cf

Please sign in to comment.