diff options
author | Darius Jahandarie <djahandarie@gmail.com> | 2023-12-06 03:53:16 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-06 03:53:16 +0000 |
commit | bd5bc1a5db29903bc098995cd9262c4576bf76af (patch) | |
tree | c9214189e0214480fcf6539ad1c6327aef6cbd1c /test/playwright/playwright-util.js | |
parent | fd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff) | |
parent | 23e6fb76319c9ed7c9bcdc3efba39bc5dd38f288 (diff) |
Merge pull request #339 from toasted-nutbread/type-annotations
Type annotations
Diffstat (limited to 'test/playwright/playwright-util.js')
-rw-r--r-- | test/playwright/playwright-util.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/playwright/playwright-util.js b/test/playwright/playwright-util.js index 5ceb92fd..ac68db4d 100644 --- a/test/playwright/playwright-util.js +++ b/test/playwright/playwright-util.js @@ -55,6 +55,7 @@ export const mockModelFieldNames = [ 'Sentence' ]; +/** @type {{[key: string]: string|undefined}} */ export const mockModelFieldsToAnkiValues = { 'Word': '{expression}', 'Reading': '{furigana-plain}', @@ -62,6 +63,10 @@ export const mockModelFieldsToAnkiValues = { 'Audio': '{audio}' }; +/** + * @param {import('playwright').Route} route + * @returns {Promise<void>|undefined} + */ export const mockAnkiRouteHandler = (route) => { const reqBody = route.request().postDataJSON(); const respBody = ankiRouteResponses[reqBody.action]; @@ -71,6 +76,11 @@ export const mockAnkiRouteHandler = (route) => { route.fulfill(respBody); }; +/** + * @param {import('playwright').Page} page + * @param {string} text + * @returns {Promise<void>} + */ export const writeToClipboardFromPage = async (page, text) => { await page.evaluate(`navigator.clipboard.writeText('${text}')`); }; @@ -100,6 +110,7 @@ const baseAnkiResp = { contentType: 'text/json' }; +/** @type {{[key: string]: import('core').SerializableObject}} */ const ankiRouteResponses = { 'version': Object.assign({body: JSON.stringify(6)}, baseAnkiResp), 'deckNames': Object.assign({body: JSON.stringify(['Mock Deck'])}, baseAnkiResp), |