Skip to content

Commit a315d56

Browse files
committed
PRO-13986 feat: add actions focus and blur for selectors
1 parent 96d5ef3 commit a315d56

4 files changed

Lines changed: 37 additions & 1 deletion

File tree

src/actions/blur.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {LogEventType} from '../constants/internal';
2+
import {log} from '../utils/log';
3+
4+
import type {Locator} from '@playwright/test';
5+
6+
import type {Selector} from '../types/internal';
7+
8+
type Options = Parameters<Locator['blur']>[0];
9+
10+
/**
11+
* Blur an element.
12+
*/
13+
export const blur = async (selector: Selector, options: Options = {}): Promise<void> => {
14+
log('Blur an element', {...options, selector}, LogEventType.InternalAction);
15+
16+
await selector.getPlaywrightLocator().blur(options);
17+
};

src/actions/focus.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {LogEventType} from '../constants/internal';
2+
import {log} from '../utils/log';
3+
4+
import type {Locator} from '@playwright/test';
5+
6+
import type {Selector} from '../types/internal';
7+
8+
type Options = Parameters<Locator['focus']>[0];
9+
10+
/**
11+
* Focuses an element.
12+
*/
13+
export const focus = async (selector: Selector, options: Options = {}): Promise<void> => {
14+
log('Focus an element', {...options, selector}, LogEventType.InternalAction);
15+
16+
await selector.getPlaywrightLocator().focus(options);
17+
};

src/actions/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ export {
66
assertSelectorInViewport,
77
assertUrlMatchRoute,
88
} from './asserts';
9+
export {blur} from './blur';
910
export {clearUpload} from './clearUpload';
1011
export {click} from './click';
1112
export {deleteCookies} from './deleteCookies';
1213
export {dispatchEvent} from './dispatchEvent';
1314
export {doubleClick} from './doubleClick';
1415
export {drag} from './drag';
1516
export {dragToElement} from './dragToElement';
17+
export {focus} from './focus';
1618
export {getBrowserConsoleMessages} from './getBrowserConsoleMessages';
1719
export {getBrowserJsErrors} from './getBrowserJsErrors';
1820
export {getCookies} from './getCookies';

src/utils/test/getTestFnAndReject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Return = Readonly<{onlog: Onlog; reject: RejectTestRun; testFnWithReject: T
2323

2424
/**
2525
* Get test function with execution timeout, idle timeout, reject and onlog functions,
26-
* by isSkipped flag, test function, runId, test execution timeout and test idle timeouts.
26+
* by `isSkipped` flag, test function, runId, test execution timeout and test idle timeouts.
2727
* @internal
2828
*/
2929
export const getTestFnAndReject = ({

0 commit comments

Comments
 (0)