Live location share - handle insufficient permissions in location sharing (PSG-610) (#9047)
* handle insufficient permissions in location sharing * reformat ternaries
This commit is contained in:
parent
c44c8ba654
commit
bda272dce4
4 changed files with 81 additions and 13 deletions
|
@ -41,6 +41,7 @@ import Modal from '../../../../src/Modal';
|
|||
import { DEFAULT_DURATION_MS } from '../../../../src/components/views/location/LiveDurationDropdown';
|
||||
import { OwnBeaconStore } from '../../../../src/stores/OwnBeaconStore';
|
||||
import { SettingLevel } from '../../../../src/settings/SettingLevel';
|
||||
import QuestionDialog from '../../../../src/components/views/dialogs/QuestionDialog';
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
||||
|
@ -417,7 +418,7 @@ describe('<LocationShareMenu />', () => {
|
|||
}));
|
||||
});
|
||||
|
||||
it('opens error dialog when beacon creation fails ', async () => {
|
||||
it('opens error dialog when beacon creation fails', async () => {
|
||||
// stub logger to keep console clean from expected error
|
||||
const logSpy = jest.spyOn(logger, 'error').mockReturnValue(undefined);
|
||||
const error = new Error('oh no');
|
||||
|
@ -438,7 +439,41 @@ describe('<LocationShareMenu />', () => {
|
|||
await flushPromisesWithFakeTimers();
|
||||
|
||||
expect(logSpy).toHaveBeenCalledWith("We couldn't start sharing your live location", error);
|
||||
expect(mocked(Modal).createDialog).toHaveBeenCalled();
|
||||
expect(mocked(Modal).createDialog).toHaveBeenCalledWith(QuestionDialog, expect.objectContaining({
|
||||
button: 'Try again',
|
||||
description: 'Element could not send your location. Please try again later.',
|
||||
title: `We couldn't send your location`,
|
||||
cancelButton: 'Cancel',
|
||||
}));
|
||||
});
|
||||
|
||||
it('opens error dialog when beacon creation fails with permission error', async () => {
|
||||
// stub logger to keep console clean from expected error
|
||||
const logSpy = jest.spyOn(logger, 'error').mockReturnValue(undefined);
|
||||
const error = { errcode: 'M_FORBIDDEN' } as unknown as Error;
|
||||
mockClient.unstable_createLiveBeacon.mockRejectedValue(error);
|
||||
const component = getComponent();
|
||||
|
||||
// advance to location picker
|
||||
setShareType(component, LocationShareType.Live);
|
||||
setLocation(component);
|
||||
|
||||
act(() => {
|
||||
getSubmitButton(component).at(0).simulate('click');
|
||||
component.setProps({});
|
||||
});
|
||||
|
||||
await flushPromisesWithFakeTimers();
|
||||
await flushPromisesWithFakeTimers();
|
||||
await flushPromisesWithFakeTimers();
|
||||
|
||||
expect(logSpy).toHaveBeenCalledWith("Insufficient permissions to start sharing your live location", error);
|
||||
expect(mocked(Modal).createDialog).toHaveBeenCalledWith(QuestionDialog, expect.objectContaining({
|
||||
button: 'OK',
|
||||
description: 'You need to have the right permissions in order to share locations in this room.',
|
||||
title: `You don't have permission to share locations`,
|
||||
hasCancelButton: false,
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue