Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(null): strict null checks for UI package and deps #6226

Merged
merged 5 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type CardFooterInstanceActionButtonsDeps = {

export interface CardFooterInstanceActionButtonsProps {
deps: CardFooterInstanceActionButtonsDeps;
userConfigurationStoreData: UserConfigurationStoreData;
userConfigurationStoreData: UserConfigurationStoreData | null;
issueDetailsData: CreateIssueDetailsTextData;
kebabMenuAriaLabel?: string;
narrowModeStatus?: NarrowModeStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type CardFooterMenuItemsProps = {
fileIssueButtonRef: IRefObject<IButton> & IRefObject<IContextualMenuRenderItem>;
toastRef: React.RefObject<Toast>;
issueDetailsData: CreateIssueDetailsTextData;
userConfigurationStoreData: UserConfigurationStoreData;
userConfigurationStoreData: UserConfigurationStoreData | null;
onIssueFilingSettingsDialogDismissed: () => void;
deps: CardFooterMenuItemsDeps;
};
Expand Down Expand Up @@ -90,6 +90,11 @@ export class CardFooterMenuItemsBuilder {
cardsViewController,
} = deps;

if (userConfigurationStoreData == null) {
// Intentionally no-op; store data is still in flight from initial load
return;
}

const selectedBugFilingService = issueFilingServiceProvider.forKey(
userConfigurationStoreData.bugService,
);
Expand Down
4 changes: 2 additions & 2 deletions src/common/components/cards/collapsible-component-cards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import styles from './collapsible-component-cards.scss';
export const collapsibleButtonAutomationId = 'collapsible-component-cards-button';

export type CollapsibleComponentCardsDeps = {
setFocusVisibility: SetFocusVisibility;
setFocusVisibility?: SetFocusVisibility;
};

export interface CollapsibleComponentCardsProps {
Expand Down Expand Up @@ -59,7 +59,7 @@ const CollapsibleComponentCards = NamedFC<CollapsibleComponentCardsProps>(
}

const onClick = (event: React.MouseEvent<HTMLDivElement>) => {
if (event.nativeEvent.detail === 0) {
if (event.nativeEvent.detail === 0 && deps.setFocusVisibility != null) {
// 0 => keyboard event
deps.setFocusVisibility(true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/cards/instance-details-footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type InstanceDetailsFooterDeps = {
export type InstanceDetailsFooterProps = {
deps: InstanceDetailsFooterDeps;
result: CardResult;
userConfigurationStoreData: UserConfigurationStoreData;
userConfigurationStoreData: UserConfigurationStoreData | null;
targetAppInfo: TargetAppData;
rule: UnifiedRule;
narrowModeStatus?: NarrowModeStatus;
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/cards/instance-details-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type InstanceDetailsGroupDeps = {
export type InstanceDetailsGroupProps = {
deps: InstanceDetailsGroupDeps;
rule: CardRuleResult;
userConfigurationStoreData: UserConfigurationStoreData;
userConfigurationStoreData: UserConfigurationStoreData | null;
targetAppInfo: TargetAppData;
cardSelectionMessageCreator?: CardSelectionMessageCreator;
narrowModeStatus?: NarrowModeStatus;
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/cards/instance-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type InstanceDetailsProps = {
deps: InstanceDetailsDeps;
result: CardResult;
index: number;
userConfigurationStoreData: UserConfigurationStoreData;
userConfigurationStoreData: UserConfigurationStoreData | null;
targetAppInfo: TargetAppData;
rule: UnifiedRule;
cardSelectionMessageCreator?: CardSelectionMessageCreator;
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/cards/result-section-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type ResultSectionContentProps = {
results: CardRuleResult[];
outcomeType: InstanceOutcomeType;
fixInstructionProcessor?: FixInstructionProcessor;
userConfigurationStoreData: UserConfigurationStoreData;
userConfigurationStoreData: UserConfigurationStoreData | null;
targetAppInfo: TargetAppData;
visualHelperEnabled: boolean;
allCardsCollapsed: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/cards/rule-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type RuleContentDeps = InstanceDetailsGroupDeps & RuleResourcesDeps;
export type RuleContentProps = {
deps: RuleContentDeps;
rule: CardRuleResult;
userConfigurationStoreData: UserConfigurationStoreData;
userConfigurationStoreData: UserConfigurationStoreData | null;
targetAppInfo: TargetAppData;
cardSelectionMessageCreator?: CardSelectionMessageCreator;
narrowModeStatus?: NarrowModeStatus;
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/cards/rules-with-instances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type RulesWithInstancesProps = {
deps: RulesWithInstancesDeps;
rules: CardRuleResult[];
outcomeType: InstanceOutcomeType;
userConfigurationStoreData: UserConfigurationStoreData;
userConfigurationStoreData: UserConfigurationStoreData | null;
targetAppInfo: TargetAppData;
outcomeCounter: OutcomeCounter;
headingLevel: number;
Expand Down
12 changes: 10 additions & 2 deletions src/packages/accessibility-insights-ui/ui-factory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as React from 'react';
import { ContentView, ContentViewDeps } from 'views/content/content-view';
import { GuidanceTitle } from 'views/content/guidance-title';
import { createMarkup, MarkupDeps } from 'views/content/markup';
import { ClientStoresHub } from 'common/stores/client-stores-hub';

type UIOptions = {
applicationTitle: string;
Expand All @@ -17,6 +18,14 @@ type UIOptions = {
};

const nullCreator = () => {};
const nullStoresHub: ClientStoresHub<any> = {
stores: [],
addChangedListenerToAllStores: () => {},
removeChangedListenerFromAllStores: () => {},
hasStores: () => false,
hasStoreData: () => false,
getAllStoreData: () => null,
};

export const contentViewFactory = ({ applicationTitle, getNarrowModeThresholds }: UIOptions) => {
const contentViewDeps: ContentViewDeps = {
Expand All @@ -26,8 +35,7 @@ export const contentViewFactory = ({ applicationTitle, getNarrowModeThresholds }
storeActionMessageCreator: {
getAllStates: nullCreator,
},
storesHub: null,
storesActionCreator: null,
storesHub: nullStoresHub,
getNarrowModeThresholds,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export const CombinedReportFailedSection = NamedFC<CombinedReportFailedSectionPr
headingLevel={4}
/>
),
onExpandToggle: null,
onExpandToggle: () => {},
headingLevel: 3,
deps: null,
deps: {},
});

return <div className="result-section">{CollapsibleContent}</div>;
Expand Down
11 changes: 10 additions & 1 deletion src/tests/unit/common/tab-store-data-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ import { BaseDataBuilder } from './base-data-builder';
export class TabStoreDataBuilder extends BaseDataBuilder<TabStoreData> {
constructor() {
super();
this.data = new TabStore(null, null, null, null, null, null, null, null).getDefaultState();
this.data = new TabStore(
null!,
null!,
null!,
null!,
null!,
null!,
null!,
null!,
).getDefaultState();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ exports[`UIFactory exports ContentView 1`] = `
"storeActionMessageCreator": {
"getAllStates": [Function],
},
"storesActionCreator": null,
"storesHub": null,
"storesHub": {
"addChangedListenerToAllStores": [Function],
"getAllStoreData": [Function],
"hasStoreData": [Function],
"hasStores": [Function],
"removeChangedListenerFromAllStores": [Function],
"stores": [],
},
"textContent": {
"applicationTitle": "THE_APPLICATION_TITLE",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('CombinedReportFailedSection', () => {

const expectedCollapsibleControlProps: Partial<CollapsibleComponentCardsProps> = {
headingLevel: 3,
deps: null,
deps: {},
};

collapsibleControlMock
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.strictNullChecks.json
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@
"./src/reports/components/report-sections/body-section.tsx",
"./src/reports/components/report-sections/collapsible-script-provider.tsx",
"./src/reports/components/report-sections/collapsible-url-result-section.tsx",
"./src/reports/components/report-sections/combined-report-failed-section.tsx",
"./src/reports/components/report-sections/content-container.tsx",
"./src/reports/components/report-sections/failed-urls-section.tsx",
"./src/reports/components/report-sections/fast-pass-results-title-section.tsx",
Expand Down Expand Up @@ -529,6 +530,7 @@
"./src/tests/unit/common/simulated-browser-event.ts",
"./src/tests/unit/common/simulated-window.ts",
"./src/tests/unit/common/store-tester.ts",
"./src/tests/unit/common/tab-store-data-builder.ts",
"./src/tests/unit/common/test-document-creator.ts",
"./src/tests/unit/common/time-simulating-promise-factory.ts",
"./src/tests/unit/common/typemoq-helper.ts",
Expand Down Expand Up @@ -600,6 +602,7 @@
"src/injected/frameCommunicators/**/*",
"src/injected/styles/**/*",
"src/issue-filing/common/markup/**/*",
"src/packages/accessibility-insights-ui/**/*",
"src/popup/Styles/**/*",
"src/popup/actions/**/*",
"src/report-export/**/*",
Expand Down