Skip to content

Commit 6e6f2cf

Browse files
committed
separate test to make it independent, adding cycle changes check test
1 parent 3d19908 commit 6e6f2cf

1 file changed

Lines changed: 47 additions & 4 deletions

File tree

FabricExample/e2e/single-feature-tests/tabs/test-tabs-tab-bar-layout-direction.e2e.ts

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect as jestExpect } from '@jest/globals';
22
import { device, expect, element, by } from 'detox';
3-
import type { AndroidElementAttributes, IosElementAttributes } from 'detox';
3+
import { AndroidElementAttributes, IosElementAttributes } from 'detox/detox';
44
import { selectSingleFeatureTestsScreen } from '../../e2e-utils';
55

66
type ElementAttributes = IosElementAttributes | AndroidElementAttributes;
@@ -34,6 +34,15 @@ async function selectDirection(direction: 'inherit' | 'rtl' | 'ltr') {
3434
`direction: ${direction}`,
3535
);
3636
}
37+
const expectTab1ToBeLeftOfTab2 = async (shouldBeLeft: boolean) => {
38+
const t1 = await getElementAttributes('tab-bar-item-1-label');
39+
const t2 = await getElementAttributes('tab-bar-item-2-label');
40+
if (shouldBeLeft) {
41+
jestExpect(t2.frame.x).toBeGreaterThan(t1.frame.x);
42+
} else {
43+
jestExpect(t1.frame.x).toBeGreaterThan(t2.frame.x);
44+
}
45+
};
3746

3847
describe('Tab Bar Layout Direction - system settings: LTR', () => {
3948
beforeEach(async () => {
@@ -86,6 +95,22 @@ describe('Tab Bar Layout Direction - system settings: LTR', () => {
8695
const tab2attrs = await getElementAttributes('tab-bar-item-2-label');
8796
jestExpect(tab2attrs.frame.x).toBeGreaterThan(tab1attrs.frame.x);
8897
});
98+
99+
it('cycle through inherit → rtl → ltr → rtl → inherit renders the tab bar in correct order', async () => {
100+
await selectDirection('inherit');
101+
await expectTab1ToBeLeftOfTab2(true);
102+
await selectDirection('rtl');
103+
await expectTab1ToBeLeftOfTab2(false);
104+
105+
await selectDirection('ltr');
106+
await expectTab1ToBeLeftOfTab2(true);
107+
108+
await selectDirection('rtl');
109+
await expectTab1ToBeLeftOfTab2(false);
110+
111+
await selectDirection('inherit');
112+
await expectTab1ToBeLeftOfTab2(true);
113+
});
89114
});
90115

91116
describe('Tab Bar Layout Direction - system settings: RTL', () => {
@@ -130,7 +155,10 @@ describe('Tab Bar Layout Direction - system settings: RTL', () => {
130155
'Tabs',
131156
'test-tabs-tab-bar-layout-direction',
132157
);
133-
await element(by.id('react-allow-rtl-picker')).tap();
158+
await element(by.id('react-force-rtl-picker')).multiTap(2);
159+
await expect(element(by.id('react-force-rtl-picker'))).toHaveLabel(
160+
'forceRTL: false',
161+
);
134162
await device.reloadReactNative();
135163
}
136164
});
@@ -165,7 +193,6 @@ describe('Tab Bar Layout Direction - system settings: RTL', () => {
165193
});
166194

167195
it('remains in RTL order when direction is explicitly set to rtl', async () => {
168-
await selectDirection('inherit');
169196
await selectDirection('rtl');
170197

171198
const tab1attrs = await getElementAttributes('tab-bar-item-1-label');
@@ -174,11 +201,27 @@ describe('Tab Bar Layout Direction - system settings: RTL', () => {
174201
});
175202

176203
it('overrides system RTL settings and renders the tab bar in LTR order', async () => {
177-
await selectDirection('inherit');
178204
await selectDirection('ltr');
179205

180206
const tab1attrs = await getElementAttributes('tab-bar-item-1-label');
181207
const tab2attrs = await getElementAttributes('tab-bar-item-2-label');
182208
jestExpect(tab2attrs.frame.x).toBeGreaterThan(tab1attrs.frame.x);
183209
});
210+
211+
it('cycle through inherit → ltr → rtl → ltr → inherit renders the tab bar in correct order', async () => {
212+
await selectDirection('inherit');
213+
await expectTab1ToBeLeftOfTab2(false);
214+
215+
await selectDirection('ltr');
216+
await expectTab1ToBeLeftOfTab2(true);
217+
218+
await selectDirection('rtl');
219+
await expectTab1ToBeLeftOfTab2(false);
220+
221+
await selectDirection('ltr');
222+
await expectTab1ToBeLeftOfTab2(true);
223+
224+
await selectDirection('inherit');
225+
await expectTab1ToBeLeftOfTab2(false);
226+
});
184227
});

0 commit comments

Comments
 (0)