-
-
Notifications
You must be signed in to change notification settings - Fork 599
chore(e2e): maintenance for automated tests after iOS 26.2 #3430
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
base: main
Are you sure you want to change the base?
Changes from all commits
cfbfc02
5615d4f
f672219
c73b277
e82c68e
803b1d3
2401b65
ea023c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,7 @@ yarn-error.log | |
|
|
||
| # testing | ||
| /coverage | ||
|
|
||
| # Yarn | ||
| .yarn/* | ||
| !.yarn/patches | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,43 +11,32 @@ const pressBack = async () => { | |
| }; | ||
|
|
||
| const awaitClassicalEventBehavior = async () => { | ||
| if (device.getPlatform() === 'ios') { | ||
| await expect( | ||
| element(by.text('9. Chats | transitionStart | closing')), | ||
| ).toExist(); | ||
| await expect( | ||
| element(by.text('10. Privacy | transitionStart | closing')), | ||
| ).toExist(); | ||
| await expect( | ||
| element(by.text('11. Main | transitionStart | opening')), | ||
| ).toExist(); | ||
| await expect( | ||
| element(by.text('12. Chats | transitionEnd | closing')), | ||
| ).toExist(); | ||
| await expect( | ||
| element(by.text('13. Privacy | transitionEnd | closing')), | ||
| ).toExist(); | ||
| await expect(element(by.text('14. Privacy | beforeRemove'))).toExist(); | ||
| await expect(element(by.text('15. Chats | beforeRemove'))).toExist(); | ||
| await expect( | ||
| element(by.text('16. Main | transitionEnd | opening')), | ||
| ).toExist(); | ||
| } else { | ||
| await expect(element(by.text('9. Privacy | beforeRemove'))).toExist(); | ||
| await expect(element(by.text('10. Chats | beforeRemove'))).toExist(); | ||
| await expect( | ||
| element(by.text('11. Main | transitionStart | opening')), | ||
| ).toExist(); | ||
| await expect( | ||
| element(by.text('12. Main | transitionEnd | opening')), | ||
| ).toExist(); | ||
| const expectedEvents = | ||
| device.getPlatform() === 'ios' | ||
| ? [ | ||
| '9. Chats | transitionStart | closing', | ||
| '10. Privacy | transitionStart | closing', | ||
| '11. Main | transitionStart | opening', | ||
| '12. Chats | transitionEnd | closing', | ||
| '13. Privacy | transitionEnd | closing', | ||
| '14. Privacy | beforeRemove', | ||
| '15. Chats | beforeRemove', | ||
| '16. Main | transitionEnd | opening', | ||
| ] | ||
| : [ | ||
| '9. Privacy | beforeRemove', | ||
| '10. Chats | beforeRemove', | ||
| '11. Main | transitionStart | opening', | ||
| '12. Main | transitionEnd | opening', | ||
| ]; | ||
| for (const expectedEventNotification of expectedEvents) { | ||
| await expect(element(by.text(expectedEventNotification))).toExist(); | ||
| } | ||
| }; | ||
|
|
||
| describe('Events', () => { | ||
| beforeEach(async () => { | ||
| await device.reloadReactNative(); | ||
| // await device.launchApp({ newInstance: true }); | ||
| await device.launchApp({ newInstance: true }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, and in every other place, where it has been done. |
||
|
|
||
| await waitFor(element(by.id('root-screen-playground-Events'))) | ||
| .toBeVisible() | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder about naming here. What are |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { device, element, by } from 'detox'; | ||
| import { getIOSVersion } from '../../../scripts/e2e/ios-devices.js'; | ||
| import semverSatisfies from 'semver/functions/satisfies'; | ||
| import semverCoerce from 'semver/functions/coerce'; | ||
|
|
||
| const IOS_BAR_BUTTON_TYPE = '_UIButtonBarButton'; | ||
| const backButtonElement = element(by.id('BackButton')); | ||
|
|
||
| export async function tapBarBackButton() { | ||
| const platform = device.getPlatform(); | ||
| if (platform === 'ios') { | ||
| return (await getIOSBackButton()).tap(); | ||
| } else if (platform === 'android') { | ||
| return backButtonElement.tap(); | ||
| } else throw new Error(`Platform "${platform}" not supported`); | ||
| } | ||
| async function getIOSBackButton() { | ||
| const iosVersion = semverCoerce(getIOSVersion().replace('iOS', ''))!; | ||
| if (semverSatisfies(iosVersion, '>=26.0')) { | ||
|
Comment on lines
+18
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if we need
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to save some time and several lines of code by adding the dev dependency, but I agree - it is an overkill and we can parse MAJOR.MINOR (or just bare MAJOR) oursevles. I don't have a strong opinion about it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @kkafar
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we don't need external dependency for this. Simple helper function is enough for that. Given what is going on with NPM & supply chain attacks recently -> lets avoid any unnecessary dependencies.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this function work only on iOS 26+? |
||
| const elementsByAttributes = | ||
| (await backButtonElement.getAttributes()) as unknown as { | ||
| elements: { className: string }[]; | ||
| }; | ||
|
Comment on lines
+21
to
+23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's the tough one.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I can use magic numbers alternatively (
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I see what you mean. I think the current version is all right then. |
||
| const elements = elementsByAttributes.elements; | ||
| if (Array.isArray(elements)) { | ||
| const uiBarButtonIndex = elements.findIndex( | ||
| elem => elem.className === IOS_BAR_BUTTON_TYPE, | ||
| ); | ||
| if (uiBarButtonIndex !== -1) { | ||
| return backButtonElement.atIndex(uiBarButtonIndex); | ||
| } | ||
KrzysztofWojnar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| return backButtonElement; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { getCommandLineResponse } from "react-native-screens/scripts/e2e/command-line-helpers"; | ||
| import { device } from 'detox'; | ||
|
|
||
| export function disableStylusPopupOnAndroid() { | ||
| if (device.getPlatform() === 'ios') return; | ||
| try { | ||
| getCommandLineResponse(`adb -s ${device.id} shell settings put secure stylus_handwriting_enabled 0`); | ||
| } catch { | ||
| console.warn('Failed to disable stylus setting.'); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import { device, expect, element, by } from 'detox'; | ||
| import { describeIfiOS, selectTestScreen } from '../e2e-utils'; | ||
| import { tapBarBackButton } from '../component-objects/back-button'; | ||
|
|
||
| // PR related to iOS search bar | ||
| describeIfiOS('Test2926', () => { | ||
|
|
@@ -26,7 +27,7 @@ describeIfiOS('Test2926', () => { | |
| await element(by.type('UISearchBarTextField')).replaceText('Item 2'); | ||
| await element(by.id('home-button-open-second')).tap(); | ||
|
|
||
| await element(by.id('BackButton')).tap(); | ||
| await tapBarBackButton(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an iOS only test. We have nice & clean way to detect a back button & tap it & we replace it with the complicated logic in |
||
|
|
||
| await expect(element(by.type('UISearchBarTextField'))).toBeVisible(); | ||
| await expect(element(by.type('UISearchBarTextField'))).toHaveText('Item 2'); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| { | ||
| "extends": "../tsconfig.json" | ||
| "extends": "../tsconfig.json", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| }, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question here. Why do we relaunch application instead of reloading RN? This was done mostly to save CI time IIRC, so it is a subject to be changed, but I need reasoning here.