Skip to content

Conversation

@maciekstosio
Copy link
Contributor

@maciekstosio maciekstosio commented Apr 8, 2025

Description

This PR adds tests for #2809, #1589 and #2800.

Changes

The main assumption is to test all permutation of headerBackButtonMenuEnabled, headerBackButtonDisplayMode and content of button (default - taken from previous screen headerTitle, custom from headerBackTitle and styled when there are styles applied). I hope this will help us tracking regression as this part of the code is a bit confusing and caused us problem in the past.
Additionally there are added "custom" scenarios that test default default behavior with default text and custom text (if the back button changes it's appearance depending on available space and headerBackButtonDisplayMode specification).
The some of the last cases are set to failing, and this is known disparity reported in #2809, we plan to fix it soon after, but wonted to make sure we don't cause a regression.

Remark:
I did it in a way that after each test we're returning to the screen with all test cases for 2809, this is due to the fact that scrolling through list of all Test* takes a lot and reloading RN after each test would cause huge overhead. The downside of it is that if any of the test fails if will cascade fail all other.

Test code and steps to reproduce

You can run test with:

detox build --configuration ios.sim.debug
detox test --configuration ios.sim.debug e2e/issuesTests/Test2809.e2e.ts -l debug

Checklist

  • Ensured that CI passes

@maciekstosio maciekstosio marked this pull request as draft April 8, 2025 11:04
@maciekstosio maciekstosio marked this pull request as ready for review April 9, 2025 11:12
@maciekstosio maciekstosio changed the title [WIP] Add tests for header interactions (#2809) Add tests for header interactions Apr 9, 2025
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initiative is great. We definitely need this.

This looks very solid, I've just left few style-related remarks.

Great job.


describe('backButtonMenuEnabled: true', () => {
describe('backButtonDisplayMode: default', () => {
it('with default text', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('with default text', async () => {
it('default back title stays visible', async () => {

Just one note to all the tests - would be nice if the string in it better described our expectations regarding the test, so that it is more readable from terminal what the test does. I'm not claiming that my suggestion is even good, but would be nice to come up with something more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed in: d1c0127

Comment on lines 153 to 157
await element(by.text('DisabledDefaultCustomText')).tap();
await element(by.text('Open screen')).tap();
await expect(element(by.text('Custom'))).toBeVisible();
await expectBackButtonMenuToNotExistOnLabel('Custom'); // Check if backButtonMenu is disabled
await element(by.text('Pop to top')).tap(); // Go back
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be refactored out to a function with some parameters, right? We do not need to repeat it every single time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed in: d1c0127

});

// Custom
it('Default long back label should be truncated to generic by buckButtonDisplayMode', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These titles are very nice

@maciekstosio maciekstosio changed the title Add tests for header interactions feat(iOS, Fabric): add tests for header interactions Apr 10, 2025
@maciekstosio maciekstosio changed the title feat(iOS, Fabric): add tests for header interactions chore(iOS, Fabric): add tests for header interactions Apr 10, 2025
@maciekstosio maciekstosio requested a review from kkafar April 11, 2025 09:12
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

@maciekstosio maciekstosio merged commit 34591a8 into main Apr 11, 2025
5 checks passed
@maciekstosio maciekstosio deleted the @maciekstosio/Add-tests-for-header-interactions- branch April 11, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants