diff --git a/app/components/channel_intro/channel_intro.js b/app/components/channel_intro/channel_intro.js index 0ceb3a0a9..a07024c4c 100644 --- a/app/components/channel_intro/channel_intro.js +++ b/app/components/channel_intro/channel_intro.js @@ -211,7 +211,10 @@ class ChannelIntro extends PureComponent { return ( - + {intl.formatMessage({ id: 'intro_messages.beginning', defaultMessage: 'Beginning of {name}', diff --git a/app/components/edit_channel_info/__snapshots__/edit_channel_info.test.js.snap b/app/components/edit_channel_info/__snapshots__/edit_channel_info.test.js.snap index 70fbc897d..24d83682f 100644 --- a/app/components/edit_channel_info/__snapshots__/edit_channel_info.test.js.snap +++ b/app/components/edit_channel_info/__snapshots__/edit_channel_info.test.js.snap @@ -17,6 +17,7 @@ exports[`EditChannelInfo should match snapshot 1`] = ` "flex": 1, } } + testID="edit_channel.scroll" > @@ -172,6 +174,7 @@ exports[`EditChannelInfo should match snapshot 1`] = ` }, ] } + testID="edit_channel.purpose.input" textAlignVertical="top" underlineColorAndroid="transparent" value="purpose" diff --git a/app/components/edit_channel_info/edit_channel_info.js b/app/components/edit_channel_info/edit_channel_info.js index fdee75e8a..b79da9302 100644 --- a/app/components/edit_channel_info/edit_channel_info.js +++ b/app/components/edit_channel_info/edit_channel_info.js @@ -241,6 +241,7 @@ export default class EditChannelInfo extends PureComponent { { + renderSectionAction = (styles, action, anchor, id) => { return ( - {action && this.renderSectionAction(styles, action, anchor)} + {action && this.renderSectionAction(styles, action, anchor, id)} ); diff --git a/app/screens/create_channel/create_channel.js b/app/screens/create_channel/create_channel.js index 014771ca9..bb1cc7b88 100644 --- a/app/screens/create_channel/create_channel.js +++ b/app/screens/create_channel/create_channel.js @@ -47,6 +47,7 @@ export default class CreateChannel extends PureComponent { id: 'create-channel', enabled: false, showAsAction: 'always', + testID: 'edit_channel.create.button', }; constructor(props, context) { diff --git a/app/screens/more_channels/more_channels.js b/app/screens/more_channels/more_channels.js index 25bd3f930..9c18ceaf8 100644 --- a/app/screens/more_channels/more_channels.js +++ b/app/screens/more_channels/more_channels.js @@ -84,6 +84,7 @@ export default class MoreChannels extends PureComponent { id: 'create-pub-channel', text: context.intl.formatMessage({id: 'mobile.create_channel', defaultMessage: 'Create'}), showAsAction: 'always', + testID: 'public_channels.create.button', }; this.leftButton = { diff --git a/detox/e2e/test/channels/create_public_channel.e2e.js b/detox/e2e/test/channels/create_public_channel.e2e.js new file mode 100644 index 000000000..a63ce1a8d --- /dev/null +++ b/detox/e2e/test/channels/create_public_channel.e2e.js @@ -0,0 +1,77 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +// ******************************************************************* +// - [#] indicates a test step (e.g. # Go to a screen) +// - [*] indicates an assertion (e.g. * Check the title) +// - Use element testID when selecting an element. Create one if none. +// ******************************************************************* + +import {toChannelScreen} from '@support/ui/screen'; +import jestExpect from 'expect'; + +import {Setup} from '@support/server_api'; + +describe('Channels', () => { + beforeAll(async () => { + const {user} = await Setup.apiInit(); + + await toChannelScreen(user); + }); + + it('MM-T3201 Create public channel', async () => { + // # Go to channel sidebar list + await element(by.id('channel_drawer.button')).tap(); + + // # Tap on + public channels + await element(by.id('action_button_sidebar.channels')).tap(); + + // * Expect a list of public channels, initially empty + await expect(element(by.text('No more channels to join'))).toBeVisible(); + + // # Tap to create new channel + await element(by.id('public_channels.create.button')).tap(); + + // * Expect a new screen to create a new public channel + await expect(element(by.text('New Public Channel'))).toBeVisible(); + + // # Fill data + await element(by.id('edit_channel.name.input')).typeText('a'); + await attemptToTapButton('edit_channel.create.button'); + + // * Expect to be in the same screen since the channel name must be longer + await expect(element(by.id('edit_channel.name.input'))).toBeVisible(); + + await element(by.id('edit_channel.name.input')).typeText('bc'); + await element(by.id('edit_channel.purpose.input')).typeText('This sentence has'); + await element(by.id('edit_channel.purpose.input')).tapReturnKey(); + await element(by.id('edit_channel.purpose.input')).typeText('multiple lines'); + await element(by.id('edit_channel.scroll')).scroll(200, 'down'); + await expect(element(by.id('edit_channel.header.input'))).toBeVisible(); + const expectedChannelHeader = 'I 🌮 love 🌮 tacos 🌮'; + await element(by.id('edit_channel.header.input')).replaceText(expectedChannelHeader); + + await element(by.id('edit_channel.create.button')).tap(); + + const expectedChannelName = 'abc'; + const expectedPurpose = 'This sentence has\nmultiple lines'; + + // * Expect a redirection to the created channel + await expect(element(by.id('channel_intro.beginning.text'))).toHaveText('Beginning of ' + expectedChannelName); + await element(by.id('channel.title.button')).tap(); + + // * Expect to see channel header and purpose in channel info + await expect(element(by.text(expectedChannelHeader))).toBeVisible(); + await expect(element(by.text(expectedPurpose))).toBeVisible(); + }); +}); + +async function attemptToTapButton(id) { + if (device.getPlatform() === 'ios') { + const attributes = await element(by.id(id)).getAttributes(); + jestExpect(attributes.visible).toEqual(true); + jestExpect(attributes.enabled).toEqual(false); + } else { + await element(by.id(id)).tap(); + } +}