This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MM-10569] Invite links won't work in mobile browser when the user is…
… asked if they want to download the app (#1919) * fixes issue with first-time mobile viewers being indirected to sign up page incorrectly get components under test fix eslint error and update snapshots * change onclick to use redirect url param instead of history.goBack()
- Loading branch information
1 parent
48d24bf
commit 5f6f5d5
Showing
7 changed files
with
326 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
tests/components/get_android_app/__snapshots__/get_android_app.test.jsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`components/GetAndroidApp should match snapshot 1`] = ` | ||
<div | ||
className="get-app get-android-app" | ||
> | ||
<h1 | ||
className="get-app__header" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Mattermost works best if you switch to our Android app" | ||
id="get_app.androidHeader" | ||
values={Object {}} | ||
/> | ||
</h1> | ||
<hr /> | ||
<div> | ||
<img | ||
className="get-android-app__icon" | ||
src="mockup.png" | ||
/> | ||
<div | ||
className="get-android-app__app-info" | ||
> | ||
<span | ||
className="get-android-app__app-name" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Mattermost for Android" | ||
id="get_app.androidAppName" | ||
values={Object {}} | ||
/> | ||
</span> | ||
<span | ||
className="get-android-app__app-creator" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Mattermost, Inc" | ||
id="get_app.mattermostInc" | ||
values={Object {}} | ||
/> | ||
</span> | ||
</div> | ||
</div> | ||
<a | ||
className="btn btn-primary get-android-app__app-store-link" | ||
href="https://about.mattermost.com/mattermost-android-app" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Continue" | ||
id="get_app.continue" | ||
values={Object {}} | ||
/> | ||
</a> | ||
<img | ||
className="get-app__screenshot" | ||
src="mockup.png" | ||
/> | ||
<span | ||
className="get-app__continue-with-browser" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Or {link}" | ||
id="get_app.continueWithBrowser" | ||
values={ | ||
Object { | ||
"link": <a | ||
className="get-android-app__continue" | ||
onClick={[Function]} | ||
> | ||
<FormattedMessage | ||
defaultMessage="continue with browser" | ||
id="get_app.continueWithBrowserLink" | ||
values={Object {}} | ||
/> | ||
</a>, | ||
} | ||
} | ||
/> | ||
</span> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React from 'react'; | ||
import {shallow} from 'enzyme'; | ||
|
||
import {mountWithIntl} from 'tests/helpers/intl-test-helper.jsx'; | ||
import GetAndroidApp from 'components/get_android_app/get_android_app.jsx'; | ||
|
||
jest.mock('images/favicon/android-chrome-192x192.png', () => 'favicon.png'); | ||
jest.mock('images/nexus-6p-mockup.png', () => 'mockup.png'); | ||
|
||
describe('components/GetAndroidApp', () => { | ||
test('should match snapshot', () => { | ||
const wrapper = shallow( | ||
<GetAndroidApp | ||
androidAppDownloadLink={'https://about.mattermost.com/mattermost-android-app'} | ||
/> | ||
); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
test('should contain the download link', () => { | ||
const wrapper = shallow( | ||
<GetAndroidApp | ||
androidAppDownloadLink={'https://about.mattermost.com/mattermost-android-app'} | ||
/> | ||
); | ||
|
||
const link = wrapper.find('.get-android-app__app-store-link'); | ||
expect(link.prop('href')).toEqual('https://about.mattermost.com/mattermost-android-app'); | ||
}); | ||
|
||
test('should redirect if the user chooses to stay in the browser. Redirect url param is present', () => { | ||
const push = jest.fn(); | ||
const wrapper = mountWithIntl( | ||
<GetAndroidApp | ||
androidAppDownloadLink={'https://about.mattermost.com/mattermost-android-app'} | ||
history={{push}} | ||
location={{search: '?redirect_to=last_page'}} | ||
/> | ||
); | ||
expect(push).not.toHaveBeenCalled(); | ||
|
||
const link = wrapper.find('.get-android-app__continue'); | ||
link.simulate('click'); | ||
expect(push).toHaveBeenCalledWith('last_page'); | ||
}); | ||
|
||
test('should redirect if the user chooses to stay in the browser. Redirect url param is not present', () => { | ||
const push = jest.fn(); | ||
const wrapper = mountWithIntl( | ||
<GetAndroidApp | ||
androidAppDownloadLink={'https://about.mattermost.com/mattermost-android-app'} | ||
history={{push}} | ||
location={{search: ''}} | ||
/> | ||
); | ||
expect(push).not.toHaveBeenCalled(); | ||
|
||
const link = wrapper.find('.get-android-app__continue'); | ||
link.simulate('click'); | ||
expect(push).toHaveBeenCalledWith('/'); | ||
}); | ||
}); |
72 changes: 72 additions & 0 deletions
72
tests/components/get_ios_app/__snapshots__/get_ios_app.test.jsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`components/GetIosApp should match snapshot 1`] = ` | ||
<div | ||
className="get-app get-ios-app" | ||
> | ||
<h1 | ||
className="get-app__header" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Mattermost works best if you switch to our iPhone app" | ||
id="get_app.iosHeader" | ||
values={Object {}} | ||
/> | ||
</h1> | ||
<hr /> | ||
<a | ||
className="get-ios-app__app-store-link" | ||
href="https://about.mattermost.com/mattermost-ios-app" | ||
rel="noopener noreferrer" | ||
> | ||
<img | ||
src="mockup.png" | ||
/> | ||
</a> | ||
<img | ||
className="get-app__screenshot" | ||
src="mockup.png" | ||
/> | ||
<h2 | ||
className="get-ios-app__already-have-it" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Already have it?" | ||
id="get_app.alreadyHaveIt" | ||
values={Object {}} | ||
/> | ||
</h2> | ||
<a | ||
className="btn btn-primary get-ios-app__open-mattermost" | ||
href="mattermost:https://" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Open Mattermost" | ||
id="get_app.openMattermost" | ||
values={Object {}} | ||
/> | ||
</a> | ||
<span | ||
className="get-app__continue-with-browser" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Or {link}" | ||
id="get_app.continueWithBrowser" | ||
values={ | ||
Object { | ||
"link": <a | ||
className="get-ios-app__continue" | ||
onClick={[Function]} | ||
> | ||
<FormattedMessage | ||
defaultMessage="continue with browser" | ||
id="get_app.continueWithBrowserLink" | ||
values={Object {}} | ||
/> | ||
</a>, | ||
} | ||
} | ||
/> | ||
</span> | ||
</div> | ||
`; |
Oops, something went wrong.