Skip to content

Commit aabbd8b

Browse files
committed
SearchBar enhancement e2e test and documentation
1 parent 25473fd commit aabbd8b

File tree

5 files changed

+51
-6
lines changed

5 files changed

+51
-6
lines changed

playground/e2e/SearchBar.test.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ describe.e2e(':ios: SearchBar', () => {
1616
await elementById(TestIDs.HIDE_SEARCH_BAR_BTN).tap();
1717
await expect(elementByTraits(['searchField'])).toBeNotVisible();
1818
});
19+
20+
it('find magnifying button in integrated placement and tap it', async () => {
21+
await elementById(TestIDs.TOGGLE_PLACEMENT_BTN).tap();
22+
await elementById(TestIDs.SHOW_SEARCH_BAR_BTN).tap();
23+
const searchButton = element(
24+
by.type('_UIButtonBarButton').and(by.label('Search')).withAncestor(by.type('UINavigationBar'))
25+
);
26+
await expect(searchButton).toBeVisible();
27+
await searchButton.tap();
28+
await expect(elementByTraits(['searchField'])).toBeVisible();
29+
});
1930
});
2031

2132
describe.e2e(':ios: SearchBar Modal', () => {
@@ -38,4 +49,16 @@ describe.e2e(':ios: SearchBar Modal', () => {
3849
await elementById(TestIDs.DISMISS_MODAL_TOPBAR_BTN).tap();
3950
await expect(elementById(TestIDs.OPTIONS_TAB)).toBeVisible();
4051
});
41-
});
52+
53+
it('find magnifying button in integrated placement and tap it', async () => {
54+
await elementById(TestIDs.TOGGLE_PLACEMENT_BTN).tap();
55+
await elementById(TestIDs.SHOW_SEARCH_BAR_BTN).tap();
56+
const searchButton = element(
57+
by.type('UISearchBarTextField').withAncestor(by.type('_UIFloatingBarContainerView'))
58+
);
59+
await expect(searchButton).toExist();
60+
await expect(element(by.type('_UISearchBarFieldEditor'))).not.toExist();
61+
await searchButton.tap();
62+
await expect(element(by.type('_UISearchBarFieldEditor'))).toExist();
63+
});
64+
});

playground/src/screens/SearchBar.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Button from '../components/Button';
66
import Navigation from '../services/Navigation';
77
import testIDs from '../testIDs';
88

9-
const { HIDE_TOP_BAR_BTN, SHOW_TOP_BAR_BTN, SHOW_SEARCH_BAR_BTN, HIDE_SEARCH_BAR_BTN, TOP_BAR } =
9+
const { HIDE_TOP_BAR_BTN, SHOW_TOP_BAR_BTN, SHOW_SEARCH_BAR_BTN, HIDE_SEARCH_BAR_BTN, TOP_BAR, TOGGLE_PLACEMENT_BTN } =
1010
testIDs;
1111

1212
interface Props extends NavigationProps { }
@@ -38,6 +38,7 @@ export default class SearchBar extends React.Component<Props> {
3838
<Button label="Show SearchBar" testID={SHOW_SEARCH_BAR_BTN} onPress={this.showSearchBar} />
3939
<Button
4040
label={`Toggle Placement (${this.state.placement})`}
41+
testID={TOGGLE_PLACEMENT_BTN}
4142
onPress={this.togglePlacement}
4243
/>
4344
</Root>
@@ -83,7 +84,13 @@ export default class SearchBar extends React.Component<Props> {
8384
Navigation.mergeOptions(this, {
8485
topBar: {
8586
searchBar: {
86-
visible: true,
87+
visible: false,
88+
},
89+
},
90+
});
91+
Navigation.mergeOptions(this, {
92+
topBar: {
93+
searchBar: {
8794
placement: newPlacement,
8895
},
8996
},

playground/src/screens/SearchBarModal.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import Root from '../components/Root';
55
import Navigation from '../services/Navigation';
66
import testIDs from '../testIDs';
77

8-
const { SHOW_SEARCH_BAR_BTN, HIDE_SEARCH_BAR_BTN, TOP_BAR } = testIDs;
8+
const { SHOW_SEARCH_BAR_BTN, HIDE_SEARCH_BAR_BTN, TOP_BAR, TOGGLE_PLACEMENT_BTN } = testIDs;
99

10-
interface Props extends NavigationProps {}
10+
interface Props extends NavigationProps { }
1111

1212
export default class SearchBarModal extends React.Component<Props> {
1313
static options() {
@@ -36,6 +36,7 @@ export default class SearchBarModal extends React.Component<Props> {
3636
<Button label="Show SearchBar" testID={SHOW_SEARCH_BAR_BTN} onPress={this.showSearchBar} />
3737
<Button
3838
label={`Toggle Placement (${this.state.placement})`}
39+
testID={TOGGLE_PLACEMENT_BTN}
3940
onPress={this.togglePlacement}
4041
/>
4142
</Root>
@@ -67,7 +68,13 @@ export default class SearchBarModal extends React.Component<Props> {
6768
Navigation.mergeOptions(this, {
6869
topBar: {
6970
searchBar: {
70-
visible: true,
71+
visible: false,
72+
},
73+
},
74+
});
75+
Navigation.mergeOptions(this, {
76+
topBar: {
77+
searchBar: {
7178
placement: newPlacement,
7279
},
7380
},

playground/src/testIDs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ const testIDs = {
218218
TOGGLE_REACT_DECLARED_MODAL: 'TOGGLE_REACT_DECLARED_MODAL',
219219
REPLACE_TAB_TEST_ID: 'REPLACE_TAB_TEST_ID',
220220
REPLACED_TAB: 'REPLACED_TAB',
221+
TOGGLE_PLACEMENT_BTN: 'TOGGLE_PLACEMENT_BTN',
221222
MOUNTED_SCREENS_TEXT: 'MOUNTED_SCREENS_TEXT',
222223
SCREEN_ROOT: 'SCREEN_ROOT',
223224
SCREEN_ROOT_LIST: 'SCREEN_ROOT_LIST',

website/docs/api/topBar-searchBar.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,10 @@ sidebar_label: Layout
5858
| Type | Required | Platform | Description |
5959
| ----------------------- | -------- | -------- | ----------------------------------------------------- |
6060
| string | No | iOS | The text value of "Cancel" button in the UISearchBar. |
61+
62+
## `placement`
63+
64+
| Type | Required | Platform | Description |
65+
| ----------------------- | -------- | -------- | --------------------------------------------------------------------------------------- |
66+
| string | No | iOS 26 | 'stacked' (default) or 'integrated' where 'integrated' is the new iOS 26 look and feel. |
67+

0 commit comments

Comments
 (0)