mattermost-mobile/app/screens/integration_selector/selected_options/index.test.tsx
Christopher Poile 92bdb2847b
[MM-57486] [MM-58008] Calls: Mobile ringing for incoming calls (#7984)
* notification ringing, settings screen, native code patch, ringing mp3s

* i18n

* play preview on first press

* prevent playing from background (only affects Android) to match iOS beh

* stop ringing/vibration on entering background

* ring when coming back from background and new incoming call is present

* no push notification sound when it's a call; improve ringing

* move sounds to asset folder; copy on postinstall for android bundling

* make Ringtone type a string enum

* make Android ring async + await ring and stop; changes from PR comments

* missing fields after merge

* release lock on an exception

* cancel sample ringing when turning notifications off

* copy sound files for android build

* typo

* update snapshots

* testing if the problem is copying the mp3 files

* fix android mp3 assets when building for non-release

* add sounds to .gitignore

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2024-07-03 10:22:46 -04:00

125 lines
3.7 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Preferences, View as ViewConstants} from '@constants';
import {Ringtone} from '@constants/calls';
import {renderWithEverything} from '@test/intl-test-helper';
import TestHelper from '@test/test_helper';
import SelectedOptions from '.';
import type Database from '@nozbe/watermelondb/Database';
describe('components/integration_selector/selected_options', () => {
let database: Database;
beforeAll(async () => {
const server = await TestHelper.setupServerDatabase();
database = server.database;
});
it('should match snapshot for users', () => {
const userProfile: UserProfile = {
id: '1',
create_at: 1111,
update_at: 1111,
delete_at: 1111,
username: 'johndoe',
nickname: 'johndoe',
first_name: 'johndoe',
last_name: 'johndoe',
position: 'hacker',
roles: 'admin',
locale: 'en_US',
notify_props: {
channel: 'true',
comments: 'never',
desktop: 'all',
desktop_sound: 'true',
email: 'true',
first_name: 'true',
mention_keys: 'false',
highlight_keys: '',
push: 'mention',
push_status: 'ooo',
calls_desktop_sound: 'true',
calls_mobile_sound: '',
calls_notification_sound: Ringtone.Calm,
calls_mobile_notification_sound: '',
},
email: 'johndoe@me.com',
auth_service: 'dummy',
};
const wrapper = renderWithEverything(
<SelectedOptions
theme={Preferences.THEMES.denim}
selectedOptions={[userProfile]}
dataSource={ViewConstants.DATA_SOURCE_USERS}
onRemove={() => {
// noop
}}
/>,
{database},
);
expect(wrapper.toJSON()).toMatchSnapshot();
});
it('should match snapshot for channels', () => {
const channel: Channel = {
id: '1',
create_at: 1111,
update_at: 1111,
delete_at: 0,
team_id: 'my team',
type: 'O',
display_name: 'channel',
name: 'channel',
header: 'channel',
purpose: '',
last_post_at: 1,
total_msg_count: 1,
extra_update_at: 1,
creator_id: '1',
scheme_id: null,
group_constrained: null,
shared: true,
};
const wrapper = renderWithEverything(
<SelectedOptions
theme={Preferences.THEMES.denim}
selectedOptions={[channel]}
dataSource={ViewConstants.DATA_SOURCE_CHANNELS}
onRemove={() => {
// noop
}}
/>,
{database},
);
expect(wrapper.toJSON()).toMatchSnapshot();
});
it('should match snapshot for options', () => {
const myItem = {
value: '1',
text: 'my text',
};
const wrapper = renderWithEverything(
<SelectedOptions
theme={Preferences.THEMES.denim}
selectedOptions={[myItem]}
dataSource={ViewConstants.DATA_SOURCE_DYNAMIC}
onRemove={() => {
// noop
}}
/>,
{database},
);
expect(wrapper.toJSON()).toMatchSnapshot();
});
});