From a0a6291db8e2be29c4ed13645c250201b4552b9d Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 29 Nov 2023 21:04:27 -0500 Subject: Update tests --- test/playwright/playwright-util.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/playwright/playwright-util.js') 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|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} + */ 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), -- cgit v1.2.3