Live location sharing: own live beacon status on maximised view (#8374)
* add floating own live sharing eacon status to maximised view Signed-off-by: Kerry Archibald <kerrya@element.io> * add tests for own beacon status Signed-off-by: Kerry Archibald <kerrya@element.io> * stylelint Signed-off-by: Kerry Archibald <kerrya@element.io> * remove huge snapshot Signed-off-by: Kerry Archibald <kerrya@element.io> * remove unused emits from test Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
parent
605fbd3e4e
commit
f2ec465f87
7 changed files with 175 additions and 16 deletions
|
@ -34,6 +34,8 @@ import {
|
|||
makeRoomWithStateEvents,
|
||||
} from '../../../test-utils';
|
||||
import { TILE_SERVER_WK_KEY } from '../../../../src/utils/WellKnownUtils';
|
||||
import { OwnBeaconStore } from '../../../../src/stores/OwnBeaconStore';
|
||||
import { BeaconDisplayStatus } from '../../../../src/components/views/beacon/displayStatus';
|
||||
|
||||
describe('<BeaconViewDialog />', () => {
|
||||
// 14.03.2022 16:15
|
||||
|
@ -50,9 +52,10 @@ describe('<BeaconViewDialog />', () => {
|
|||
getClientWellKnown: jest.fn().mockReturnValue({
|
||||
[TILE_SERVER_WK_KEY.name]: { map_style_url: 'maps.com' },
|
||||
}),
|
||||
getUserId: jest.fn().mockReturnValue(aliceId),
|
||||
getUserId: jest.fn().mockReturnValue(bobId),
|
||||
getRoom: jest.fn(),
|
||||
isGuest: jest.fn().mockReturnValue(false),
|
||||
getVisibleRooms: jest.fn().mockReturnValue([]),
|
||||
});
|
||||
|
||||
// make fresh rooms every time
|
||||
|
@ -83,6 +86,10 @@ describe('<BeaconViewDialog />', () => {
|
|||
const getComponent = (props = {}) =>
|
||||
mount(<BeaconViewDialog {...defaultProps} {...props} />);
|
||||
|
||||
beforeEach(() => {
|
||||
jest.spyOn(OwnBeaconStore.instance, 'getLiveBeaconIds').mockRestore();
|
||||
});
|
||||
|
||||
it('renders a map with markers', () => {
|
||||
const room = setupRoom([defaultEvent]);
|
||||
const beacon = room.currentState.beacons.get(getBeaconInfoIdentifier(defaultEvent));
|
||||
|
@ -95,6 +102,31 @@ describe('<BeaconViewDialog />', () => {
|
|||
expect(component.find('SmartMarker').length).toEqual(1);
|
||||
});
|
||||
|
||||
it('does not render any own beacon status when user is not live sharing', () => {
|
||||
// default event belongs to alice, we are bob
|
||||
const room = setupRoom([defaultEvent]);
|
||||
const beacon = room.currentState.beacons.get(getBeaconInfoIdentifier(defaultEvent));
|
||||
beacon.addLocations([location1]);
|
||||
const component = getComponent();
|
||||
expect(component.find('DialogOwnBeaconStatus').html()).toBeNull();
|
||||
});
|
||||
|
||||
it('renders own beacon status when user is live sharing', () => {
|
||||
// default event belongs to alice
|
||||
const room = setupRoom([defaultEvent]);
|
||||
const beacon = room.currentState.beacons.get(getBeaconInfoIdentifier(defaultEvent));
|
||||
beacon.addLocations([location1]);
|
||||
// mock own beacon store to show default event as alice's live beacon
|
||||
jest.spyOn(OwnBeaconStore.instance, 'getLiveBeaconIds').mockReturnValue([beacon.identifier]);
|
||||
jest.spyOn(OwnBeaconStore.instance, 'getBeaconById').mockReturnValue(beacon);
|
||||
const component = getComponent();
|
||||
expect(component.find('MemberAvatar').length).toBeTruthy();
|
||||
expect(component.find('OwnBeaconStatus').props()).toEqual({
|
||||
beacon, displayStatus: BeaconDisplayStatus.Active,
|
||||
className: 'mx_DialogOwnBeaconStatus_status',
|
||||
});
|
||||
});
|
||||
|
||||
it('updates markers on changes to beacons', () => {
|
||||
const room = setupRoom([defaultEvent]);
|
||||
const beacon = room.currentState.beacons.get(getBeaconInfoIdentifier(defaultEvent));
|
||||
|
|
|
@ -5,24 +5,13 @@ exports[`<OwnBeaconStatus /> renders without a beacon instance 1`] = `
|
|||
displayStatus="Loading"
|
||||
>
|
||||
<BeaconStatus
|
||||
className="mx_MBeaconBody_chin"
|
||||
displayLiveTimeRemaining={true}
|
||||
displayStatus="Loading"
|
||||
label="Live location enabled"
|
||||
withIcon={true}
|
||||
>
|
||||
<div
|
||||
className="mx_BeaconStatus mx_BeaconStatus_Loading mx_MBeaconBody_chin"
|
||||
className="mx_BeaconStatus mx_BeaconStatus_Loading"
|
||||
>
|
||||
<StyledLiveBeaconIcon
|
||||
className="mx_BeaconStatus_icon"
|
||||
isIdle={true}
|
||||
withError={false}
|
||||
>
|
||||
<div
|
||||
className="mx_StyledLiveBeaconIcon mx_BeaconStatus_icon mx_StyledLiveBeaconIcon_idle"
|
||||
/>
|
||||
</StyledLiveBeaconIcon>
|
||||
<div
|
||||
className="mx_BeaconStatus_description"
|
||||
>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue