Rocket.Chat.ReactNative/e2e/tests/assorted/04-setting.spec.ts

96 lines
3.1 KiB
TypeScript
Raw Normal View History

import { device, waitFor, element, by, expect } from 'detox';
2023-01-25 19:03:02 +00:00
import { navigateToLogin, login, platformTypes, TTextMatcher } from '../../helpers/app';
2023-02-22 17:46:16 +00:00
import { createRandomRoom, createRandomUser, ITestUser } from '../../helpers/data_setup';
2023-01-25 19:03:02 +00:00
describe('Settings screen', () => {
let alertButtonType: string;
let textMatcher: TTextMatcher;
2023-02-22 17:46:16 +00:00
let user: ITestUser;
2023-02-22 16:58:21 +00:00
let room: string;
2023-02-22 13:36:51 +00:00
2023-01-25 19:03:02 +00:00
beforeAll(async () => {
2023-02-22 13:36:51 +00:00
user = await createRandomUser();
2023-02-22 17:46:16 +00:00
({ name: room } = await createRandomRoom(user));
2023-01-25 19:03:02 +00:00
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
await navigateToLogin();
2023-02-22 13:36:51 +00:00
await login(user.username, user.password);
2023-01-25 19:03:02 +00:00
await waitFor(element(by.id('rooms-list-view')))
.toBeVisible()
.withTimeout(10000);
await element(by.id('rooms-list-view-sidebar')).tap();
await waitFor(element(by.id('sidebar-view')))
.toBeVisible()
.withTimeout(2000);
await waitFor(element(by.id('sidebar-settings')))
.toBeVisible()
.withTimeout(2000);
await element(by.id('sidebar-settings')).tap();
await waitFor(element(by.id('settings-view')))
.toBeVisible()
.withTimeout(2000);
});
describe('Render', () => {
it('should have settings view', async () => {
await expect(element(by.id('settings-view'))).toBeVisible();
});
it('should have language', async () => {
await expect(element(by.id('settings-view-language'))).toExist();
});
it('should have review app', async () => {
await expect(element(by.id('settings-view-review-app'))).toExist();
});
it('should have share app', async () => {
await expect(element(by.id('settings-view-share-app'))).toExist();
});
it('should have default browser', async () => {
await expect(element(by.id('settings-view-default-browser'))).toExist();
});
it('should have theme', async () => {
await expect(element(by.id('settings-view-theme'))).toExist();
});
it('should have security and privacy', async () => {
await expect(element(by.id('settings-view-security-privacy'))).toExist();
});
it('should have licence', async () => {
await expect(element(by.id('settings-view-license'))).toExist();
});
it('should have version no', async () => {
await expect(element(by.id('settings-view-version'))).toExist();
});
it('should have server version', async () => {
await expect(element(by.id('settings-view-server-version'))).toExist();
});
});
describe('Usage', () => {
it('should tap clear cache and navigate to roomslistview', async () => {
await waitFor(element(by.id('settings-view')))
.toBeVisible()
.withTimeout(2000);
await element(by.id('settings-view-clear-cache')).tap();
await waitFor(element(by[textMatcher]('This will clear all your offline data.')))
.toExist()
.withTimeout(2000);
await element(by[textMatcher]('Clear').and(by.type(alertButtonType))).tap();
await waitFor(element(by.id('rooms-list-view')))
.toBeVisible()
.withTimeout(5000);
2023-02-22 16:58:21 +00:00
await waitFor(element(by.id(`rooms-list-view-item-${room}`)))
2023-01-25 19:03:02 +00:00
.toExist()
.withTimeout(10000);
});
});
});