-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c570a3
commit 1740ab8
Showing
4 changed files
with
48 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { sleep, untilDocumentReady } from '../../../utils/utils' | ||
import { isUndefined } from 'lodash-es' | ||
import { newPostEditorFocusAnchor, newPostEditorHasFocus, newPostEditorSelector } from './selector' | ||
import { equal } from '../../../utils/assert' | ||
|
||
export const getFocus = async () => { | ||
await untilDocumentReady() | ||
while (isUndefined(newPostEditorSelector().evaluate())) { | ||
await sleep(1000) | ||
} | ||
|
||
if (!hasFocus()) { | ||
try { | ||
const i = newPostEditorFocusAnchor().evaluate()! | ||
i.focus() | ||
} catch { | ||
await requestManualClick() | ||
} | ||
} | ||
|
||
equal(hasFocus(), true, 'Failed to get focus') | ||
} | ||
|
||
const hasFocus = () => !isUndefined(newPostEditorHasFocus().evaluate()) | ||
|
||
const requestManualClick = async () => { | ||
alert('Please manually select the post box') | ||
while (!hasFocus()) { | ||
await sleep(1000) | ||
} | ||
} | ||
|
||
export const getText = () => newPostEditorSelector().evaluate()!.innerText |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters