[TESTS] Add E2E tests to directory (#2964)
* [E2E TEST] Directory * Fix tests Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
ec5840c076
commit
45d0d4a5f0
|
@ -165,12 +165,12 @@ class DirectoryView extends React.Component {
|
||||||
<SearchBox
|
<SearchBox
|
||||||
onChangeText={this.onSearchChangeText}
|
onChangeText={this.onSearchChangeText}
|
||||||
onSubmitEditing={this.search}
|
onSubmitEditing={this.search}
|
||||||
testID='federation-view-search'
|
testID='directory-view-search'
|
||||||
/>
|
/>
|
||||||
<Touch
|
<Touch
|
||||||
onPress={this.toggleDropdown}
|
onPress={this.toggleDropdown}
|
||||||
style={styles.dropdownItemButton}
|
style={styles.dropdownItemButton}
|
||||||
testID='federation-view-create-channel'
|
testID='directory-view-dropdown'
|
||||||
theme={theme}
|
theme={theme}
|
||||||
>
|
>
|
||||||
<View style={[sharedStyles.separatorVertical, styles.toggleDropdownContainer, { borderColor: themes[theme].separatorColor }]}>
|
<View style={[sharedStyles.separatorVertical, styles.toggleDropdownContainer, { borderColor: themes[theme].separatorColor }]}>
|
||||||
|
@ -199,7 +199,7 @@ class DirectoryView extends React.Component {
|
||||||
title: item.name,
|
title: item.name,
|
||||||
onPress: () => this.onPressItem(item),
|
onPress: () => this.onPressItem(item),
|
||||||
baseUrl,
|
baseUrl,
|
||||||
testID: `federation-view-item-${ item.name }`,
|
testID: `directory-view-item-${ item.name }`.toLowerCase(),
|
||||||
style,
|
style,
|
||||||
user,
|
user,
|
||||||
theme,
|
theme,
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
const {
|
||||||
|
device, expect, element, by, waitFor
|
||||||
|
} = require('detox');
|
||||||
|
const data = require('../../data');
|
||||||
|
const { navigateToLogin, login, tapBack, sleep } = require('../../helpers/app');
|
||||||
|
|
||||||
|
const testuser = data.users.regular
|
||||||
|
|
||||||
|
async function navigateToRoom(search) {
|
||||||
|
await element(by.id('directory-view-search')).replaceText(search);
|
||||||
|
await waitFor(element(by.id(`directory-view-item-${ search }`))).toBeVisible().withTimeout(10000);
|
||||||
|
await sleep(300); // app takes some time to animate
|
||||||
|
await element(by.id(`directory-view-item-${ search }`)).tap();
|
||||||
|
await waitFor(element(by.id('room-view'))).toExist().withTimeout(5000);
|
||||||
|
await waitFor(element(by.id(`room-view-title-${ search }`))).toExist().withTimeout(5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Join room from directory', () => {
|
||||||
|
before(async() => {
|
||||||
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||||
|
await navigateToLogin();
|
||||||
|
await login(testuser.username, testuser.password);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Usage', async() => {
|
||||||
|
it('should tap directory', async() => {
|
||||||
|
await element(by.id('rooms-list-view-directory')).tap();
|
||||||
|
await waitFor(element(by.id('directory-view'))).toExist().withTimeout(2000);
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should search public channel and navigate', async() => {
|
||||||
|
await navigateToRoom(data.channels.detoxpublic.name);
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should back and tap directory', async() => {
|
||||||
|
await tapBack();
|
||||||
|
await element(by.id('rooms-list-view-directory')).tap();
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should search user and navigate', async() => {
|
||||||
|
await element(by.id('directory-view-dropdown')).tap();
|
||||||
|
await element(by.label('Users')).tap();
|
||||||
|
await element(by.label('Search by')).tap();
|
||||||
|
await navigateToRoom(data.users.alternate.username);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue