Skip to content

Commit 6c3f626

Browse files
Split FocusZone E2E Tests (#3619)
* Adding resolutions to specific packages with security vulnerabilities * Remove * Adding whitespace * Revert * Removing unused file * Split focus zone tests into smaller, separate spec files * Change files
1 parent bc378f4 commit 6c3f626

File tree

3 files changed

+158
-118
lines changed

3 files changed

+158
-118
lines changed
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import { Attribute, AttributeValue, Keys } from '../../common/consts';
2+
import FocusZonePageObject from '../pages/FocusZonePageObject';
3+
4+
// Before testing begins, allow up to 60 seconds for app to open
5+
describe('FocusZone Testing Initialization', () => {
6+
it('Wait for app load', async () => {
7+
expect(await FocusZonePageObject.waitForInitialPageToDisplay()).toBeTrue();
8+
});
9+
10+
it('Click and navigate to FocusZone test page', async () => {
11+
/* Click on component button to navigate to test page */
12+
expect(await FocusZonePageObject.navigateToPageAndLoadTests()).toBeTrue();
13+
14+
/* Expand E2E section */
15+
expect(await FocusZonePageObject.enableE2ETesterMode()).toBeTrue();
16+
17+
await expect(await FocusZonePageObject.didAssertPopup())
18+
.withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT)
19+
.toBeFalsy(); // Ensure no asserts popped up
20+
});
21+
});
22+
23+
/* FocusZone Functional Testing
24+
*
25+
* Focuses on the directional aspect of FocusZone with arrow keys.
26+
*
27+
* */
28+
describe('FocusZone Functional Testing', () => {
29+
beforeEach(async () => {
30+
await FocusZonePageObject.scrollToTestElement();
31+
32+
await FocusZonePageObject.resetTest();
33+
});
34+
35+
it('Navigate bidirectional focuszone using arrow keys. Validate focus switches correctly.', async () => {
36+
// move to 2 with right arrow
37+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_RIGHT]);
38+
expect(
39+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
40+
).toBeTruthy();
41+
42+
// move to 3 with down arrow
43+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_DOWN]);
44+
expect(
45+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(3), Attribute.IsFocused, AttributeValue.true),
46+
).toBeTruthy();
47+
48+
expect(await FocusZonePageObject.didAssertPopup())
49+
.withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT)
50+
.toBeFalsy();
51+
});
52+
53+
it('Navigate horizontal focuszone using arrow keys. Validate focus switches correctly.', async () => {
54+
await FocusZonePageObject.configureGridFocusZone('SetDirection', 'horizontal');
55+
// move to 2 with right arrow
56+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_RIGHT]);
57+
expect(
58+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
59+
).toBeTruthy();
60+
61+
// down arrow shouldn't move focus
62+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_DOWN]);
63+
expect(
64+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
65+
).toBeTruthy();
66+
67+
// left arrow goes back
68+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(4), [Keys.ARROW_LEFT]);
69+
expect(
70+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(3), Attribute.IsFocused, AttributeValue.true),
71+
).toBeTruthy();
72+
73+
expect(await FocusZonePageObject.didAssertPopup())
74+
.withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT)
75+
.toBeFalsy();
76+
});
77+
78+
it('Navigates vertical focuszone using arrow keys. Validate focus switches correctly.', async () => {
79+
await FocusZonePageObject.configureGridFocusZone('SetDirection', 'vertical');
80+
81+
// move to 2 with down arrow
82+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_DOWN]);
83+
expect(
84+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
85+
).toBeTruthy();
86+
87+
// right arrow shouldn't move focus
88+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_RIGHT]);
89+
expect(
90+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
91+
).toBeTruthy();
92+
93+
// up arrow goes back
94+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(4), [Keys.ARROW_UP]);
95+
expect(
96+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(3), Attribute.IsFocused, AttributeValue.true),
97+
).toBeTruthy();
98+
99+
expect(await FocusZonePageObject.didAssertPopup())
100+
.withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT)
101+
.toBeFalsy();
102+
});
103+
104+
it('Navigates none-direction focuszone using arrow keys. Validate focus does not switch.', async () => {
105+
await FocusZonePageObject.configureGridFocusZone('SetDirection', 'none');
106+
107+
// none of these key commands should move
108+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_DOWN]);
109+
expect(
110+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
111+
).toBeTruthy();
112+
113+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_UP]);
114+
expect(
115+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
116+
).toBeTruthy();
117+
118+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_LEFT]);
119+
expect(
120+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
121+
).toBeTruthy();
122+
123+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_RIGHT]);
124+
expect(
125+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
126+
).toBeTruthy();
127+
128+
expect(await FocusZonePageObject.didAssertPopup())
129+
.withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT)
130+
.toBeFalsy();
131+
});
132+
133+
it('Navigates bi-directional focuszone with 2d navigation. Validate focus switches correctly.', async () => {
134+
await FocusZonePageObject.configureGridFocusZone('Set2DNavigation', true);
135+
136+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_DOWN]);
137+
expect(
138+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(4), Attribute.IsFocused, AttributeValue.true),
139+
).toBeTruthy();
140+
141+
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(4), [Keys.ARROW_RIGHT]);
142+
expect(
143+
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(5), Attribute.IsFocused, AttributeValue.true),
144+
).toBeTruthy();
145+
146+
expect(await FocusZonePageObject.didAssertPopup())
147+
.withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT)
148+
.toBeFalsy();
149+
});
150+
});

