Skip to content

Commit 9877f2f

Browse files
authored
Overhaul Tests + Errors for Avatar and Callout (#2423)
* Redid deprecated Button tests * Overhaul avatar tests * Overhaul Callout tests * Overhaul checkbox deprecated tests * Overhaul CheckboxV1 tests * Remove un-needed overrided method for Callout tests * Change files * Address comments and nits * Missed some changes * Re-did some of the checkbox page object methods * More nits * Address comments, add comments to funcs * Nits fixed * Fix errors not displaying for waiting methods on specs * More consistency across individual test names * Align test names for checkbox windows spec * Typo fix * Remove instances of '->' in test labels * Rephrase test names: action -> expectation format * Reduce scope of PR * Updating change message
1 parent 9fca6a2 commit 9877f2f

8 files changed

+79
-93
lines changed

apps/E2E/src/Avatar/consts.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,3 @@ export const AVATAR_ACCESSIBILITY_ROLE = 'link';
1010

1111
export const AVATAR_TEST_COMPONENT = 'AVATAR_TEST_COMPONENT';
1212
export const AVATAR_SECONDARY_TEST_COMPONENT = 'AVATAR_SECONDARY_TEST_COMPONENT';
13-
14-
export const ACCESSIBILITY_LABEL_ATTR = 'Name';
15-
export const ACCESSIBILITY_HINT_ATTRIBUTE = 'HelpText';
16-
export const ACCESSIBILITY_ROLE_ATTRIBUTE = 'ControlType';
17-
export const ACCESSIBILITY_ROLE_IMAGE = 'ControlType.Image';
18-
export const ACCESSIBILITY_ROLE_LINK = 'ControlType.HyperLink';

apps/E2E/src/Avatar/pages/AvatarPageObject.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,7 @@ import {
55
AVATAR_SECONDARY_TEST_COMPONENT,
66
} from '../consts';
77
import { BasePage, By } from '../../common/BasePage';
8-
9-
export const enum AvatarComponentSelector {
10-
PrimaryComponent, //this._primaryComponent
11-
SecondaryComponent, //this._secondaryComponent
12-
}
138
class AvatarPageObject extends BasePage {
14-
async getPrimaryComponentAttribute(attribute: string): Promise<string> {
15-
return await (await this._primaryComponent).getAttribute(attribute);
16-
}
17-
18-
async getSecondaryComponentAttribute(attribute: string): Promise<string> {
19-
return await (await this._secondaryComponent).getAttribute(attribute);
20-
}
21-
22-
async getAvatarAccessibilityLabel(componentSelector: AvatarComponentSelector): Promise<string> {
23-
return componentSelector == AvatarComponentSelector.SecondaryComponent
24-
? await (await this._secondaryComponent).getAttribute('Name')
25-
: await (await this._primaryComponent).getAttribute('Name');
26-
}
27-
28-
async getAvatarAccessibilityHint(componentSelector: AvatarComponentSelector): Promise<string> {
29-
return componentSelector == AvatarComponentSelector.SecondaryComponent
30-
? await (await this._secondaryComponent).getAttribute('HelpText')
31-
: await (await this._primaryComponent).getAttribute('HelpText');
32-
}
33-
34-
async getAvatarAccessibilityRole(componentSelector: AvatarComponentSelector): Promise<string> {
35-
return componentSelector == AvatarComponentSelector.SecondaryComponent
36-
? await (await this._secondaryComponent).getAttribute('ControlType')
37-
: await (await this._primaryComponent).getAttribute('ControlType');
38-
}
399
/*****************************************/
4010
/**************** Getters ****************/
4111
/*****************************************/
Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
import NavigateAppPage from '../../common/NavigateAppPage';
22
import AvatarPageObject from '../pages/AvatarPageObject';
3-
import { PAGE_TIMEOUT, BOOT_APP_TIMEOUT } from '../../common/consts';
4-
import {
5-
AVATAR_ACCESSIBILITY_LABEL,
6-
AVATAR_ACCESSIBILITY_LABEL_BY_NAME,
7-
AVATAR_ACCESSIBILITY_HINT,
8-
ACCESSIBILITY_LABEL_ATTR,
9-
ACCESSIBILITY_HINT_ATTRIBUTE,
10-
ACCESSIBILITY_ROLE_ATTRIBUTE,
11-
ACCESSIBILITY_ROLE_IMAGE,
12-
ACCESSIBILITY_ROLE_LINK,
13-
} from '../consts';
3+
import { PAGE_TIMEOUT, BOOT_APP_TIMEOUT, Attribute, LINK_A11Y_ROLE, IMAGE_A11Y_ROLE } from '../../common/consts';
4+
import { AVATAR_ACCESSIBILITY_LABEL, AVATAR_ACCESSIBILITY_LABEL_BY_NAME, AVATAR_ACCESSIBILITY_HINT } from '../consts';
145

156
// Before testing begins, allow up to 60 seconds for app to open
167
describe('Avatar Testing Initialization', function () {
@@ -34,30 +25,47 @@ describe('Avatar Accessibility Testing', () => {
3425
await AvatarPageObject.scrollToTestElement();
3526
});
3627

37-
it('Validate accessibilityLabel', async () => {
38-
await expect(await AvatarPageObject.getPrimaryComponentAttribute(ACCESSIBILITY_LABEL_ATTR)).toEqual(AVATAR_ACCESSIBILITY_LABEL);
28+
it('Set "accessibilityLabel" prop. Validate "accessibilityLabel" value propagates to "Name" element attribute.', async () => {
29+
await expect(
30+
await AvatarPageObject.compareAttribute(AvatarPageObject._primaryComponent, Attribute.AccessibilityLabel, AVATAR_ACCESSIBILITY_LABEL),
31+
).toBeTrue();
32+
3933
await expect(await AvatarPageObject.didAssertPopup()).toBeFalsy(AvatarPageObject.ERRORMESSAGE_ASSERT);
4034
});
4135

42-
it('Validate accessibilityLabel from `name` prop', async () => {
43-
await expect(await AvatarPageObject.getSecondaryComponentAttribute(ACCESSIBILITY_LABEL_ATTR)).toEqual(
44-
AVATAR_ACCESSIBILITY_LABEL_BY_NAME,
45-
);
36+
it('Set "name" prop without setting "accessibilityLabel". Validate "accessibilityLabel" value defaults to "{name}, available".', async () => {
37+
await expect(
38+
await AvatarPageObject.compareAttribute(
39+
AvatarPageObject._secondaryComponent,
40+
Attribute.AccessibilityLabel,
41+
AVATAR_ACCESSIBILITY_LABEL_BY_NAME,
42+
),
43+
).toBeTrue();
44+
4645
await expect(await AvatarPageObject.didAssertPopup()).toBeFalsy(AvatarPageObject.ERRORMESSAGE_ASSERT);
4746
});
4847

49-
it('Validate accessibilityHint', async () => {
50-
await expect(await AvatarPageObject.getPrimaryComponentAttribute(ACCESSIBILITY_HINT_ATTRIBUTE)).toEqual(AVATAR_ACCESSIBILITY_HINT);
48+
it('Set "accessibilityHint". Validate "accessibilityHint" value propagates to "HelpText" element attribute.', async () => {
49+
await expect(
50+
await AvatarPageObject.compareAttribute(AvatarPageObject._primaryComponent, Attribute.AccessibilityHint, AVATAR_ACCESSIBILITY_HINT),
51+
).toBeTrue();
52+
5153
await expect(await AvatarPageObject.didAssertPopup()).toBeFalsy(AvatarPageObject.ERRORMESSAGE_ASSERT);
5254
});
5355

54-
it('Validate accessibilityRole', async () => {
55-
await expect(await AvatarPageObject.getPrimaryComponentAttribute(ACCESSIBILITY_ROLE_ATTRIBUTE)).toEqual(ACCESSIBILITY_ROLE_LINK);
56+
it('Set "accessibilityRole" prop. Validate "accessibilityRole" value propagates to "ControlType" attribute.', async () => {
57+
await expect(
58+
await AvatarPageObject.compareAttribute(AvatarPageObject._primaryComponent, Attribute.AccessibilityRole, LINK_A11Y_ROLE),
59+
).toBeTrue();
60+
5661
await expect(await AvatarPageObject.didAssertPopup()).toBeFalsy(AvatarPageObject.ERRORMESSAGE_ASSERT);
5762
});
5863

59-
it('Validate default accessibilityRole', async () => {
60-
await expect(await AvatarPageObject.getSecondaryComponentAttribute(ACCESSIBILITY_ROLE_ATTRIBUTE)).toEqual(ACCESSIBILITY_ROLE_IMAGE);
64+
it('Do NOT set "accessibilityRole". Validate "accessibilityRole" value defaults to "Image" ControlType.', async () => {
65+
await expect(
66+
await AvatarPageObject.compareAttribute(AvatarPageObject._secondaryComponent, Attribute.AccessibilityRole, IMAGE_A11Y_ROLE),
67+
).toBeTrue();
68+
6169
await expect(await AvatarPageObject.didAssertPopup()).toBeFalsy(AvatarPageObject.ERRORMESSAGE_ASSERT);
6270
});
6371
});

apps/E2E/src/Callout/pages/CalloutPageObject.win.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,26 @@ class CalloutPageObject extends BasePage {
1010
/******************************************************************/
1111
/**************** UI Element Interaction Methods ******************/
1212
/******************************************************************/
13-
async didCalloutLoad(): Promise<boolean> {
13+
async isCalloutOpen(): Promise<boolean> {
1414
return await (await this._primaryComponent).isDisplayed();
1515
}
1616

17-
/* OVERRIDE: This must scroll to the button that opens the callout, not the callout (since it's not visible on load.) */
18-
async scrollToTestElement(): Promise<void> {
19-
// on win32, adding a blank value to an element automatically scrolls to it
20-
await (await this._buttonToOpenCallout).addValue('');
21-
}
22-
23-
async openCallout(): Promise<void> {
24-
await (await this._buttonToOpenCallout).click();
17+
// This both opens and waits for it to go in view
18+
async openCalloutAndWaitForLoad(): Promise<void> {
19+
if (!(await this.isCalloutOpen())) {
20+
await (await this._buttonToOpenCallout).click();
21+
await this.waitForCondition(
22+
async () => await this.isCalloutOpen(),
23+
'Clicked the button to open the Callout, but the Callout did not open correctly.',
24+
);
25+
}
2526
}
2627

2728
async closeCallout(): Promise<void> {
2829
// all we have to do is click outside the callout
2930
await (await this._testPage).click();
3031
}
3132

32-
async waitForCalloutComponentInView(timeout?: number): Promise<void> {
33-
await browser.waitUntil(
34-
async () => {
35-
return await this.didCalloutLoad();
36-
},
37-
{
38-
timeout: timeout ?? this.waitForUiEvent,
39-
},
40-
);
41-
}
42-
4333
/*****************************************/
4434
/**************** Getters ****************/
4535
/*****************************************/

apps/E2E/src/Callout/specs/Callout.spec.win.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import NavigateAppPage from '../../common/NavigateAppPage';
22
import CalloutPageObject from '../pages/CalloutPageObject.win';
33
import { CALLOUT_ACCESSIBILITY_LABEL } from '../consts';
4-
import { PAGE_TIMEOUT, BOOT_APP_TIMEOUT, CALLOUT_A11Y_ROLE } from '../../common/consts';
5-
import { ComponentSelector } from '../../common/BasePage';
4+
import { Attribute, PAGE_TIMEOUT, BOOT_APP_TIMEOUT, CALLOUT_A11Y_ROLE } from '../../common/consts';
65

76
// Before testing begins, allow up to 60 seconds for app to open
87
describe('Callout Testing Initialization', function () {
@@ -23,18 +22,27 @@ describe('Callout Testing Initialization', function () {
2322

2423
describe('Callout Accessibility Testing', () => {
2524
beforeAll(async () => {
26-
await CalloutPageObject.scrollToTestElement();
27-
await CalloutPageObject.openCallout();
28-
await CalloutPageObject.waitForCalloutComponentInView(PAGE_TIMEOUT);
25+
await CalloutPageObject.scrollToTestElement(await CalloutPageObject._buttonToOpenCallout);
26+
await CalloutPageObject.openCalloutAndWaitForLoad();
2927
});
3028

31-
it('Validate accessibilityRole is correct', async () => {
32-
await expect(await CalloutPageObject.getAccessibilityRole()).toEqual(CALLOUT_A11Y_ROLE);
29+
it('Validate "accessibilityRole" prop has correct value, propagates to "ControlType" element attribute.', async () => {
30+
await expect(
31+
await CalloutPageObject.compareAttribute(CalloutPageObject._primaryComponent, Attribute.AccessibilityRole, CALLOUT_A11Y_ROLE),
32+
).toBeTrue();
33+
3334
await expect(await CalloutPageObject.didAssertPopup()).toBeFalsy(CalloutPageObject.ERRORMESSAGE_ASSERT); // Ensure no asserts popped up
3435
});
3536

36-
it('Set accessibilityLabel', async () => {
37-
await expect(await CalloutPageObject.getAccessibilityLabel(ComponentSelector.Primary)).toEqual(CALLOUT_ACCESSIBILITY_LABEL);
37+
it('Set "accessibilityLabel" prop. Validate "accessibilityLabel" value propagates to "Name" element attribute.', async () => {
38+
await expect(
39+
await CalloutPageObject.compareAttribute(
40+
CalloutPageObject._primaryComponent,
41+
Attribute.AccessibilityLabel,
42+
CALLOUT_ACCESSIBILITY_LABEL,
43+
),
44+
).toBeTrue();
45+
3846
await expect(await CalloutPageObject.didAssertPopup()).toBeFalsy(CalloutPageObject.ERRORMESSAGE_ASSERT); // Ensure no asserts popped up
3947
});
4048

@@ -45,13 +53,12 @@ describe('Callout Accessibility Testing', () => {
4553

4654
describe('Callout Functional Testing', () => {
4755
beforeEach(async () => {
48-
await CalloutPageObject.scrollToTestElement();
49-
await CalloutPageObject.openCallout();
50-
await CalloutPageObject.waitForCalloutComponentInView(PAGE_TIMEOUT);
56+
await CalloutPageObject.scrollToTestElement(await CalloutPageObject._buttonToOpenCallout);
57+
await CalloutPageObject.openCalloutAndWaitForLoad();
5158
});
5259

53-
it('Open the callout and validate it loaded correctly (visible)', async () => {
54-
await expect(await CalloutPageObject.didCalloutLoad()).toBeTruthy();
60+
it('Open Callout by clicking a button. Validate that the Callout is displayed.', async () => {
61+
await expect(await CalloutPageObject.isCalloutOpen()).toBeTruthy('The callout failed to visibly display.');
5562
});
5663

5764
afterEach(async () => {

apps/E2E/src/common/consts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const ROOT_VIEW = 'Fluent_Tester_Root_View';
44
export const BUTTON_A11Y_ROLE = 'ControlType.Button';
55
export const CALLOUT_A11Y_ROLE = 'ControlType.Group';
66
export const CHECKBOX_A11Y_ROLE = 'ControlType.CheckBox';
7+
export const IMAGE_A11Y_ROLE = 'ControlType.Image';
78
export const LINK_A11Y_ROLE = 'ControlType.HyperLink';
89
export const MENUBUTTON_A11Y_ROLE = 'ControlType.Button';
910
export const MENU_A11Y_ROLE = 'ControlType.Menu';
@@ -19,6 +20,7 @@ export const BOOT_APP_TIMEOUT = 60000;
1920
export const PAGE_TIMEOUT = 15000;
2021

2122
export const enum Attribute {
23+
AccessibilityHint = 'HelpText',
2224
AccessibilityLabel = 'Name',
2325
AccessibilityRole = 'ControlType',
2426
ExpandCollapseState = 'ExpandCollapse.ExpandCollapseState',
@@ -31,6 +33,7 @@ export const enum Attribute {
3133
}
3234

3335
export const attributeToEnumName = {
36+
[Attribute.AccessibilityHint]: 'AccessibilityHint',
3437
[Attribute.AccessibilityLabel]: 'AccessibilityLabel',
3538
[Attribute.AccessibilityRole]: 'AccessibilityRole',
3639
[Attribute.ExpandCollapseState]: 'ExpandCollapseState',
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Clean up and overhaul Avatar and Callout tests with better errors and cleaner PageObjects",
4+
"packageName": "@fluentui-react-native/e2e-testing",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Clean up and overhaul Avatar and Callout tests with better errors and cleaner PageObjects",
4+
"packageName": "@fluentui-react-native/tester",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

0 commit comments

Comments
 (0)