Skip to content

Commit

Permalink
Using index signature to access index properties
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Jan 15, 2025
1 parent 9412987 commit 311ef8c
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 57 deletions.
10 changes: 5 additions & 5 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -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: [
{
Expand All @@ -17,18 +17,18 @@ 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",
trace: "on-first-retry",
},
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,
});
8 changes: 4 additions & 4 deletions src/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check warning on line 13 in src/backend/index.ts

View check run for this annotation

Codecov / codecov/patch

src/backend/index.ts#L10-L13

Added lines #L10 - L13 were not covered by tests
10 changes: 3 additions & 7 deletions src/frontend/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/FolderSelection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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" },
Expand Down
8 changes: 4 additions & 4 deletions tests/frontend/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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" },
Expand Down Expand Up @@ -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" },
Expand All @@ -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" },
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/destination-selection-api-error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/destination-selection-unhandled-error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/destination-selection-unknown-error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/move-api-error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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" },
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/move-folders-equal-error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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" },
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/move-invalid-parameter-error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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" },
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/move-repeat-after-timeout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/move-unhandled-error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/move-unknown-error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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" },
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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" },
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/non-empty.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions tests/frontend/source-destination-selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -96,7 +96,7 @@ test("works with folder selection", async ({ page }) => {
},
},
];
window._endpointStubs.listSharedDrives = [
window._endpointStubs["listSharedDrives"] = [
{
status: "success",
value: {
Expand Down Expand Up @@ -138,7 +138,7 @@ test("works with folder selection", async ({ page }) => {
},
},
];
window._endpointStubs.move = [
window._endpointStubs["move"] = [
{
status: "success",
value: { response: { errors: [] }, status: "success" },
Expand Down
2 changes: 1 addition & 1 deletion tests/frontend/source-selection-api-error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
2 changes: 1 addition & 1 deletion tests/frontend/source-selection-unhandled-error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Loading

0 comments on commit 311ef8c

Please sign in to comment.