This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 831
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the state shown for call in rooms (#10833)
* Fix the state shown for call in rooms We split out a separate state for 'missed' separate to 'ended' which caused confusion as the state got set to this when it shouldn't have, so calls that wouldn't have been shown as missed were. Remove the csutom call state and just have the missed state as a variant of the ended state. Re-order the if clauses so they hit the right ones. Also don't pass the callState variable into renderContent() which is a class method and so has access to the same info anyway. * Fix test * i18n (reorder only) * Fix test * Fix types * Add test for legacy call event tile
- Loading branch information
Showing
5 changed files
with
163 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
test/components/views/messages/LegacyCallEvent-test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
Copyright 2023 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import { CallErrorCode, CallState } from "matrix-js-sdk/src/webrtc/call"; | ||
import { MatrixEvent } from "matrix-js-sdk/src/models/event"; | ||
|
||
import LegacyCallEvent from "../../../../src/components/views/messages/LegacyCallEvent"; | ||
import LegacyCallEventGrouper from "../../../../src/components/structures/LegacyCallEventGrouper"; | ||
|
||
const THEIR_USER_ID = "@them:here"; | ||
|
||
describe("LegacyCallEvent", () => { | ||
let callInviteEvent: Record<string, any>; | ||
let callEventGrouper: Record<string, any>; | ||
|
||
beforeEach(() => { | ||
callInviteEvent = { | ||
sender: { | ||
userId: THEIR_USER_ID, | ||
}, | ||
}; | ||
|
||
callEventGrouper = { | ||
addListener: jest.fn(), | ||
removeListener: jest.fn(), | ||
invite: jest.fn().mockReturnValue(callInviteEvent), | ||
}; | ||
}); | ||
|
||
const renderEvent = () => { | ||
render( | ||
<LegacyCallEvent | ||
mxEvent={callInviteEvent as unknown as MatrixEvent} | ||
callEventGrouper={callEventGrouper as unknown as LegacyCallEventGrouper} | ||
/>, | ||
); | ||
}; | ||
|
||
it("shows if the call was ended", () => { | ||
callEventGrouper.state = CallState.Ended; | ||
callEventGrouper.gotRejected = jest.fn().mockReturnValue(true); | ||
|
||
renderEvent(); | ||
|
||
screen.getByText("Call declined"); | ||
}); | ||
|
||
it("shows if the call was answered elsewhere", () => { | ||
callEventGrouper.state = CallState.Ended; | ||
callEventGrouper.hangupReason = CallErrorCode.AnsweredElsewhere; | ||
|
||
renderEvent(); | ||
|
||
screen.getByText("Answered elsewhere"); | ||
}); | ||
|
||
it("shows if the call was missed", () => { | ||
callEventGrouper.state = CallState.Ended; | ||
callEventGrouper.callWasMissed = jest.fn().mockReturnValue(true); | ||
|
||
renderEvent(); | ||
|
||
screen.getByText("Missed call"); | ||
}); | ||
|
||
it("shows if the call ended cleanly", () => { | ||
callEventGrouper.state = CallState.Ended; | ||
callEventGrouper.hangupReason = CallErrorCode.UserHangup; | ||
|
||
renderEvent(); | ||
|
||
screen.getByText("Call ended"); | ||
}); | ||
|
||
it("shows if the call is connecting", () => { | ||
callEventGrouper.state = CallState.Connecting; | ||
|
||
renderEvent(); | ||
|
||
screen.getByText("Connecting"); | ||
}); | ||
|
||
it("shows timer if the call is connected", () => { | ||
callEventGrouper.state = CallState.Connected; | ||
|
||
renderEvent(); | ||
|
||
screen.getByText("00:00"); | ||
}); | ||
}); |