Conform more of the code base to strict null checking (#10147)
* Conform more of the code base to strict null checking * More strict fixes * More strict work * Fix missing optional type * Iterate
This commit is contained in:
parent
fa036a5080
commit
da7aa4055e
380 changed files with 682 additions and 694 deletions
|
@ -53,7 +53,7 @@ describe("NewRoomIntro", () => {
|
|||
describe("for a DM Room", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(DMRoomMap.shared(), "getUserIdForRoomId").mockReturnValue(userId);
|
||||
const room = new Room(roomId, client, client.getUserId());
|
||||
const room = new Room(roomId, client, client.getUserId()!);
|
||||
room.name = "test_room";
|
||||
renderNewRoomIntro(client, room);
|
||||
});
|
||||
|
@ -67,7 +67,7 @@ describe("NewRoomIntro", () => {
|
|||
describe("for a DM LocalRoom", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(DMRoomMap.shared(), "getUserIdForRoomId").mockReturnValue(userId);
|
||||
const localRoom = new LocalRoom(roomId, client, client.getUserId());
|
||||
const localRoom = new LocalRoom(roomId, client, client.getUserId()!);
|
||||
localRoom.name = "test_room";
|
||||
localRoom.targets.push(new DirectoryMember({ user_id: userId }));
|
||||
renderNewRoomIntro(client, localRoom);
|
||||
|
|
|
@ -61,7 +61,7 @@ const setupMainMenu = async (client: MatrixClient, testSpace: Room): Promise<Ren
|
|||
|
||||
expect(wrapper.container.textContent).toBe("Test Space");
|
||||
act(() => {
|
||||
wrapper.container.querySelector<HTMLElement>('[aria-label="Test Space menu"]').click();
|
||||
wrapper.container.querySelector<HTMLElement>('[aria-label="Test Space menu"]')?.click();
|
||||
});
|
||||
|
||||
return wrapper;
|
||||
|
@ -77,7 +77,7 @@ const setupPlusMenu = async (client: MatrixClient, testSpace: Room): Promise<Ren
|
|||
|
||||
expect(wrapper.container.textContent).toBe("Test Space");
|
||||
act(() => {
|
||||
wrapper.container.querySelector<HTMLElement>('[aria-label="Add"]').click();
|
||||
wrapper.container.querySelector<HTMLElement>('[aria-label="Add"]')?.click();
|
||||
});
|
||||
|
||||
return wrapper;
|
||||
|
@ -92,7 +92,7 @@ const checkMenuLabels = (items: NodeListOf<Element>, labelArray: Array<string>)
|
|||
expect(items).toHaveLength(labelArray.length);
|
||||
|
||||
const checkLabel = (item: Element, label: string) => {
|
||||
expect(item.querySelector(".mx_IconizedContextMenu_label").textContent).toBe(label);
|
||||
expect(item.querySelector(".mx_IconizedContextMenu_label")?.textContent).toBe(label);
|
||||
};
|
||||
|
||||
labelArray.forEach((label, index) => {
|
||||
|
|
|
@ -84,9 +84,9 @@ describe("<RoomPreviewBar />", () => {
|
|||
const getActions = (wrapper: RenderResult) =>
|
||||
wrapper.container.querySelector<HTMLDivElement>(".mx_RoomPreviewBar_actions");
|
||||
const getPrimaryActionButton = (wrapper: RenderResult) =>
|
||||
getActions(wrapper).querySelector(".mx_AccessibleButton_kind_primary");
|
||||
getActions(wrapper)?.querySelector(".mx_AccessibleButton_kind_primary");
|
||||
const getSecondaryActionButton = (wrapper: RenderResult) =>
|
||||
getActions(wrapper).querySelector(".mx_AccessibleButton_kind_secondary");
|
||||
getActions(wrapper)?.querySelector(".mx_AccessibleButton_kind_secondary");
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
|
@ -102,17 +102,17 @@ describe("<RoomPreviewBar />", () => {
|
|||
const component = getComponent({ joining: true });
|
||||
|
||||
expect(isSpinnerRendered(component)).toBeTruthy();
|
||||
expect(getMessage(component).textContent).toEqual("Joining …");
|
||||
expect(getMessage(component)?.textContent).toEqual("Joining …");
|
||||
});
|
||||
it("renders rejecting message", () => {
|
||||
const component = getComponent({ rejecting: true });
|
||||
expect(isSpinnerRendered(component)).toBeTruthy();
|
||||
expect(getMessage(component).textContent).toEqual("Rejecting invite …");
|
||||
expect(getMessage(component)?.textContent).toEqual("Rejecting invite …");
|
||||
});
|
||||
it("renders loading message", () => {
|
||||
const component = getComponent({ loading: true });
|
||||
expect(isSpinnerRendered(component)).toBeTruthy();
|
||||
expect(getMessage(component).textContent).toEqual("Loading …");
|
||||
expect(getMessage(component)?.textContent).toEqual("Loading …");
|
||||
});
|
||||
|
||||
it("renders not logged in message", () => {
|
||||
|
@ -120,7 +120,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
const component = getComponent({ loading: true });
|
||||
|
||||
expect(isSpinnerRendered(component)).toBeFalsy();
|
||||
expect(getMessage(component).textContent).toEqual("Join the conversation with an account");
|
||||
expect(getMessage(component)?.textContent).toEqual("Join the conversation with an account");
|
||||
});
|
||||
|
||||
it("should send room oob data to start login", async () => {
|
||||
|
@ -136,8 +136,8 @@ describe("<RoomPreviewBar />", () => {
|
|||
const dispatcherSpy = jest.fn();
|
||||
const dispatcherRef = defaultDispatcher.register(dispatcherSpy);
|
||||
|
||||
expect(getMessage(component).textContent).toEqual("Join the conversation with an account");
|
||||
fireEvent.click(getPrimaryActionButton(component));
|
||||
expect(getMessage(component)?.textContent).toEqual("Join the conversation with an account");
|
||||
fireEvent.click(getPrimaryActionButton(component)!);
|
||||
|
||||
await waitFor(() =>
|
||||
expect(dispatcherSpy).toHaveBeenCalledWith(
|
||||
|
@ -268,14 +268,14 @@ describe("<RoomPreviewBar />", () => {
|
|||
|
||||
it("joins room on primary button click", () => {
|
||||
const component = getComponent({ inviterName, room, onJoinClick, onRejectClick });
|
||||
fireEvent.click(getPrimaryActionButton(component));
|
||||
fireEvent.click(getPrimaryActionButton(component)!);
|
||||
|
||||
expect(onJoinClick).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("rejects invite on secondary button click", () => {
|
||||
const component = getComponent({ inviterName, room, onJoinClick, onRejectClick });
|
||||
fireEvent.click(getSecondaryActionButton(component));
|
||||
fireEvent.click(getSecondaryActionButton(component)!);
|
||||
|
||||
expect(onRejectClick).toHaveBeenCalled();
|
||||
});
|
||||
|
@ -331,7 +331,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
await new Promise(setImmediate);
|
||||
expect(getPrimaryActionButton(component)).toBeTruthy();
|
||||
expect(getSecondaryActionButton(component)).toBeFalsy();
|
||||
fireEvent.click(getPrimaryActionButton(component));
|
||||
fireEvent.click(getPrimaryActionButton(component)!);
|
||||
expect(onJoinClick).toHaveBeenCalled();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue