aboutsummaryrefslogtreecommitdiff
path: root/test/playwright/playwright-util.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-29 21:04:27 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-29 21:04:27 -0500
commita0a6291db8e2be29c4ed13645c250201b4552b9d (patch)
tree18a0141f0aed7d87e1a1c0cbf1fd86b9de2ba8f4 /test/playwright/playwright-util.js
parent9ed81f25ab7f462546888a4ddd7fcecdf5ea1806 (diff)
Update tests
Diffstat (limited to 'test/playwright/playwright-util.js')
-rw-r--r--test/playwright/playwright-util.js11
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),