From e82bf5f19ed9d8269acf01b96f50f6d390790d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Thu, 12 Sep 2024 09:58:24 +0300 Subject: [PATCH 1/3] Using index signature to access index properties --- playwright.config.ts | 10 +++++----- src/backend/index.ts | 8 ++++---- src/frontend/App.svelte | 10 +++------- src/frontend/FolderSelection.svelte | 4 ++-- tests/frontend/basic.spec.ts | 4 ++-- tests/frontend/configuration.spec.ts | 8 ++++---- tests/frontend/destination-selection-api-error.spec.ts | 4 ++-- ...stination-selection-invalid-parameter-error.spec.ts | 4 ++-- .../destination-selection-unhandled-error.spec.ts | 4 ++-- .../destination-selection-unknown-error.spec.ts | 4 ++-- tests/frontend/move-api-error.spec.ts | 4 ++-- tests/frontend/move-folders-equal-error.spec.ts | 4 ++-- tests/frontend/move-invalid-parameter-error.spec.ts | 4 ++-- tests/frontend/move-repeat-after-timeout.spec.ts | 4 ++-- tests/frontend/move-unhandled-error.spec.ts | 4 ++-- tests/frontend/move-unknown-error.spec.ts | 4 ++-- tests/frontend/navigation.spec.ts | 4 ++-- tests/frontend/non-empty.spec.ts | 4 ++-- tests/frontend/source-destination-selection.spec.ts | 6 +++--- tests/frontend/source-selection-api-error.spec.ts | 2 +- .../source-selection-invalid-parameter-error.spec.ts | 2 +- .../frontend/source-selection-unhandled-error.spec.ts | 2 +- tests/frontend/source-selection-unknown-error.spec.ts | 2 +- tests/frontend/success-with-errors.spec.ts | 4 ++-- 24 files changed, 53 insertions(+), 57 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 2a93f52a..0631711c 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,7 +1,7 @@ import { defineConfig, devices } from "@playwright/test"; export default defineConfig({ - forbidOnly: process.env.CI !== undefined, + forbidOnly: process.env["CI"] !== undefined, fullyParallel: true, projects: [ { @@ -17,8 +17,8 @@ export default defineConfig({ use: { ...devices["Desktop Safari"] }, }, ], - reporter: process.env.CI !== undefined ? "html" : "list", - retries: process.env.CI !== undefined ? 2 : 0, + reporter: process.env["CI"] !== undefined ? "html" : "list", + retries: process.env["CI"] !== undefined ? 2 : 0, testDir: "./tests/frontend", use: { baseURL: "http://127.0.0.1:5173", @@ -26,9 +26,9 @@ export default defineConfig({ }, webServer: { command: "npm run start -- --host", - reuseExistingServer: process.env.CI === undefined, + reuseExistingServer: process.env["CI"] === undefined, url: "http://127.0.0.1:5173", }, // Opt out of parallel tests on CI. - //workers: process.env.CI !== undefined ? 1 : undefined, + //workers: process.env["CI"] !== undefined ? 1 : undefined, }); diff --git a/src/backend/index.ts b/src/backend/index.ts index ca5e3515..570cec1f 100644 --- a/src/backend/index.ts +++ b/src/backend/index.ts @@ -7,7 +7,7 @@ import { move } from "./move"; declare const globalThis: google.script.PublicEndpoints; -globalThis.doGet = doGet; -globalThis.listFolders = listFolders; -globalThis.listSharedDrives = listSharedDrives; -globalThis.move = move; +globalThis["doGet"] = doGet; +globalThis["listFolders"] = listFolders; +globalThis["listSharedDrives"] = listSharedDrives; +globalThis["move"] = move; diff --git a/src/frontend/App.svelte b/src/frontend/App.svelte index f2a51454..f1478f11 100644 --- a/src/frontend/App.svelte +++ b/src/frontend/App.svelte @@ -119,13 +119,9 @@ google.script.run .withSuccessHandler(moveSuccessHandler) .withFailureHandler(moveErrorHandler) - .move( - source.id, - destination.id, - copyComments, - mergeFolders, - forceNonEmpty, - ); + [ + "move" + ](source.id, destination.id, copyComments, mergeFolders, forceNonEmpty); } function showErrorDialogWithEvent( diff --git a/src/frontend/FolderSelection.svelte b/src/frontend/FolderSelection.svelte index 590d732b..07040774 100644 --- a/src/frontend/FolderSelection.svelte +++ b/src/frontend/FolderSelection.svelte @@ -65,12 +65,12 @@ google.script.run .withSuccessHandler(handleSharedDriveResponse) .withFailureHandler(handleError) - .listSharedDrives(); + ["listSharedDrives"](); } else { google.script.run .withSuccessHandler(handleFolderResponse) .withFailureHandler(handleError) - .listFolders(path[path.length - 1].id); + ["listFolders"](path[path.length - 1].id); } } diff --git a/tests/frontend/basic.spec.ts b/tests/frontend/basic.spec.ts index 7580bd57..ffc27073 100644 --- a/tests/frontend/basic.spec.ts +++ b/tests/frontend/basic.spec.ts @@ -7,7 +7,7 @@ test("works with basic configuration", async ({ page }) => { const getCalls = await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -17,7 +17,7 @@ test("works with basic configuration", async ({ page }) => { value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "success", value: { response: { errors: [] }, status: "success" }, diff --git a/tests/frontend/configuration.spec.ts b/tests/frontend/configuration.spec.ts index 8a35252a..c865e2ea 100644 --- a/tests/frontend/configuration.spec.ts +++ b/tests/frontend/configuration.spec.ts @@ -7,7 +7,7 @@ test("works with copy configuration", async ({ page }) => { const getCalls = await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -17,7 +17,7 @@ test("works with copy configuration", async ({ page }) => { value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "success", value: { response: { errors: [] }, status: "success" }, @@ -53,7 +53,7 @@ test("works with merge configuration", async ({ page }) => { const getCalls = await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -63,7 +63,7 @@ test("works with merge configuration", async ({ page }) => { value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "success", value: { response: { errors: [] }, status: "success" }, diff --git a/tests/frontend/destination-selection-api-error.spec.ts b/tests/frontend/destination-selection-api-error.spec.ts index 6f294bde..16842f06 100644 --- a/tests/frontend/destination-selection-api-error.spec.ts +++ b/tests/frontend/destination-selection-api-error.spec.ts @@ -9,13 +9,13 @@ test("handles raw errors in source folder selection gracefully", async ({ await setup(page); await page.evaluate(() => { - window._endpointStubs.listFolders = [ + window._endpointStubs["listFolders"] = [ { status: "success", value: { status: "error", type: "DriveAPIError" }, }, ]; - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { diff --git a/tests/frontend/destination-selection-invalid-parameter-error.spec.ts b/tests/frontend/destination-selection-invalid-parameter-error.spec.ts index 2cd832ca..de3fd389 100644 --- a/tests/frontend/destination-selection-invalid-parameter-error.spec.ts +++ b/tests/frontend/destination-selection-invalid-parameter-error.spec.ts @@ -9,13 +9,13 @@ test("handles raw errors in source folder selection gracefully", async ({ await setup(page); await page.evaluate(() => { - window._endpointStubs.listFolders = [ + window._endpointStubs["listFolders"] = [ { status: "success", value: { status: "error", type: "invalidParameter" }, }, ]; - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { diff --git a/tests/frontend/destination-selection-unhandled-error.spec.ts b/tests/frontend/destination-selection-unhandled-error.spec.ts index 6072b644..44ed5e60 100644 --- a/tests/frontend/destination-selection-unhandled-error.spec.ts +++ b/tests/frontend/destination-selection-unhandled-error.spec.ts @@ -9,13 +9,13 @@ test("handles raw errors in source folder selection gracefully", async ({ await setup(page); await page.evaluate(() => { - window._endpointStubs.listFolders = [ + window._endpointStubs["listFolders"] = [ { status: "failure", value: new Error("ERROR MESSAGE"), }, ]; - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { diff --git a/tests/frontend/destination-selection-unknown-error.spec.ts b/tests/frontend/destination-selection-unknown-error.spec.ts index a081d6db..ceaa8b8f 100644 --- a/tests/frontend/destination-selection-unknown-error.spec.ts +++ b/tests/frontend/destination-selection-unknown-error.spec.ts @@ -9,13 +9,13 @@ test("handles raw errors in source folder selection gracefully", async ({ await setup(page); await page.evaluate(() => { - window._endpointStubs.listFolders = [ + window._endpointStubs["listFolders"] = [ { status: "success", value: { status: "error", type: "unknown" }, }, ]; - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { diff --git a/tests/frontend/move-api-error.spec.ts b/tests/frontend/move-api-error.spec.ts index b0d56a3f..aab3a275 100644 --- a/tests/frontend/move-api-error.spec.ts +++ b/tests/frontend/move-api-error.spec.ts @@ -7,7 +7,7 @@ test("works with an API error", async ({ page }) => { await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -17,7 +17,7 @@ test("works with an API error", async ({ page }) => { value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "success", value: { status: "error", type: "DriveAPIError" }, diff --git a/tests/frontend/move-folders-equal-error.spec.ts b/tests/frontend/move-folders-equal-error.spec.ts index 80077c28..2233895a 100644 --- a/tests/frontend/move-folders-equal-error.spec.ts +++ b/tests/frontend/move-folders-equal-error.spec.ts @@ -9,7 +9,7 @@ test("works with source and destination folders being equal", async ({ await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -19,7 +19,7 @@ test("works with source and destination folders being equal", async ({ value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "success", value: { status: "error", type: "sourceEqualsDestination" }, diff --git a/tests/frontend/move-invalid-parameter-error.spec.ts b/tests/frontend/move-invalid-parameter-error.spec.ts index 59be0544..bb3c587c 100644 --- a/tests/frontend/move-invalid-parameter-error.spec.ts +++ b/tests/frontend/move-invalid-parameter-error.spec.ts @@ -7,7 +7,7 @@ test("works with an API error", async ({ page }) => { await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -17,7 +17,7 @@ test("works with an API error", async ({ page }) => { value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "success", value: { status: "error", type: "invalidParameter" }, diff --git a/tests/frontend/move-repeat-after-timeout.spec.ts b/tests/frontend/move-repeat-after-timeout.spec.ts index 227609c0..ba9a6271 100644 --- a/tests/frontend/move-repeat-after-timeout.spec.ts +++ b/tests/frontend/move-repeat-after-timeout.spec.ts @@ -9,7 +9,7 @@ test("works with an unhandled move error", async ({ page }) => { await page.evaluate(() => { const e = new Error(); e.name = "ScriptError"; - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -19,7 +19,7 @@ test("works with an unhandled move error", async ({ page }) => { value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "failure", value: e, diff --git a/tests/frontend/move-unhandled-error.spec.ts b/tests/frontend/move-unhandled-error.spec.ts index 99359f78..7f5de32b 100644 --- a/tests/frontend/move-unhandled-error.spec.ts +++ b/tests/frontend/move-unhandled-error.spec.ts @@ -7,7 +7,7 @@ test("works with an unhandled move error", async ({ page }) => { await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -17,7 +17,7 @@ test("works with an unhandled move error", async ({ page }) => { value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "failure", value: new Error("ERROR MESSAGE"), diff --git a/tests/frontend/move-unknown-error.spec.ts b/tests/frontend/move-unknown-error.spec.ts index 9bb98e3b..4c6605c1 100644 --- a/tests/frontend/move-unknown-error.spec.ts +++ b/tests/frontend/move-unknown-error.spec.ts @@ -7,7 +7,7 @@ test("works with an unknown move error", async ({ page }) => { await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -17,7 +17,7 @@ test("works with an unknown move error", async ({ page }) => { value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "success", value: { status: "error", type: "unknown" }, diff --git a/tests/frontend/navigation.spec.ts b/tests/frontend/navigation.spec.ts index 605b8460..6212c5c3 100644 --- a/tests/frontend/navigation.spec.ts +++ b/tests/frontend/navigation.spec.ts @@ -7,7 +7,7 @@ test("works with basic configuration", async ({ page }) => { const getCalls = await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -33,7 +33,7 @@ test("works with basic configuration", async ({ page }) => { value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "success", value: { response: { errors: [] }, status: "success" }, diff --git a/tests/frontend/non-empty.spec.ts b/tests/frontend/non-empty.spec.ts index 4689ab8a..4d09f23e 100644 --- a/tests/frontend/non-empty.spec.ts +++ b/tests/frontend/non-empty.spec.ts @@ -7,7 +7,7 @@ test("works with non-empty destination folder", async ({ page }) => { const getCalls = await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -21,7 +21,7 @@ test("works with non-empty destination folder", async ({ page }) => { value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { delay: 500, status: "success", diff --git a/tests/frontend/source-destination-selection.spec.ts b/tests/frontend/source-destination-selection.spec.ts index 6e9c090a..48bfe6d5 100644 --- a/tests/frontend/source-destination-selection.spec.ts +++ b/tests/frontend/source-destination-selection.spec.ts @@ -7,7 +7,7 @@ test("works with folder selection", async ({ page }) => { const getCalls = await setup(page); await page.evaluate(() => { - window._endpointStubs.listFolders = [ + window._endpointStubs["listFolders"] = [ { status: "success", value: { @@ -96,7 +96,7 @@ test("works with folder selection", async ({ page }) => { }, }, ]; - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { @@ -138,7 +138,7 @@ test("works with folder selection", async ({ page }) => { }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "success", value: { response: { errors: [] }, status: "success" }, diff --git a/tests/frontend/source-selection-api-error.spec.ts b/tests/frontend/source-selection-api-error.spec.ts index 0bb3bce2..9d4099be 100644 --- a/tests/frontend/source-selection-api-error.spec.ts +++ b/tests/frontend/source-selection-api-error.spec.ts @@ -9,7 +9,7 @@ test("handles raw errors in source folder selection gracefully", async ({ await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { status: "error", type: "DriveAPIError" }, diff --git a/tests/frontend/source-selection-invalid-parameter-error.spec.ts b/tests/frontend/source-selection-invalid-parameter-error.spec.ts index 830e3e49..9e037d74 100644 --- a/tests/frontend/source-selection-invalid-parameter-error.spec.ts +++ b/tests/frontend/source-selection-invalid-parameter-error.spec.ts @@ -9,7 +9,7 @@ test("handles invalid parameter errors in source folder selection gracefully", a await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { status: "error", type: "invalidParameter" }, diff --git a/tests/frontend/source-selection-unhandled-error.spec.ts b/tests/frontend/source-selection-unhandled-error.spec.ts index 0877768e..d3229ae5 100644 --- a/tests/frontend/source-selection-unhandled-error.spec.ts +++ b/tests/frontend/source-selection-unhandled-error.spec.ts @@ -9,7 +9,7 @@ test("handles raw errors in source folder selection gracefully", async ({ await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "failure", value: new Error("ERROR MESSAGE"), diff --git a/tests/frontend/source-selection-unknown-error.spec.ts b/tests/frontend/source-selection-unknown-error.spec.ts index 49d62ac1..262bee87 100644 --- a/tests/frontend/source-selection-unknown-error.spec.ts +++ b/tests/frontend/source-selection-unknown-error.spec.ts @@ -9,7 +9,7 @@ test("handles raw errors in source folder selection gracefully", async ({ await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { status: "error", type: "unknown" }, diff --git a/tests/frontend/success-with-errors.spec.ts b/tests/frontend/success-with-errors.spec.ts index 4b6ca378..d853b0ec 100644 --- a/tests/frontend/success-with-errors.spec.ts +++ b/tests/frontend/success-with-errors.spec.ts @@ -7,7 +7,7 @@ test("works and displays moving errors", async ({ page }) => { const getCalls = await setup(page); await page.evaluate(() => { - window._endpointStubs.listSharedDrives = [ + window._endpointStubs["listSharedDrives"] = [ { status: "success", value: { response: [], status: "success" }, @@ -17,7 +17,7 @@ test("works and displays moving errors", async ({ page }) => { value: { response: [], status: "success" }, }, ]; - window._endpointStubs.move = [ + window._endpointStubs["move"] = [ { status: "success", value: { From ddebc209d5571299e609ca0faa1a1a2303f2543c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Thu, 12 Sep 2024 09:58:41 +0300 Subject: [PATCH 2/3] Stricter tsconfig --- tsconfig.json | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 9f99d8a5..702b0c26 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,22 @@ { "compilerOptions": { + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, "module": "es6", "moduleResolution": "node", - "verbatimModuleSyntax": true, - "allowSyntheticDefaultImports": true, "resolveJsonModule": true, - "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "verbatimModuleSyntax": true, + + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "exactOptionalPropertyTypes": true, "noFallthroughCasesInSwitch": true, + "noImplicitOverride": true, "noImplicitReturns": true, + "noPropertyAccessFromIndexSignature": true, "noUnusedLocals": true, "noUnusedParameters": true, - "skipLibCheck": true, "strict": true } } From e583f3c44ebc58e1fc888b5aa61e22df3c3cf50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Thu, 12 Sep 2024 12:05:47 +0300 Subject: [PATCH 3/3] Disabled skipLibCheck --- tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 702b0c26..90f595e5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,6 @@ "module": "es6", "moduleResolution": "node", "resolveJsonModule": true, - "skipLibCheck": true, "verbatimModuleSyntax": true, "allowUnreachableCode": false,