Live location sharing - render users own beacons in timeline (#8296)
* extract location markers into generic Marker Signed-off-by: Kerry Archibald <kerrya@element.io> * wrap marker in smartmarker Signed-off-by: Kerry Archibald <kerrya@element.io> * test smartmarker Signed-off-by: Kerry Archibald <kerrya@element.io> * working map in location body Signed-off-by: Kerry Archibald <kerrya@element.io> * remove skinned sdk Signed-off-by: Kerry Archibald <kerrya@element.io> * use new ZoomButtons in MLocationBody Signed-off-by: Kerry Archibald <kerrya@element.io> * test LocationViewDialog Signed-off-by: Kerry Archibald <kerrya@element.io> * update commentt Signed-off-by: Kerry Archibald <kerrya@element.io> * lint Signed-off-by: Kerry Archibald <kerrya@element.io> * lint Signed-off-by: Kerry Archibald <kerrya@element.io> * extract livetimeremaining into own component Signed-off-by: Kerry Archibald <kerrya@element.io> * extract more beacon state utils Signed-off-by: Kerry Archibald <kerrya@element.io> * update tests for roomlivesharewarning Signed-off-by: Kerry Archibald <kerrya@element.io> * add beacon map and status chin Signed-off-by: Kerry Archibald <kerrya@element.io> * add handling for bubbles Signed-off-by: Kerry Archibald <kerrya@element.io> * tests for BeaconBody Signed-off-by: Kerry Archibald <kerrya@element.io> * move displaystatus check up to mbeaconbody Signed-off-by: Kerry Archibald <kerrya@element.io> * test BeaconStatus Signed-off-by: Kerry Archibald <kerrya@element.io> * rename BeaconStatusChin -> BeaconStatus Signed-off-by: Kerry Archibald <kerrya@element.io> * make BeaconStatus generic Signed-off-by: Kerry Archibald <kerrya@element.io> * lint Signed-off-by: Kerry Archibald <kerrya@element.io> * adjust spinner size Signed-off-by: Kerry Archibald <kerrya@element.io> * lint Signed-off-by: Kerry Archibald <kerrya@element.io> * add static time remaining option to beacon status Signed-off-by: Kerry Archibald <kerrya@element.io> * render time differently for own beacon Signed-off-by: Kerry Archibald <kerrya@element.io> * use children to add actions to BeaconStatus Signed-off-by: Kerry Archibald <kerrya@element.io> * add OwnBeaconStatus wrapper with stop button Signed-off-by: Kerry Archibald <kerrya@element.io> * add error states for own beacon Signed-off-by: Kerry Archibald <kerrya@element.io> * test OwnBeaconStatus Signed-off-by: Kerry Archibald <kerrya@element.io> * move ownbeaconstatus to write dir Signed-off-by: Kerry Archibald <kerrya@element.io> * improve button styling Signed-off-by: Kerry Archibald <kerrya@element.io> * i18n Signed-off-by: Kerry Archibald <kerrya@element.io> * lint Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
parent
7a1a2c41d2
commit
1c215e2b71
11 changed files with 443 additions and 117 deletions
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { Beacon } from 'matrix-js-sdk/src/matrix';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
|
||||
import BeaconStatus from '../../../../src/components/views/beacon/BeaconStatus';
|
||||
import { BeaconDisplayStatus } from '../../../../src/components/views/beacon/displayStatus';
|
||||
|
@ -26,6 +25,7 @@ import { findByTestId, makeBeaconInfoEvent } from '../../../test-utils';
|
|||
describe('<BeaconStatus />', () => {
|
||||
const defaultProps = {
|
||||
displayStatus: BeaconDisplayStatus.Loading,
|
||||
label: 'test label',
|
||||
};
|
||||
const getComponent = (props = {}) =>
|
||||
mount(<BeaconStatus {...defaultProps} {...props} />);
|
||||
|
@ -40,28 +40,42 @@ describe('<BeaconStatus />', () => {
|
|||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders active state without stop buttons', () => {
|
||||
// mock for stable snapshot
|
||||
jest.spyOn(Date, 'now').mockReturnValue(123456789);
|
||||
const beacon = new Beacon(makeBeaconInfoEvent('@user:server', '!room:server', {}, '$1'));
|
||||
const component = getComponent({ beacon, displayStatus: BeaconDisplayStatus.Active });
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders active state with stop button', () => {
|
||||
const stopBeacon = jest.fn();
|
||||
const beacon = new Beacon(makeBeaconInfoEvent('@user:server', '!room:sever'));
|
||||
const component = getComponent({
|
||||
beacon,
|
||||
stopBeacon,
|
||||
displayStatus: BeaconDisplayStatus.Active,
|
||||
});
|
||||
expect(findByTestId(component, 'beacon-status-stop-beacon')).toMatchSnapshot();
|
||||
|
||||
act(() => {
|
||||
findByTestId(component, 'beacon-status-stop-beacon').at(0).simulate('click');
|
||||
describe('active state', () => {
|
||||
it('renders without children', () => {
|
||||
// mock for stable snapshot
|
||||
jest.spyOn(Date, 'now').mockReturnValue(123456789);
|
||||
const beacon = new Beacon(makeBeaconInfoEvent('@user:server', '!room:server', {}, '$1'));
|
||||
const component = getComponent({ beacon, displayStatus: BeaconDisplayStatus.Active });
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
expect(stopBeacon).toHaveBeenCalled();
|
||||
it('renders with children', () => {
|
||||
const beacon = new Beacon(makeBeaconInfoEvent('@user:server', '!room:sever'));
|
||||
const component = getComponent({
|
||||
beacon,
|
||||
children: <span data-test-id='test'>test</span>,
|
||||
displayStatus: BeaconDisplayStatus.Active,
|
||||
});
|
||||
expect(findByTestId(component, 'test-child')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders static remaining time when displayLiveTimeRemaining is falsy', () => {
|
||||
// mock for stable snapshot
|
||||
jest.spyOn(Date, 'now').mockReturnValue(123456789);
|
||||
const beacon = new Beacon(makeBeaconInfoEvent('@user:server', '!room:server', {}, '$1'));
|
||||
const component = getComponent({ beacon, displayStatus: BeaconDisplayStatus.Active });
|
||||
expect(component.text().includes('Live until 11:17')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('renders live time remaining when displayLiveTimeRemaining is truthy', () => {
|
||||
// mock for stable snapshot
|
||||
jest.spyOn(Date, 'now').mockReturnValue(123456789);
|
||||
const beacon = new Beacon(makeBeaconInfoEvent('@user:server', '!room:server', {}, '$1'));
|
||||
const component = getComponent({
|
||||
beacon, displayStatus: BeaconDisplayStatus.Active,
|
||||
displayLiveTimeRemaining: true,
|
||||
});
|
||||
expect(component.text().includes('1h left')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue