-
Notifications
You must be signed in to change notification settings - Fork 2.7k
'together' flag tabs loading webviews #8202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
bb4c086
fix for TOGETHER flag #8201
markdevocht 31f5d1a
Merge remote-tracking branch 'origin/master' into bugfix/TOGETHER-tab…
markdevocht 7fc4fcb
update
markdevocht 614c41d
webview test fix
markdevocht 9deb36f
android commit
markdevocht 47d7a4f
move tab button test to ButtonTab page
markdevocht 120bc43
update
markdevocht 40e4b3c
update
markdevocht d22ca6b
code alignment
markdevocht 8ad1c3e
test id update
markdevocht a1be48c
some more refactoring
markdevocht 356d6ff
clean up
markdevocht f41a9ab
first try with e2e test
markdevocht 654847c
test update
markdevocht 64ff54f
android test update
markdevocht 9e07165
update
markdevocht 53d4d31
better naming for units and classes
markdevocht b3ca7ca
update
markdevocht d6e920c
changes
markdevocht c48dee6
tab tap listener update
markdevocht da0a0fb
one class to rule them all
markdevocht 46fe1e3
clearing things up
markdevocht File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| const React = require('react'); | ||
|
|
||
| const WebView = (props) => React.createElement('WebView', props); | ||
|
|
||
| module.exports = { WebView }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -182,4 +182,4 @@ | |
| ] | ||
| ] | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,22 @@ | ||
| import Utils from './Utils'; | ||
| import TestIDs from '../src/testIDs'; | ||
|
|
||
| const { elementById, elementByLabel } = Utils; | ||
|
|
||
| describe.e2e(':ios: Tabs with Together flag', () => { | ||
| beforeEach(async () => { | ||
| await device.launchApp({ newInstance: true }); | ||
| await elementById(TestIDs.BOTTOM_TABS_BTN).tap(); | ||
| await expect(elementByLabel('First Tab')).toBeVisible(); | ||
| }); | ||
|
|
||
| it('should load all tabs when tabsAttachMode is together', async () => { | ||
| await elementById(TestIDs.TABS_TOGETHER_BTN).tap(); | ||
| await waitFor(element(by.text(/\d→\d→\d/))) | ||
| .toExist() | ||
| .withTimeout(5000); | ||
|
|
||
| await elementById(TestIDs.TABS_TOGETHER_DISMISS).tap(); | ||
| await expect(elementByLabel('First Tab')).toBeVisible(); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,111 @@ | ||
| import React from 'react'; | ||
| import { StyleSheet } from 'react-native'; | ||
| import { NavigationComponent, NavigationProps, Options } from 'react-native-navigation'; | ||
| import { WebView } from 'react-native-webview'; | ||
| import Navigation from '../services/Navigation'; | ||
| import Screens from './Screens'; | ||
| import testIDs from '../testIDs'; | ||
|
|
||
| const { TABS_TOGETHER_DISMISS } = testIDs; | ||
|
|
||
| const webViewLoadedOrder: number[] = []; | ||
| const listeners: Set<() => void> = new Set(); | ||
| const notifyListeners = () => listeners.forEach((fn) => fn()); | ||
|
|
||
| const baseOptions = (title: string): Options => ({ | ||
| topBar: { | ||
| title: { text: title }, | ||
| leftButtons: [ | ||
| { id: 'dismiss', testID: TABS_TOGETHER_DISMISS, icon: require('../../img/clear.png') }, | ||
| ], | ||
| }, | ||
| bottomTab: { | ||
| text: title, | ||
| icon: require('../../img/layouts.png'), | ||
| }, | ||
| }); | ||
|
|
||
| interface Props extends NavigationProps { | ||
| tabIndex: number; | ||
| } | ||
|
|
||
| interface State { | ||
| loadStartTimestamp: number | null; | ||
| } | ||
|
|
||
| class WebViewTab extends NavigationComponent<Props, State> { | ||
| state: State = { loadStartTimestamp: null }; | ||
|
|
||
| static options(passProps: Props): Options { | ||
| return baseOptions(`Tab ${passProps.tabIndex + 1}`); | ||
| } | ||
|
|
||
| constructor(props: Props) { | ||
| super(props); | ||
| Navigation.events().bindComponent(this); | ||
| } | ||
|
|
||
| navigationButtonPressed({ buttonId }: { buttonId: string }) { | ||
| if (buttonId === 'dismiss') { | ||
| Navigation.dismissModal('TogetherFlagTabTest'); | ||
| } | ||
| } | ||
|
|
||
| componentDidMount() { | ||
| const update = () => { | ||
| const text = webViewLoadedOrder.length > 0 ? webViewLoadedOrder.join('→') : '...'; | ||
| Navigation.mergeOptions(this.props.componentId, { | ||
| topBar: { | ||
| subtitle: { text }, | ||
| }, | ||
| }); | ||
| }; | ||
| listeners.add(update); | ||
| update(); | ||
| } | ||
|
|
||
| onLoadStart = () => { | ||
| if (!webViewLoadedOrder.includes(this.props.tabIndex)) { | ||
| webViewLoadedOrder.push(this.props.tabIndex); | ||
| this.setState({ loadStartTimestamp: Date.now() }); | ||
| notifyListeners(); | ||
| } | ||
| }; | ||
|
|
||
| render() { | ||
| const { loadStartTimestamp } = this.state; | ||
| const timeString = loadStartTimestamp | ||
| ? new Date(loadStartTimestamp).toLocaleTimeString('en-US', { | ||
| hour12: false, | ||
| hour: '2-digit', | ||
| minute: '2-digit', | ||
| second: '2-digit', | ||
| fractionalSecondDigits: 3, | ||
| }) | ||
| : 'loading...'; | ||
|
|
||
| return ( | ||
| <WebView | ||
| source={{ html: `<html><body><h1>Tab ${this.props.tabIndex + 1}: started loading at ${timeString}</h1></body></html>` }} | ||
| style={styles.webview} | ||
| onLoadStart={this.onLoadStart} | ||
| /> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export { WebViewTab }; | ||
|
|
||
| export const resetWebViewLoadedOrder = () => { | ||
| webViewLoadedOrder.length = 0; | ||
| }; | ||
|
|
||
| export const TAB_SCREENS = [ | ||
| { name: Screens.WebViewTab, tabIndex: 0 }, | ||
| { name: Screens.WebViewTab, tabIndex: 1 }, | ||
| { name: Screens.WebViewTab, tabIndex: 2 }, | ||
| ]; | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| webview: { flex: 1 }, | ||
| }); |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.