Skip to content

Commit c624fd6

Browse files
authored
Add click tests for LinkV1 (#2437)
### Platforms Impacted - [ ] iOS - [ ] macOS - [ ] win32 (Office) - [ ] windows - [ ] android ### Description of changes Add E2E click tests for LinkV1 ### Verification CI will verify ### Pull request checklist This PR has considered (when applicable): - [x] Automated Tests - [ ] Documentation and examples - [ ] Keyboard Accessibility - [ ] Voiceover - [ ] Internationalization and Right-to-left Layouts
1 parent 0e49789 commit c624fd6

File tree

5 files changed

+61
-3
lines changed

5 files changed

+61
-3
lines changed

apps/E2E/src/LinkExperimental/pages/ExperimentalLinkPageObject.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ import {
77
import { BasePage, By } from '../../common/BasePage';
88

99
class ExperimentalLinkPageObject extends BasePage {
10+
/******************************************************************/
11+
/**************** UI Element Interaction Methods ******************/
12+
/******************************************************************/
13+
async didOnPressCallbackFire(errMsg: string): Promise<boolean> {
14+
const callbackText = await By(EXPERIMENTAL_LINK_NO_A11Y_LABEL_COMPONENT);
15+
await browser.waitUntil(async () => await callbackText.isDisplayed(), {
16+
timeout: this.waitForUiEvent,
17+
timeoutMsg: errMsg,
18+
interval: 1000,
19+
});
20+
21+
return await callbackText.isDisplayed();
22+
}
23+
1024
/*****************************************/
1125
/**************** Getters ****************/
1226
/*****************************************/

apps/E2E/src/LinkExperimental/specs/ExperimentalLink.spec.win.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import NavigateAppPage from '../../common/NavigateAppPage';
22
import ExperimentalLinkPageObject from '../pages/ExperimentalLinkPageObject';
33
import { EXPERIMENTAL_LINK_ACCESSIBILITY_LABEL } from '../consts';
4-
import { LINK_A11Y_ROLE, PAGE_TIMEOUT, BOOT_APP_TIMEOUT, Attribute } from '../../common/consts';
4+
import { LINK_A11Y_ROLE, PAGE_TIMEOUT, BOOT_APP_TIMEOUT, Attribute, Keys } from '../../common/consts';
55

66
// Before testing begins, allow up to 60 seconds for app to open
77
describe('Link Testing Initialization', function () {
@@ -21,6 +21,37 @@ describe('Link Testing Initialization', function () {
2121
});
2222
});
2323

24+
describe('Link Testing Functionality', function () {
25+
/* Scrolls and waits for the Link to be visible on the Test Page */
26+
beforeEach(async () => {
27+
await ExperimentalLinkPageObject.scrollToTestElement();
28+
});
29+
30+
it('Validate OnPress() callback was fired on a click', async () => {
31+
await ExperimentalLinkPageObject.click(ExperimentalLinkPageObject._secondaryComponent);
32+
await expect(
33+
await ExperimentalLinkPageObject.didOnPressCallbackFire(`The link failed to fire an onPress callback with a mouse click.`),
34+
).toBeTruthy();
35+
await expect(await ExperimentalLinkPageObject.didAssertPopup()).toBeFalsy(ExperimentalLinkPageObject.ERRORMESSAGE_ASSERT);
36+
});
37+
38+
it('Validate OnPress() callback was fired after hitting "Enter"', async () => {
39+
await ExperimentalLinkPageObject.sendKeys(ExperimentalLinkPageObject._secondaryComponent, [Keys.ENTER]);
40+
await expect(
41+
await ExperimentalLinkPageObject.didOnPressCallbackFire(`The link failed to fire an OnPress callback with an enter keypress.`),
42+
).toBeTruthy();
43+
await expect(await ExperimentalLinkPageObject.didAssertPopup()).toBeFalsy(ExperimentalLinkPageObject.ERRORMESSAGE_ASSERT);
44+
});
45+
46+
it('Validate OnPress() callback was fired after hitting "SPACE"', async () => {
47+
await ExperimentalLinkPageObject.sendKeys(ExperimentalLinkPageObject._secondaryComponent, [Keys.SPACE]);
48+
await expect(
49+
await ExperimentalLinkPageObject.didOnPressCallbackFire(`The link failed to fire an OnPress callback with a space keypress.`),
50+
).toBeTruthy();
51+
await expect(await ExperimentalLinkPageObject.didAssertPopup()).toBeFalsy(ExperimentalLinkPageObject.ERRORMESSAGE_ASSERT);
52+
});
53+
});
54+
2455
describe('Link Accessibility Testing', () => {
2556
beforeAll(async () => {
2657
await ExperimentalLinkPageObject.scrollToTestElement();

apps/fluent-tester/src/TestComponents/LinkExperimental/E2ELinkTest.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { Alert } from 'react-native';
32
import { LinkV1 as Link } from '@fluentui/react-native';
43
import { Stack } from '@fluentui-react-native/stack';
54
import { stackStyle } from '../Common/styles';
@@ -13,7 +12,7 @@ import { testProps } from '../Common/TestProps';
1312

1413
export const LinkE2ETest: React.FunctionComponent = () => {
1514
const doPress = (): void => {
16-
Alert.alert('Alert.', 'You have been alerted.');
15+
console.log('Link pressed');
1716
};
1817

1918
return (
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Add click tests",
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": "patch",
3+
"comment": "Update link callback",
4+
"packageName": "@fluentui-react-native/tester",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

0 commit comments

Comments
 (0)