apps/E2E/src/FocusZone/specs/FocusZone.spec.win.ts renamed to apps/E2E/src/FocusZone/specs/FocusZone_Tab_CircNav.spec.win.ts

Lines changed: 1 addition & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ describe('FocusZone Testing Initialization', () => {
2222

2323
/* FocusZone Functional Testing
2424
*
25-
* This test validates that keyboard navigation using both arrow keys and
26-
* tab key works, even when modifying how the FocusZone functions.
25+
* These tests validate Circular Navigation, disabled FZ, and tab with/without default tabbable element.
2726
*
2827
* */
2928
describe('FocusZone Functional Testing', () => {
@@ -33,122 +32,6 @@ describe('FocusZone Functional Testing', () => {
3332
await FocusZonePageObject.resetTest();
3433
});
3534

36-
it('Navigate bidirectional focuszone using arrow keys. Validate focus switches correctly.', async () => {
37-
// move to 2 with right arrow
38-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_RIGHT]);
39-
expect(
40-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
41-
).toBeTruthy();
42-
43-
// move to 3 with down arrow
44-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_DOWN]);
45-
expect(
46-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(3), Attribute.IsFocused, AttributeValue.true),
47-
).toBeTruthy();
48-
49-
expect(await FocusZonePageObject.didAssertPopup())
50-
.withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT)
51-
.toBeFalsy();
52-
});
53-
54-
it('Navigate horizontal focuszone using arrow keys. Validate focus switches correctly.', async () => {
55-
await FocusZonePageObject.configureGridFocusZone('SetDirection', 'horizontal');
56-
// move to 2 with right arrow
57-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_RIGHT]);
58-
expect(
59-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
60-
).toBeTruthy();
61-
62-
// down arrow shouldn't move focus
63-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_DOWN]);
64-
expect(
65-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
66-
).toBeTruthy();
67-
68-
// left arrow goes back
69-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(4), [Keys.ARROW_LEFT]);
70-
expect(
71-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(3), Attribute.IsFocused, AttributeValue.true),
72-
).toBeTruthy();
73-
74-
expect(await FocusZonePageObject.didAssertPopup())
75-
.withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT)
76-
.toBeFalsy();
77-
});
78-
79-
it('Navigates vertical focuszone using arrow keys. Validate focus switches correctly.', async () => {
80-
await FocusZonePageObject.configureGridFocusZone('SetDirection', 'vertical');
81-
82-
// move to 2 with down arrow
83-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_DOWN]);
84-
expect(
85-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
86-
).toBeTruthy();
87-
88-
// right arrow shouldn't move focus
89-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_RIGHT]);
90-
expect(
91-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
92-
).toBeTruthy();
93-
94-
// up arrow goes back
95-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(4), [Keys.ARROW_UP]);
96-
expect(
97-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(3), Attribute.IsFocused, AttributeValue.true),
98-
).toBeTruthy();
99-
100-
expect(await FocusZonePageObject.didAssertPopup())
101-
.withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT)
102-
.toBeFalsy();
103-
});
104-
105-
it('Navigates none-direction focuszone using arrow keys. Validate focus does not switch.', async () => {
106-
await FocusZonePageObject.configureGridFocusZone('SetDirection', 'none');
107-
108-
// none of these key commands should move
109-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_DOWN]);
110-
expect(
111-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
112-
).toBeTruthy();
113-
114-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_UP]);
115-
expect(
116-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
117-
).toBeTruthy();
118-
119-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_LEFT]);
120-
expect(
121-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
122-
).toBeTruthy();
123-
124-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_RIGHT]);
125-
expect(
126-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true),
127-
).toBeTruthy();
128-
129-
expect(await FocusZonePageObject.didAssertPopup())
130-
.withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT)
131-
.toBeFalsy();
132-
});
133-
134-
it('Navigates bi-directional focuszone with 2d navigation. Validate focus switches correctly.', async () => {
135-
await FocusZonePageObject.configureGridFocusZone('Set2DNavigation', true);
136-
137-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_DOWN]);
138-
expect(
139-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(4), Attribute.IsFocused, AttributeValue.true),
140-
).toBeTruthy();
141-
142-
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(4), [Keys.ARROW_RIGHT]);
143-
expect(
144-
await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(5), Attribute.IsFocused, AttributeValue.true),
145-
).toBeTruthy();
146-
147-
expect(await FocusZonePageObject.didAssertPopup())
148-
.withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT)
149-
.toBeFalsy();
150-
});
151-
15235
it("Navigates focuszone with circular navigation off. Validate focus between start and end doesn't switch.", async () => {
15336
await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_LEFT]);
15437
expect(
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Split focus zone tests into smaller, separate spec files",
4+
"packageName": "@fluentui-react-native/e2e-testing",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

0 commit comments

Comments
 (0)