From e02b797c917f356499c086e8dfa8eee40b71a42f Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Mon, 2 Nov 2020 18:20:14 -0500 Subject: [PATCH 1/8] Part 1 of reenabling no-floating-promises --- src/DetailsView/details-view-initializer.ts | 10 ++++- src/background/background-init.ts | 4 ++ src/background/global-context-factory.ts | 1 + src/background/injector-controller.ts | 45 ++++++++----------- src/background/stores/assessment-store.ts | 35 +++++---------- .../stores/global/global-store-hub.ts | 4 ++ .../stores/global/user-configuration-store.ts | 8 +++- src/background/tab-context-factory.ts | 4 ++ src/electron/views/renderer-initializer.ts | 14 +++--- src/injected/analyzers/analyzer-provider.ts | 31 ++++++------- src/injected/analyzers/base-analyzer.ts | 15 +++---- src/injected/analyzers/tab-stops-analyzer.ts | 10 ++--- src/injected/client-init.ts | 5 ++- src/injected/main-window-initializer.ts | 1 + src/popup/popup-init.ts | 6 +-- .../common/assessment-store-data-builder.ts | 2 + .../unit/common/fail-test-on-error-logger.ts | 13 ++++++ .../unit/tests/DetailsView/store-mocks.ts | 1 + .../background/injector-controller.test.ts | 12 ++--- .../stores/global/global-store-hub.test.ts | 3 ++ .../global/user-configuration-store.test.ts | 16 ++++++- .../background/tab-context-factory.test.ts | 4 ++ .../analyzers/analyzer-provider.test.ts | 2 + .../injected/analyzers/base-analyzer.test.ts | 2 + .../analyzers/tab-stops-analyzer.test.ts | 21 +++++---- .../frame-communicator.test.ts | 2 +- 26 files changed, 154 insertions(+), 117 deletions(-) create mode 100644 src/tests/unit/common/fail-test-on-error-logger.ts diff --git a/src/DetailsView/details-view-initializer.ts b/src/DetailsView/details-view-initializer.ts index 06c9b61de95..7bea71e63a4 100644 --- a/src/DetailsView/details-view-initializer.ts +++ b/src/DetailsView/details-view-initializer.ts @@ -122,6 +122,7 @@ import { AssessmentInstanceTableHandler } from './handlers/assessment-instance-t import { DetailsViewToggleClickHandlerFactory } from './handlers/details-view-toggle-click-handler-factory'; import { MasterCheckBoxConfigProvider } from './handlers/master-checkbox-config-provider'; import { PreviewFeatureFlagsHandler } from './handlers/preview-feature-flags-handler'; +import { Logger } from 'common/logging/logger'; declare const window: AutoChecker & Window; @@ -486,7 +487,11 @@ if (tabId != null) { window.A11YSelfValidator = a11ySelfValidator; }, () => { - const renderer = createNullifiedRenderer(document, ReactDOM.render); + const renderer = createNullifiedRenderer( + document, + ReactDOM.render, + createDefaultLogger(), + ); renderer.render(); }, ); @@ -495,9 +500,10 @@ if (tabId != null) { function createNullifiedRenderer( doc: Document, render: typeof ReactDOM.render, + logger: Logger, ): NoContentAvailableViewRenderer { // using an instance of an actual store (instead of a StoreProxy) so we can get the default state. - const store = new UserConfigurationStore(null, new UserConfigurationActions(), null); + const store = new UserConfigurationStore(null, new UserConfigurationActions(), null, logger); const storesHub = new BaseClientStoresHub([store]); const deps: NoContentAvailableViewDeps = { diff --git a/src/background/background-init.ts b/src/background/background-init.ts index cab6589e3d2..b07f0e07d8f 100644 --- a/src/background/background-init.ts +++ b/src/background/background-init.ts @@ -6,6 +6,7 @@ import { ConsoleTelemetryClient } from 'background/telemetry/console-telemetry-c import { DebugToolsTelemetryClient } from 'background/telemetry/debug-tools-telemetry-client'; import { createToolData } from 'common/application-properties-provider'; import { BrowserAdapterFactory } from 'common/browser-adapters/browser-adapter-factory'; +import { WindowUtils } from 'common/window-utils'; import { UAParser } from 'ua-parser-js'; import { AxeInfo } from '../common/axe-info'; import { VisualizationConfigurationFactory } from '../common/configs/visualization-configuration-factory'; @@ -57,6 +58,8 @@ async function initialize(): Promise { deprecatedStorageDataKeys, ); + const windowUtils = new WindowUtils(); + const urlValidator = new UrlValidator(browserAdapter); const indexedDBInstance: IndexedDBAPI = new IndexedDBUtil(getIndexedDBStore()); const indexedDBDataKeysToFetch = [ @@ -186,6 +189,7 @@ async function initialize(): Promise { promiseFactory, logger, usageLogger, + windowUtils, ); const targetPageController = new TargetPageController( diff --git a/src/background/global-context-factory.ts b/src/background/global-context-factory.ts index 6302ee2757b..c9a26fef206 100644 --- a/src/background/global-context-factory.ts +++ b/src/background/global-context-factory.ts @@ -61,6 +61,7 @@ export class GlobalContextFactory { indexedDBInstance, persistedData, storageAdapter, + logger, ); const featureFlagsController = new FeatureFlagsController( diff --git a/src/background/injector-controller.ts b/src/background/injector-controller.ts index 6be9224d7ab..6c4152d64a3 100644 --- a/src/background/injector-controller.ts +++ b/src/background/injector-controller.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. import { InspectMode } from 'background/inspect-modes'; +import { Logger } from 'common/logging/logger'; import { Messages } from '../common/messages'; import { WindowUtils } from '../common/window-utils'; import { ContentScriptInjector } from './injector/content-script-injector'; @@ -10,31 +11,19 @@ import { TabStore } from './stores/tab-store'; import { VisualizationStore } from './stores/visualization-store'; export class InjectorController { - private injector: ContentScriptInjector; - private visualizationStore: VisualizationStore; - private inspectStore: InspectStore; - private interpreter: Interpreter; - private tabStore: TabStore; - private windowUtils: WindowUtils; private static readonly injectionStartedWaitTime = 10; private oldInspectType = InspectMode.off; constructor( - injector: ContentScriptInjector, - visualizationStore: VisualizationStore, - interpreter: Interpreter, - tabStore: TabStore, - inspectStore: InspectStore, - windowUtils?: WindowUtils, - ) { - this.injector = injector; - this.visualizationStore = visualizationStore; - this.tabStore = tabStore; - this.inspectStore = inspectStore; - this.interpreter = interpreter; - this.windowUtils = windowUtils || new WindowUtils(); - } + private readonly injector: ContentScriptInjector, + private readonly visualizationStore: VisualizationStore, + private readonly interpreter: Interpreter, + private readonly tabStore: TabStore, + private readonly inspectStore: InspectStore, + private readonly windowUtils: WindowUtils, + private readonly logger: Logger, + ) {} public initialize(): void { this.visualizationStore.addChangedListener(this.inject); @@ -59,13 +48,15 @@ export class InjectorController { }); }, InjectorController.injectionStartedWaitTime); - // tslint:disable-next-line:no-floating-promises - grandfathered - this.injector.injectScripts(tabId).then(() => { - this.interpreter.interpret({ - messageType: Messages.Visualizations.State.InjectionCompleted, - tabId: tabId, - }); - }); + this.injector + .injectScripts(tabId) + .then(() => { + this.interpreter.interpret({ + messageType: Messages.Visualizations.State.InjectionCompleted, + tabId: tabId, + }); + }) + .catch(this.logger.error); } this.oldInspectType = inspectStoreState.inspectMode; diff --git a/src/background/stores/assessment-store.ts b/src/background/stores/assessment-store.ts index f61d054fed2..67365b65ef4 100644 --- a/src/background/stores/assessment-store.ts +++ b/src/background/stores/assessment-store.ts @@ -4,6 +4,7 @@ import { AssessmentsProvider } from 'assessments/types/assessments-provider'; import { IndexedDBDataKeys } from 'background/IndexedDBDataKeys'; import { BrowserAdapter } from 'common/browser-adapters/browser-adapter'; import { IndexedDBAPI } from 'common/indexedDB/indexedDB'; +import { Logger } from 'common/logging/logger'; import { StoreNames } from 'common/stores/store-names'; import { DetailsViewPivotType } from 'common/types/details-view-pivot-type'; import { ManualTestStatus } from 'common/types/manual-test-status'; @@ -46,33 +47,18 @@ import { AssessmentDataRemover } from './../assessment-data-remover'; import { BaseStoreImpl } from './base-store-impl'; export class AssessmentStore extends BaseStoreImpl { - private assessmentActions: AssessmentActions; - private assessmentDataConverter: AssessmentDataConverter; - private assessmentDataRemover: AssessmentDataRemover; - private assessmentsProvider: AssessmentsProvider; - private idbInstance: IndexedDBAPI; - private browserAdapter: BrowserAdapter; - private persistedData: AssessmentStoreData; - constructor( - browserAdapter: BrowserAdapter, - assessmentActions: AssessmentActions, - assessmentDataConverter: AssessmentDataConverter, - assessmentDataRemover: AssessmentDataRemover, - assessmentsProvider: AssessmentsProvider, - idbInstance: IndexedDBAPI, - persistedData: AssessmentStoreData, + private readonly browserAdapter: BrowserAdapter, + private readonly assessmentActions: AssessmentActions, + private readonly assessmentDataConverter: AssessmentDataConverter, + private readonly assessmentDataRemover: AssessmentDataRemover, + private readonly assessmentsProvider: AssessmentsProvider, + private readonly idbInstance: IndexedDBAPI, + private readonly persistedData: AssessmentStoreData, private readonly initialAssessmentStoreDataGenerator: InitialAssessmentStoreDataGenerator, + private readonly logger: Logger, ) { super(StoreNames.AssessmentStore); - - this.browserAdapter = browserAdapter; - this.assessmentActions = assessmentActions; - this.assessmentDataConverter = assessmentDataConverter; - this.assessmentsProvider = assessmentsProvider; - this.assessmentDataRemover = assessmentDataRemover; - this.idbInstance = idbInstance; - this.persistedData = persistedData; } public generateDefaultState(persistedData: AssessmentStoreData = null): AssessmentStoreData { @@ -99,8 +85,7 @@ export class AssessmentStore extends BaseStoreImpl { protected emitChanged(): void { const assessmentStoreData = this.getState(); - // tslint:disable-next-line:no-floating-promises - grandfathered-in pre-existing violation - this.persistAssessmentData(assessmentStoreData); + this.persistAssessmentData(assessmentStoreData).catch(this.logger.error); super.emitChanged(); } diff --git a/src/background/stores/global/global-store-hub.ts b/src/background/stores/global/global-store-hub.ts index dcb244134d3..9def679ab98 100644 --- a/src/background/stores/global/global-store-hub.ts +++ b/src/background/stores/global/global-store-hub.ts @@ -3,6 +3,7 @@ import { PermissionsStateStore } from 'background/stores/global/permissions-state-store'; import { FeatureFlagDefaultsHelper } from 'common/feature-flag-defaults-helper'; import { getAllFeatureFlagDetails } from 'common/feature-flags'; +import { Logger } from 'common/logging/logger'; import { BaseStore } from '../../../common/base-store'; import { BrowserAdapter } from '../../../common/browser-adapters/browser-adapter'; import { StorageAdapter } from '../../../common/browser-adapters/storage-adapter'; @@ -43,6 +44,7 @@ export class GlobalStoreHub implements StoreHub { indexedDbInstance: IndexedDBAPI, persistedData: PersistedData, storageAdapter: StorageAdapter, + logger: Logger, ) { this.commandStore = new CommandStore(globalActionHub.commandActions, telemetryEventHandler); this.featureFlagStore = new FeatureFlagStore( @@ -66,11 +68,13 @@ export class GlobalStoreHub implements StoreHub { indexedDbInstance, persistedData.assessmentStoreData, new InitialAssessmentStoreDataGenerator(assessmentsProvider.all()), + logger, ); this.userConfigurationStore = new UserConfigurationStore( persistedData.userConfigurationData, globalActionHub.userConfigurationActions, indexedDbInstance, + logger, ); this.permissionsStateStore = new PermissionsStateStore( globalActionHub.permissionsStateActions, diff --git a/src/background/stores/global/user-configuration-store.ts b/src/background/stores/global/user-configuration-store.ts index ebaeeb7cedb..d52fd2a4d34 100644 --- a/src/background/stores/global/user-configuration-store.ts +++ b/src/background/stores/global/user-configuration-store.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +import { Logger } from 'common/logging/logger'; import { cloneDeep, isPlainObject } from 'lodash'; import { IndexedDBAPI } from '../../../common/indexedDB/indexedDB'; import { StoreNames } from '../../../common/stores/store-names'; @@ -33,6 +34,7 @@ export class UserConfigurationStore extends BaseStoreImpl) => { - const installationData: InstallationData = persistedData.installationData; +const logger = createDefaultLogger(); - const logger = createDefaultLogger(); +getPersistedData(indexedDBInstance, indexedDBDataKeysToFetch) + .then((persistedData: Partial) => { + const installationData: InstallationData = persistedData.installationData; const applicationTelemetryDataFactory = getApplicationTelemetryDataFactory( installationData, @@ -203,6 +202,7 @@ getPersistedData(indexedDBInstance, indexedDBDataKeysToFetch).then( persistedData.userConfigurationData, userConfigActions, indexedDBInstance, + logger, ); userConfigurationStore.initialize(); @@ -561,5 +561,5 @@ getPersistedData(indexedDBInstance, indexedDBDataKeysToFetch).then( sendAppInitializedTelemetryEvent(telemetryEventHandler, platformInfo); ipcRendererShim.initializeWindow(); - }, -); + }) + .catch(logger.error); diff --git a/src/injected/analyzers/analyzer-provider.ts b/src/injected/analyzers/analyzer-provider.ts index 73300c3d692..6671618d9a3 100644 --- a/src/injected/analyzers/analyzer-provider.ts +++ b/src/injected/analyzers/analyzer-provider.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +import { Logger } from 'common/logging/logger'; import { ScanIncompleteWarningDetector } from 'injected/scan-incomplete-warning-detector'; import { BaseStore } from '../../common/base-store'; @@ -21,25 +22,19 @@ import { PostResolveCallback, RuleAnalyzer } from './rule-analyzer'; import { TabStopsAnalyzer } from './tab-stops-analyzer'; export class AnalyzerProvider { - private tabStopsListener: TabStopsListener; - private scopingStore: BaseStore; - private sendMessageDelegate: (message) => void; - private scanner: ScannerUtils; - private telemetryDataFactory: TelemetryDataFactory; - private dateGetter: () => Date; - constructor( - tabStopsListener: TabStopsListener, - scopingStore: BaseStore, - sendMessageDelegate: (message) => void, - scanner: ScannerUtils, - telemetryDataFactory: TelemetryDataFactory, - dateGetter: () => Date, + private readonly tabStopsListener: TabStopsListener, + private readonly scopingStore: BaseStore, + private readonly sendMessageDelegate: (message) => void, + private readonly scanner: ScannerUtils, + private readonly telemetryDataFactory: TelemetryDataFactory, + private readonly dateGetter: () => Date, private readonly visualizationConfigFactory: VisualizationConfigurationFactory, - private filterResultsByRules: IResultRuleFilter, - private sendConvertedResults: PostResolveCallback, - private sendNeedsReviewResults: PostResolveCallback, - private scanIncompleteWarningDetector: ScanIncompleteWarningDetector, + private readonly filterResultsByRules: IResultRuleFilter, + private readonly sendConvertedResults: PostResolveCallback, + private readonly sendNeedsReviewResults: PostResolveCallback, + private readonly scanIncompleteWarningDetector: ScanIncompleteWarningDetector, + private readonly logger: Logger, ) { this.tabStopsListener = tabStopsListener; this.scopingStore = scopingStore; @@ -116,6 +111,7 @@ export class AnalyzerProvider { new WindowUtils(), this.sendMessageDelegate, this.scanIncompleteWarningDetector, + this.logger, ); } @@ -124,6 +120,7 @@ export class AnalyzerProvider { config, this.sendMessageDelegate, this.scanIncompleteWarningDetector, + this.logger, ); } } diff --git a/src/injected/analyzers/base-analyzer.ts b/src/injected/analyzers/base-analyzer.ts index c53aaf79fe3..4103bbc275e 100644 --- a/src/injected/analyzers/base-analyzer.ts +++ b/src/injected/analyzers/base-analyzer.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +import { Logger } from 'common/logging/logger'; import { ScanIncompleteWarningDetector } from 'injected/scan-incomplete-warning-detector'; import * as Q from 'q'; @@ -20,21 +21,17 @@ export class BaseAnalyzer implements Analyzer { }; constructor( - protected config: AnalyzerConfiguration, - protected sendMessage: (message) => void, - private scanIncompleteWarningDetector: ScanIncompleteWarningDetector, + protected readonly config: AnalyzerConfiguration, + protected readonly sendMessage: (message) => void, + private readonly scanIncompleteWarningDetector: ScanIncompleteWarningDetector, + protected readonly logger: Logger, ) { this.visualizationType = config.testType; } public analyze(): void { const results = this.getResults(); - - // We intentionally float this promise; the current analyzer API is that analyze starts the - // analysis and it's allowed to continue running for arbitrarily long until teardown() is called. - // - // tslint:disable-next-line:no-floating-promises - results.then(this.onResolve); + results.then(this.onResolve).catch(this.logger.error); } public teardown(): void {} diff --git a/src/injected/analyzers/tab-stops-analyzer.ts b/src/injected/analyzers/tab-stops-analyzer.ts index 385e1d8798c..4b81c885f68 100644 --- a/src/injected/analyzers/tab-stops-analyzer.ts +++ b/src/injected/analyzers/tab-stops-analyzer.ts @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +import { Logger } from 'common/logging/logger'; +import { WindowUtils } from 'common/window-utils'; import { ScanIncompleteWarningDetector } from 'injected/scan-incomplete-warning-detector'; import * as Q from 'q'; -import { WindowUtils } from '../../common/window-utils'; import { TabStopEvent, TabStopsListener } from '../tab-stops-listener'; import { AxeAnalyzerResult, @@ -32,8 +33,9 @@ export class TabStopsAnalyzer extends BaseAnalyzer { windowUtils: WindowUtils, sendMessageDelegate: (message) => void, scanIncompleteWarningDetector: ScanIncompleteWarningDetector, + logger: Logger, ) { - super(config, sendMessageDelegate, scanIncompleteWarningDetector); + super(config, sendMessageDelegate, scanIncompleteWarningDetector, logger); this.tabStopsListener = tabStopsListener; this.windowUtils = windowUtils; } @@ -42,9 +44,7 @@ export class TabStopsAnalyzer extends BaseAnalyzer { // We intentionally float this promise; the current analyzer API is that analyze starts the // analysis and it's allowed to continue running for arbitrarily long until teardown() is called. // We use a Promise for this internally only so we can reuse Q's "onprogress" behavior. - // - // tslint:disable-next-line:no-floating-promises - this.getResults().progress(this.onProgress); + this.getResults().progress(this.onProgress).catch(this.logger.error); } protected getResults = (): Q.Promise => { diff --git a/src/injected/client-init.ts b/src/injected/client-init.ts index 26b907c1aa4..63ff2627261 100644 --- a/src/injected/client-init.ts +++ b/src/injected/client-init.ts @@ -1,10 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +import { createDefaultLogger } from 'common/logging/default-logger'; import { initializeFabricIcons } from '../common/fabric-icons'; import { MainWindowInitializer } from './main-window-initializer'; import { WindowInitializer } from './window-initializer'; if (!window.windowInitializer) { + const logger = createDefaultLogger(); initializeFabricIcons(); if (window.top === window) { @@ -13,6 +15,5 @@ if (!window.windowInitializer) { window.windowInitializer = new WindowInitializer(); } - // tslint:disable-next-line:no-floating-promises - top-level entry points are intentionally floating promises - window.windowInitializer.initialize(); + window.windowInitializer.initialize().catch(logger.error); } diff --git a/src/injected/main-window-initializer.ts b/src/injected/main-window-initializer.ts index 6241a95c2db..326bbb237b0 100644 --- a/src/injected/main-window-initializer.ts +++ b/src/injected/main-window-initializer.ts @@ -321,6 +321,7 @@ export class MainWindowInitializer extends WindowInitializer { unifiedResultSender.sendAutomatedChecksResults, unifiedResultSender.sendNeedsReviewResults, scanIncompleteWarningDetector, + logger, ); const analyzerStateUpdateHandler = new AnalyzerStateUpdateHandler( diff --git a/src/popup/popup-init.ts b/src/popup/popup-init.ts index 545e06a2639..a8fd6abae38 100644 --- a/src/popup/popup-init.ts +++ b/src/popup/popup-init.ts @@ -16,14 +16,14 @@ const browserAdapterFactory = new BrowserAdapterFactory(userAgentParser); const browserAdapter = browserAdapterFactory.makeFromUserAgent(); const urlValidator = new UrlValidator(browserAdapter); const targetTabFinder = new TargetTabFinder(window, browserAdapter, urlValidator, new UrlParser()); +const logger = createDefaultLogger(); const isSupportedBrowser = createSupportedBrowserChecker(userAgentParser); const popupInitializer: PopupInitializer = new PopupInitializer( browserAdapter, targetTabFinder, isSupportedBrowser, - createDefaultLogger(), + logger, ); -// tslint:disable-next-line:no-floating-promises - top-level entry points are intentionally floating promises -popupInitializer.initialize(); +popupInitializer.initialize().catch(logger.error); diff --git a/src/tests/unit/common/assessment-store-data-builder.ts b/src/tests/unit/common/assessment-store-data-builder.ts index 4c0dacc1be7..e922ee5e818 100644 --- a/src/tests/unit/common/assessment-store-data-builder.ts +++ b/src/tests/unit/common/assessment-store-data-builder.ts @@ -12,6 +12,7 @@ import { } from '../../../common/types/store-data/assessment-result-data'; import { VisualizationType } from '../../../common/types/visualization-type'; import { BaseDataBuilder } from './base-data-builder'; +import { failTestOnErrorLogger } from 'tests/unit/common/fail-test-on-error-logger'; export class AssessmentsStoreDataBuilder extends BaseDataBuilder { private storeDataGeneratorMock: IMock; @@ -31,6 +32,7 @@ export class AssessmentsStoreDataBuilder extends BaseDataBuilder { + // intentionally ignored + }, + error: (message?: string, ...optionalParams: any[]) => { + fail(`FailTestOnErrorLogger.error invoked with "${message}" ${inspect(optionalParams)}`); + }, +}; diff --git a/src/tests/unit/tests/DetailsView/store-mocks.ts b/src/tests/unit/tests/DetailsView/store-mocks.ts index 240f3453505..72feffaa212 100644 --- a/src/tests/unit/tests/DetailsView/store-mocks.ts +++ b/src/tests/unit/tests/DetailsView/store-mocks.ts @@ -76,6 +76,7 @@ export class StoreMocks { null, null, null, + null, ).getDefaultState(); public scopingStoreData = new ScopingStore(null).getDefaultState(); public inspectStoreData = new InspectStore(null, null).getDefaultState(); diff --git a/src/tests/unit/tests/background/injector-controller.test.ts b/src/tests/unit/tests/background/injector-controller.test.ts index 41a39d9ce00..9a6f0838498 100644 --- a/src/tests/unit/tests/background/injector-controller.test.ts +++ b/src/tests/unit/tests/background/injector-controller.test.ts @@ -10,11 +10,12 @@ import { Interpreter } from 'background/interpreter'; import { InspectStore } from 'background/stores/inspect-store'; import { TabStore } from 'background/stores/tab-store'; import { VisualizationStore } from 'background/stores/visualization-store'; -import { Messages } from '../../../../common/messages'; -import { VisualizationStoreData } from '../../../../common/types/store-data/visualization-store-data'; -import { WindowUtils } from '../../../../common/window-utils'; -import { itIsFunction } from '../../common/it-is-function'; -import { VisualizationStoreDataBuilder } from '../../common/visualization-store-data-builder'; +import { Messages } from 'common/messages'; +import { VisualizationStoreData } from 'common/types/store-data/visualization-store-data'; +import { WindowUtils } from 'common/window-utils'; +import { itIsFunction } from 'tests/unit/common/it-is-function'; +import { VisualizationStoreDataBuilder } from 'tests/unit/common/visualization-store-data-builder'; +import { failTestOnErrorLogger } from 'tests/unit/common/fail-test-on-error-logger'; describe('InjectorControllerTest', () => { let validator: InjectorControllerValidator; @@ -176,6 +177,7 @@ class InjectorControllerValidator { this.mockTabStore.object, this.mockInspectStore.object, this.mockWindowUtils.object, + failTestOnErrorLogger, ); } diff --git a/src/tests/unit/tests/background/stores/global/global-store-hub.test.ts b/src/tests/unit/tests/background/stores/global/global-store-hub.test.ts index af1b3bbedbc..5eab6aa6461 100644 --- a/src/tests/unit/tests/background/stores/global/global-store-hub.test.ts +++ b/src/tests/unit/tests/background/stores/global/global-store-hub.test.ts @@ -12,6 +12,7 @@ import { PermissionsStateStore } from 'background/stores/global/permissions-stat import { ScopingStore } from 'background/stores/global/scoping-store'; import { UserConfigurationStore } from 'background/stores/global/user-configuration-store'; import { cloneDeep } from 'lodash'; +import { failTestOnErrorLogger } from 'tests/unit/common/fail-test-on-error-logger'; import { IMock, Mock, Times } from 'typemoq'; import { BaseStore } from '../../../../../../common/base-store'; import { IndexedDBAPI } from '../../../../../../common/indexedDB/indexedDB'; @@ -60,6 +61,7 @@ describe('GlobalStoreHubTest', () => { idbInstance, cloneDeep(persistedDataStub), null, + failTestOnErrorLogger, ); const allStores = testSubject.getAllStores(); @@ -84,6 +86,7 @@ describe('GlobalStoreHubTest', () => { idbInstance, cloneDeep(persistedDataStub), null, + failTestOnErrorLogger, ); const allStores = testSubject.getAllStores() as BaseStoreImpl[]; const initializeMocks: Array> = []; diff --git a/src/tests/unit/tests/background/stores/global/user-configuration-store.test.ts b/src/tests/unit/tests/background/stores/global/user-configuration-store.test.ts index aa3f9daac23..674d0353378 100644 --- a/src/tests/unit/tests/background/stores/global/user-configuration-store.test.ts +++ b/src/tests/unit/tests/background/stores/global/user-configuration-store.test.ts @@ -23,6 +23,7 @@ import { UserConfigurationStoreData, } from '../../../../../../common/types/store-data/user-configuration-store'; import { StoreTester } from '../../../../common/store-tester'; +import { failTestOnErrorLogger } from 'tests/unit/common/fail-test-on-error-logger'; describe('UserConfigurationStoreTest', () => { let initialStoreData: UserConfigurationStoreData; @@ -60,6 +61,7 @@ describe('UserConfigurationStoreTest', () => { initialStoreData, new UserConfigurationActions(), indexDbStrictMock.object, + failTestOnErrorLogger, ); expect(testSubject.getState()).toBeUndefined(); @@ -70,6 +72,7 @@ describe('UserConfigurationStoreTest', () => { null, new UserConfigurationActions(), indexDbStrictMock.object, + failTestOnErrorLogger, ); testSubject.initialize(); @@ -82,6 +85,7 @@ describe('UserConfigurationStoreTest', () => { cloneDeep(initialStoreData), new UserConfigurationActions(), indexDbStrictMock.object, + failTestOnErrorLogger, ); testSubject.initialize(); @@ -108,6 +112,7 @@ describe('UserConfigurationStoreTest', () => { persisted as UserConfigurationStoreData, new UserConfigurationActions(), indexDbStrictMock.object, + failTestOnErrorLogger, ); testSubject.initialize(); @@ -120,6 +125,7 @@ describe('UserConfigurationStoreTest', () => { null, new UserConfigurationActions(), indexDbStrictMock.object, + failTestOnErrorLogger, ); testSubject.initialize(); @@ -135,6 +141,7 @@ describe('UserConfigurationStoreTest', () => { cloneDeep(initialStoreData), new UserConfigurationActions(), indexDbStrictMock.object, + failTestOnErrorLogger, ); const firstCallDefaultState = testSubject.getDefaultState(); @@ -150,6 +157,7 @@ describe('UserConfigurationStoreTest', () => { null, new UserConfigurationActions(), indexDbStrictMock.object, + failTestOnErrorLogger, ); const firstCallDefaultState = testSubject.getDefaultState(); @@ -165,6 +173,7 @@ describe('UserConfigurationStoreTest', () => { initialStoreData, new UserConfigurationActions(), indexDbStrictMock.object, + failTestOnErrorLogger, ); expect(testSubject.getId()).toBe(StoreNames[StoreNames.UserConfigurationStore]); @@ -512,7 +521,12 @@ describe('UserConfigurationStoreTest', () => { actionName: keyof UserConfigurationActions, ): StoreTester { const factory = (actions: UserConfigurationActions) => - new UserConfigurationStore(initialStoreData, actions, indexDbStrictMock.object); + new UserConfigurationStore( + initialStoreData, + actions, + indexDbStrictMock.object, + failTestOnErrorLogger, + ); return new StoreTester(UserConfigurationActions, actionName, factory); } diff --git a/src/tests/unit/tests/background/tab-context-factory.test.ts b/src/tests/unit/tests/background/tab-context-factory.test.ts index 79d119a47b0..dcfeb203e1f 100644 --- a/src/tests/unit/tests/background/tab-context-factory.test.ts +++ b/src/tests/unit/tests/background/tab-context-factory.test.ts @@ -15,6 +15,7 @@ import { TargetTabController } from 'background/target-tab-controller'; import { TelemetryEventHandler } from 'background/telemetry/telemetry-event-handler'; import { Logger } from 'common/logging/logger'; import { NotificationCreator } from 'common/notification-creator'; +import { WindowUtils } from 'common/window-utils'; import { IMock, It, Mock, MockBehavior, Times } from 'typemoq'; import { UnifiedScanResultStore } from '../../../../background/stores/unified-scan-result-store'; import { UsageLogger } from '../../../../background/usage-logger'; @@ -37,6 +38,7 @@ describe('TabContextFactoryTest', () => { let mockLogger: IMock; let mockUsageLogger: IMock; let mockNotificationCreator: IMock; + let mockWindowUtils: IMock; beforeEach(() => { mockBrowserAdapter = Mock.ofType(); @@ -44,6 +46,7 @@ describe('TabContextFactoryTest', () => { mockUsageLogger = Mock.ofType(); mockDetailsViewController = Mock.ofType(); mockNotificationCreator = Mock.ofType(); + mockWindowUtils = Mock.ofType(); }); it('createInterpreter', () => { @@ -98,6 +101,7 @@ describe('TabContextFactoryTest', () => { promiseFactoryMock.object, mockLogger.object, mockUsageLogger.object, + mockWindowUtils.object, ); const tabContext = testObject.createTabContext( diff --git a/src/tests/unit/tests/injected/analyzers/analyzer-provider.test.ts b/src/tests/unit/tests/injected/analyzers/analyzer-provider.test.ts index 3c0139cd2f4..ab90134c0c0 100644 --- a/src/tests/unit/tests/injected/analyzers/analyzer-provider.test.ts +++ b/src/tests/unit/tests/injected/analyzers/analyzer-provider.test.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import { ScopingStore } from 'background/stores/global/scoping-store'; import { ScanIncompleteWarningDetector } from 'injected/scan-incomplete-warning-detector'; +import { failTestOnErrorLogger } from 'tests/unit/common/fail-test-on-error-logger'; import { IMock, Mock } from 'typemoq'; import { VisualizationConfigurationFactory } from '../../../../../common/configs/visualization-configuration-factory'; @@ -69,6 +70,7 @@ describe('AnalyzerProviderTests', () => { sendConvertedResultsMock.object, sendNeedsReviewResultsMock.object, scanIncompleteWarningDetectorMock.object, + failTestOnErrorLogger, ); }); diff --git a/src/tests/unit/tests/injected/analyzers/base-analyzer.test.ts b/src/tests/unit/tests/injected/analyzers/base-analyzer.test.ts index 849af664fb6..8c537c7c990 100644 --- a/src/tests/unit/tests/injected/analyzers/base-analyzer.test.ts +++ b/src/tests/unit/tests/injected/analyzers/base-analyzer.test.ts @@ -8,6 +8,7 @@ import { VisualizationType } from 'common/types/visualization-type'; import { AnalyzerConfiguration } from 'injected/analyzers/analyzer'; import { BaseAnalyzer } from 'injected/analyzers/base-analyzer'; import { ScanIncompleteWarningDetector } from 'injected/scan-incomplete-warning-detector'; +import { failTestOnErrorLogger } from 'tests/unit/common/fail-test-on-error-logger'; describe('BaseAnalyzer', () => { let testSubject: BaseAnalyzer; @@ -29,6 +30,7 @@ describe('BaseAnalyzer', () => { configStub, sendMessageMock.object, scanIncompleteWarningDetectorMock.object, + failTestOnErrorLogger, ); }); diff --git a/src/tests/unit/tests/injected/analyzers/tab-stops-analyzer.test.ts b/src/tests/unit/tests/injected/analyzers/tab-stops-analyzer.test.ts index ccc4a5f86d0..e3e8c777662 100644 --- a/src/tests/unit/tests/injected/analyzers/tab-stops-analyzer.test.ts +++ b/src/tests/unit/tests/injected/analyzers/tab-stops-analyzer.test.ts @@ -1,18 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { ScanIncompleteWarningDetector } from 'injected/scan-incomplete-warning-detector'; import { IMock, It, Mock, MockBehavior, Times } from 'typemoq'; -import { Message } from '../../../../../common/message'; -import { VisualizationType } from '../../../../../common/types/visualization-type'; -import { WindowUtils } from '../../../../../common/window-utils'; -import { - FocusAnalyzerConfiguration, - ScanBasePayload, -} from '../../../../../injected/analyzers/analyzer'; -import { TabStopsAnalyzer } from '../../../../../injected/analyzers/tab-stops-analyzer'; -import { TabStopEvent, TabStopsListener } from '../../../../../injected/tab-stops-listener'; -import { itIsFunction } from '../../../common/it-is-function'; +import { Message } from 'common/message'; +import { VisualizationType } from 'common/types/visualization-type'; +import { WindowUtils } from 'common/window-utils'; +import { FocusAnalyzerConfiguration, ScanBasePayload } from 'injected/analyzers/analyzer'; +import { TabStopsAnalyzer } from 'injected/analyzers/tab-stops-analyzer'; +import { ScanIncompleteWarningDetector } from 'injected/scan-incomplete-warning-detector'; +import { TabStopEvent, TabStopsListener } from 'injected/tab-stops-listener'; +import { failTestOnErrorLogger } from 'tests/unit/common/fail-test-on-error-logger'; +import { itIsFunction } from 'tests/unit/common/it-is-function'; describe('TabStopsAnalyzer', () => { let windowUtilsMock: IMock; @@ -50,6 +48,7 @@ describe('TabStopsAnalyzer', () => { windowUtilsMock.object, sendMessageMock.object, scanIncompleteWarningDetectorMock.object, + failTestOnErrorLogger, ); typeStub = -1 as VisualizationType; }); diff --git a/src/tests/unit/tests/injected/frameCommunicators/frame-communicator.test.ts b/src/tests/unit/tests/injected/frameCommunicators/frame-communicator.test.ts index be6413041af..85b882338cc 100644 --- a/src/tests/unit/tests/injected/frameCommunicators/frame-communicator.test.ts +++ b/src/tests/unit/tests/injected/frameCommunicators/frame-communicator.test.ts @@ -19,7 +19,7 @@ import { QStub } from '../../../stubs/q-stub'; // These tests were written before we started enforcing no-floating-promises, and we've grandfathered in // their warnings because they pervasively use a Q-mocking strategy that consistently trips the check. -// tslint:disable:no-floating-promises +/* eslint-disable @typescript-eslint/no-floating-promises */ interface FrameInfo { frameElement: HTMLIFrameElement; From 299b9f0494dadd4d7719e10e81b4a39608f0cf3c Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Mon, 2 Nov 2020 18:41:56 -0500 Subject: [PATCH 2/8] fix rule-analyzer --- src/injected/analyzers/rule-analyzer.ts | 4 +++- src/tests/unit/tests/injected/analyzers/rule-analyzer.test.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/injected/analyzers/rule-analyzer.ts b/src/injected/analyzers/rule-analyzer.ts index 777d96dbe27..33ce4dfe95e 100644 --- a/src/injected/analyzers/rule-analyzer.ts +++ b/src/injected/analyzers/rule-analyzer.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. import { ScopingInputTypes } from 'background/scoping-input-types'; +import { Logger } from 'common/logging/logger'; import { ScanIncompleteWarningDetector } from 'injected/scan-incomplete-warning-detector'; import * as Q from 'q'; @@ -32,8 +33,9 @@ export class RuleAnalyzer extends BaseAnalyzer { protected readonly visualizationConfigFactory: VisualizationConfigurationFactory, private postOnResolve: PostResolveCallback, scanIncompleteWarningDetector: ScanIncompleteWarningDetector, + logger: Logger, ) { - super(config, sendMessageDelegate, scanIncompleteWarningDetector); + super(config, sendMessageDelegate, scanIncompleteWarningDetector, logger); } protected getResults = (): Q.Promise => { diff --git a/src/tests/unit/tests/injected/analyzers/rule-analyzer.test.ts b/src/tests/unit/tests/injected/analyzers/rule-analyzer.test.ts index ac98f00117e..40bd7cd6a6e 100644 --- a/src/tests/unit/tests/injected/analyzers/rule-analyzer.test.ts +++ b/src/tests/unit/tests/injected/analyzers/rule-analyzer.test.ts @@ -4,6 +4,7 @@ import { ScopingInputTypes } from 'background/scoping-input-types'; import { ScopingStore } from 'background/stores/global/scoping-store'; import { ScanIncompleteWarningDetector } from 'injected/scan-incomplete-warning-detector'; import { isFunction } from 'lodash'; +import { failTestOnErrorLogger } from 'tests/unit/common/fail-test-on-error-logger'; import { IMock, It, Mock, Times } from 'typemoq'; import { VisualizationConfiguration } from '../../../../../common/configs/visualization-configuration'; @@ -136,6 +137,7 @@ describe('RuleAnalyzer', () => { visualizationConfigurationFactoryMock.object, postResolveCallbackMock.object, scanIncompleteWarningDetectorMock.object, + failTestOnErrorLogger, ); const scanResults = createTestResults(); From 919d32eca5fbfa4f80371ce09c35cf25ab409731 Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Mon, 2 Nov 2020 18:42:31 -0500 Subject: [PATCH 3/8] Fix RuleAnalyzer usage --- src/injected/analyzers/analyzer-provider.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/injected/analyzers/analyzer-provider.ts b/src/injected/analyzers/analyzer-provider.ts index 6671618d9a3..c1d6da3deec 100644 --- a/src/injected/analyzers/analyzer-provider.ts +++ b/src/injected/analyzers/analyzer-provider.ts @@ -55,6 +55,7 @@ export class AnalyzerProvider { this.visualizationConfigFactory, null, this.scanIncompleteWarningDetector, + this.logger, ); } @@ -71,6 +72,7 @@ export class AnalyzerProvider { this.visualizationConfigFactory, this.sendConvertedResults, this.scanIncompleteWarningDetector, + this.logger, ); } @@ -87,6 +89,7 @@ export class AnalyzerProvider { this.visualizationConfigFactory, this.sendNeedsReviewResults, this.scanIncompleteWarningDetector, + this.logger, ); } From c952413812708ce657a3a5561b6ee3d5e4a25add Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Mon, 2 Nov 2020 19:07:37 -0500 Subject: [PATCH 4/8] Fix BatchedRuleAnalyzer --- src/injected/analyzers/batched-rule-analyzer.ts | 3 +++ .../tests/injected/analyzers/batched-rule-analyzer.test.ts | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/injected/analyzers/batched-rule-analyzer.ts b/src/injected/analyzers/batched-rule-analyzer.ts index 1fd85af80e0..94c488d1052 100644 --- a/src/injected/analyzers/batched-rule-analyzer.ts +++ b/src/injected/analyzers/batched-rule-analyzer.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +import { Logger } from 'common/logging/logger'; import { ScanIncompleteWarningDetector } from 'injected/scan-incomplete-warning-detector'; import { BaseStore } from '../../common/base-store'; @@ -26,6 +27,7 @@ export class BatchedRuleAnalyzer extends RuleAnalyzer { protected readonly visualizationConfigFactory: VisualizationConfigurationFactory, private postScanFilter: IResultRuleFilter, scanIncompleteWarningDetector: ScanIncompleteWarningDetector, + logger: Logger, ) { super( config, @@ -37,6 +39,7 @@ export class BatchedRuleAnalyzer extends RuleAnalyzer { visualizationConfigFactory, null, scanIncompleteWarningDetector, + logger, ); BatchedRuleAnalyzer.batchConfigs.push(config); } diff --git a/src/tests/unit/tests/injected/analyzers/batched-rule-analyzer.test.ts b/src/tests/unit/tests/injected/analyzers/batched-rule-analyzer.test.ts index e76bed5d9e6..c1457895f86 100644 --- a/src/tests/unit/tests/injected/analyzers/batched-rule-analyzer.test.ts +++ b/src/tests/unit/tests/injected/analyzers/batched-rule-analyzer.test.ts @@ -4,6 +4,7 @@ import { ScopingInputTypes } from 'background/scoping-input-types'; import { ScopingStore } from 'background/stores/global/scoping-store'; import { ScanIncompleteWarningDetector } from 'injected/scan-incomplete-warning-detector'; import { clone, isFunction } from 'lodash'; +import { failTestOnErrorLogger } from 'tests/unit/common/fail-test-on-error-logger'; import { IMock, It, Mock, MockBehavior, Times } from 'typemoq'; import { VisualizationConfiguration } from '../../../../../common/configs/visualization-configuration'; @@ -292,6 +293,7 @@ describe('BatchedRuleAnalyzer', () => { visualizationConfigurationFactoryMock.object, resultConfigFilterMock.object, scanIncompleteWarningDetectorMock.object, + failTestOnErrorLogger, ); } }); From b79f05c61677cdf6d139017f7d6ecdd8617cac8a Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Mon, 2 Nov 2020 19:07:53 -0500 Subject: [PATCH 5/8] Fix BatchedRuleAnalyzer usage --- src/injected/analyzers/analyzer-provider.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/injected/analyzers/analyzer-provider.ts b/src/injected/analyzers/analyzer-provider.ts index c1d6da3deec..a3a668973da 100644 --- a/src/injected/analyzers/analyzer-provider.ts +++ b/src/injected/analyzers/analyzer-provider.ts @@ -104,6 +104,7 @@ export class AnalyzerProvider { this.visualizationConfigFactory, this.filterResultsByRules, this.scanIncompleteWarningDetector, + this.logger, ); } From 98d8de3c9260c33dae17aac16af6f6f78ae8683e Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Mon, 2 Nov 2020 19:10:14 -0500 Subject: [PATCH 6/8] fix assessment store tests --- .../unit/tests/background/stores/assessment-store.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tests/unit/tests/background/stores/assessment-store.test.ts b/src/tests/unit/tests/background/stores/assessment-store.test.ts index b0b8eb66506..f0a562917b2 100644 --- a/src/tests/unit/tests/background/stores/assessment-store.test.ts +++ b/src/tests/unit/tests/background/stores/assessment-store.test.ts @@ -50,6 +50,7 @@ import { import { TabStopEvent } from 'injected/tab-stops-listener'; import { cloneDeep, isFunction } from 'lodash'; import { ScanResults } from 'scanner/iruleresults'; +import { failTestOnErrorLogger } from 'tests/unit/common/fail-test-on-error-logger'; import { IMock, It, Mock, MockBehavior, Times } from 'typemoq'; import { DictionaryStringTo } from 'types/common-types'; import { AssessmentDataBuilder } from '../../../common/assessment-data-builder'; @@ -130,6 +131,7 @@ describe('AssessmentStore', () => { null, null, initialAssessmentStoreDataGeneratorMock.object, + failTestOnErrorLogger, ); const actualState = testObject.getDefaultState(); @@ -224,6 +226,7 @@ describe('AssessmentStore', () => { null, persisted, initialAssessmentStoreDataGeneratorMock.object, + failTestOnErrorLogger, ); const actualState = testObject.getDefaultState(); @@ -1981,6 +1984,7 @@ describe('AssessmentStore', () => { indexDBInstanceMock.object, null, initialAssessmentStoreDataGeneratorMock.object, + failTestOnErrorLogger, ); return new AssessmentStoreTester( AssessmentActions, From 77b9ee6c1e2014c33e5b8c77cb434de3cbcf4fad Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Mon, 2 Nov 2020 19:12:26 -0500 Subject: [PATCH 7/8] Fix user config store tests --- .../stores/global/user-configuration-store.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tests/unit/tests/background/stores/global/user-configuration-store.test.ts b/src/tests/unit/tests/background/stores/global/user-configuration-store.test.ts index 674d0353378..b215f4c9782 100644 --- a/src/tests/unit/tests/background/stores/global/user-configuration-store.test.ts +++ b/src/tests/unit/tests/background/stores/global/user-configuration-store.test.ts @@ -224,6 +224,7 @@ describe('UserConfigurationStoreTest', () => { .setup(i => i.setItem(IndexedDBDataKeys.userConfiguration, It.isValue(expectedState)), ) + .returns(() => Promise.resolve(true)) .verifiable(Times.once()); storeTester @@ -279,6 +280,7 @@ describe('UserConfigurationStoreTest', () => { .setup(i => i.setItem(IndexedDBDataKeys.userConfiguration, It.isValue(expectedState)), ) + .returns(() => Promise.resolve(true)) .verifiable(Times.once()); storeTester @@ -334,6 +336,7 @@ describe('UserConfigurationStoreTest', () => { .setup(i => i.setItem(IndexedDBDataKeys.userConfiguration, It.isValue(expectedState)), ) + .returns(() => Promise.resolve(true)) .verifiable(Times.once()); storeTester @@ -373,6 +376,7 @@ describe('UserConfigurationStoreTest', () => { .setup(i => i.setItem(IndexedDBDataKeys.userConfiguration, It.isValue(expectedState)), ) + .returns(() => Promise.resolve(true)) .verifiable(Times.once()); storeTester @@ -419,6 +423,7 @@ describe('UserConfigurationStoreTest', () => { .setup(indexDb => indexDb.setItem(IndexedDBDataKeys.userConfiguration, It.isValue(expectedState)), ) + .returns(() => Promise.resolve(true)) .verifiable(Times.once()); storeTester @@ -448,6 +453,7 @@ describe('UserConfigurationStoreTest', () => { .setup(indexDb => indexDb.setItem(IndexedDBDataKeys.userConfiguration, It.isValue(expectedState)), ) + .returns(() => Promise.resolve(true)) .verifiable(Times.once()); storeTester @@ -468,6 +474,7 @@ describe('UserConfigurationStoreTest', () => { .setup(indexDb => indexDb.setItem(IndexedDBDataKeys.userConfiguration, It.isValue(expectedState)), ) + .returns(() => Promise.resolve(true)) .verifiable(Times.once()); storeTester @@ -508,6 +515,7 @@ describe('UserConfigurationStoreTest', () => { .setup(i => i.setItem(IndexedDBDataKeys.userConfiguration, It.isValue(expectedState)), ) + .returns(() => Promise.resolve(true)) .verifiable(Times.once()); storeTester From 6a8fbe5d79fb6c6e449c90b807685e53452597b8 Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Tue, 3 Nov 2020 14:12:21 -0500 Subject: [PATCH 8/8] Switch fail for expect in failTestOnErrorLogger --- src/tests/unit/common/fail-test-on-error-logger.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tests/unit/common/fail-test-on-error-logger.ts b/src/tests/unit/common/fail-test-on-error-logger.ts index 24d75b83b5f..92fe3dbe35c 100644 --- a/src/tests/unit/common/fail-test-on-error-logger.ts +++ b/src/tests/unit/common/fail-test-on-error-logger.ts @@ -8,6 +8,8 @@ export const failTestOnErrorLogger: Logger = { // intentionally ignored }, error: (message?: string, ...optionalParams: any[]) => { - fail(`FailTestOnErrorLogger.error invoked with "${message}" ${inspect(optionalParams)}`); + expect( + `FailTestOnErrorLogger.error invoked with "${message}" ${inspect(optionalParams)}`, + ).toBe('FailTestOnErrorLogger.error never invoked'); }, };