Skip to content

Commit 253239b

Browse files
committed
Set "type": "module" and fix things
1 parent a0372ee commit 253239b

File tree

13 files changed

+94
-87
lines changed

13 files changed

+94
-87
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,6 @@
126126
"vite": "^5.3.2",
127127
"vite-plugin-istanbul": "^6.0.2",
128128
"vitest": "^2.0.5"
129-
}
129+
},
130+
"type": "module"
130131
}

playwright.config.ts

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,30 @@
22

33
import { defineConfig, devices, PlaywrightTestConfig } from "@playwright/test";
44

5-
const SHOULD_TEST_SAFARI = getBoolEnvVar('TEST_SAFARI');
6-
const SHOULD_TEST_LOCALLY = getBoolEnvVar('TEST_LOCAL');
5+
const SHOULD_TEST_SAFARI = getBoolEnvVar("TEST_SAFARI");
6+
const SHOULD_TEST_LOCALLY = getBoolEnvVar("TEST_LOCAL");
77

88
/**
9-
* List of browsers to test against.
10-
*
11-
* - Use Safari if indicated by `TEST_SAFARI=y`
12-
* - Use only one browser (Desktop Chrome) if testing locally. Tests against a local
13-
* backend use features which modify global state, so we can only use one browser.
14-
* - Use multiple browsers and mobile browsers if testing against the public testing server.
15-
*/
9+
* List of browsers to test against.
10+
*
11+
* - Use Safari if indicated by `TEST_SAFARI=y`
12+
* - Use only one browser (Desktop Chrome) if testing locally. Tests against a local
13+
* backend use features which modify global state, so we can only use one browser.
14+
* - Use multiple browsers and mobile browsers if testing against the public testing server.
15+
*/
1616
const BROWSERS: PlaywrightTestConfig["projects"] = [];
1717

1818
if (SHOULD_TEST_LOCALLY) {
1919
if (SHOULD_TEST_SAFARI) {
20-
BROWSERS.push(
21-
{
22-
name: 'webkit',
23-
use: { ...devices['Desktop Safari'] },
24-
},
25-
);
20+
BROWSERS.push({
21+
name: "webkit",
22+
use: { ...devices["Desktop Safari"] },
23+
});
2624
} else {
27-
BROWSERS.push(
28-
{
29-
name: "chromium",
30-
use: { ...devices["Desktop Chrome"] },
31-
},
32-
);
25+
BROWSERS.push({
26+
name: "chromium",
27+
use: { ...devices["Desktop Chrome"] },
28+
});
3329
}
3430
} else {
3531
BROWSERS.push(
@@ -38,23 +34,23 @@ if (SHOULD_TEST_LOCALLY) {
3834
use: { ...devices["Desktop Chrome"] },
3935
},
4036
{
41-
name: 'firefox',
42-
use: { ...devices['Desktop Firefox'] },
37+
name: "firefox",
38+
use: { ...devices["Desktop Firefox"] },
4339
},
4440
{
45-
name: 'Mobile Chrome',
46-
use: { ...devices['Pixel 5'] },
41+
name: "Mobile Chrome",
42+
use: { ...devices["Pixel 5"] },
4743
},
4844
);
4945
if (SHOULD_TEST_SAFARI) {
5046
BROWSERS.push(
5147
{
52-
name: 'webkit',
53-
use: { ...devices['Desktop Safari'] },
48+
name: "webkit",
49+
use: { ...devices["Desktop Safari"] },
5450
},
5551
{
56-
name: 'Mobile Safari',
57-
use: { ...devices['iPhone 12'] },
52+
name: "Mobile Safari",
53+
use: { ...devices["iPhone 12"] },
5854
},
5955
);
6056
}
@@ -63,7 +59,7 @@ if (SHOULD_TEST_LOCALLY) {
6359
/**
6460
* Name of a npm script which starts a UI development server.
6561
*/
66-
const UI_SCRIPT = SHOULD_TEST_LOCALLY ? 'dev' : 'dev:public';
62+
const UI_SCRIPT = SHOULD_TEST_LOCALLY ? "dev" : "dev:public";
6763
/**
6864
* Port number (on localhost) for the server created by {@link UI_SCRIPT}
6965
*/
@@ -74,7 +70,7 @@ const UI_PORT = SHOULD_TEST_LOCALLY ? 5173 : 25173;
7470
*/
7571
export default defineConfig({
7672
/* A script which deletes the previous coverage data */
77-
globalSetup: require.resolve('./deleteCoverageData'),
73+
globalSetup: "./deleteCoverageData.ts",
7874

7975
testDir: "./tests",
8076
/* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */
@@ -103,14 +99,14 @@ export default defineConfig({
10399
webServer: {
104100
command: `env USE_BABEL_PLUGIN_ISTANBUL=y CI=true npm run ${UI_SCRIPT}`,
105101
url: `http://localhost:${UI_PORT}`,
106-
reuseExistingServer:true,
107-
timeout: SHOULD_TEST_LOCALLY ? 5 * 60_000 : 60_000 // more time is needed for local testing web server, to download container images and example data
102+
reuseExistingServer: true,
103+
timeout: SHOULD_TEST_LOCALLY ? 5 * 60_000 : 60_000, // more time is needed for local testing web server, to download container images and example data
108104
},
109105
});
110106

111107
/**
112108
* Get a boolean value from an environment variable.
113109
*/
114110
function getBoolEnvVar(name: string): boolean {
115-
return process.env[name]?.toLowerCase().startsWith('y') || false;
111+
return process.env[name]?.toLowerCase().startsWith("y") || false;
116112
}

src/components/NiivueDatasetViewer/components/RadiologcalConventionToggle.tsx

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,31 @@ type RadiologcalConventionToggleProps = {
88
setOptions: Updater<ChNVROptions>;
99
};
1010

11-
const RadiologcalConventionToggle: React.FC<RadiologcalConventionToggleProps> =
12-
({ options, setOptions }) => (
13-
<ToggleGroup>
14-
<ToggleGroupItem
15-
text="Neurological"
16-
isSelected={!options.isRadiologicalConvention}
17-
onChange={() =>
18-
setOptions((draft) => {
19-
draft.isRadiologicalConvention = false;
20-
draft.sagittalNoseLeft = false;
21-
})
22-
}
23-
/>
24-
<ToggleGroupItem
25-
text="Radiological"
26-
isSelected={options.isRadiologicalConvention}
27-
onChange={() =>
28-
setOptions((draft) => {
29-
draft.isRadiologicalConvention = true;
30-
draft.sagittalNoseLeft = true;
31-
})
32-
}
33-
/>
34-
</ToggleGroup>
35-
);
11+
const RadiologcalConventionToggle: React.FC<
12+
RadiologcalConventionToggleProps
13+
> = ({ options, setOptions }) => (
14+
<ToggleGroup>
15+
<ToggleGroupItem
16+
text="Neurological"
17+
isSelected={!options.isRadiologicalConvention}
18+
onChange={() =>
19+
setOptions((draft) => {
20+
draft.isRadiologicalConvention = false;
21+
draft.sagittalNoseLeft = false;
22+
})
23+
}
24+
/>
25+
<ToggleGroupItem
26+
text="Radiological"
27+
isSelected={options.isRadiologicalConvention}
28+
onChange={() =>
29+
setOptions((draft) => {
30+
draft.isRadiologicalConvention = true;
31+
draft.sagittalNoseLeft = true;
32+
})
33+
}
34+
/>
35+
</ToggleGroup>
36+
);
3637

3738
export default RadiologcalConventionToggle;

src/components/Store/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ const Store = () => {
162162
);
163163
if (!adminURL)
164164
throw new Error("Please provide a link to your chris-admin url");
165-
166165

167166
const client = ChrisAPIClient.getClient();
168167
const adminCredentials = btoa(`${username.trim()}:${password.trim()}`); // Base64 encoding for Basic Auth

testing/publicCUBE/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import viteConfig from "../../vite.config";
55
export default mergeConfig(viteConfig, {
66
envDir: "./testing/publicCUBE",
77
server: {
8-
port: 25173
9-
}
8+
port: 25173,
9+
},
1010
});

tests/createFeed.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { test, expect } from "./fixtures/loggedIn.ts";
22
import { faker } from "@faker-js/faker";
33
import createFeed from "./helpers/createFeedHelper.ts";
4-
import path from "path";
4+
import getProjectFile from "./helpers/projectFile.ts";
55

6-
const SOME_FILE = path.join(__dirname, "..", "package-lock.json");
6+
const SOME_FILE = getProjectFile("package-lock.json");
77

88
test("Can create a feed", async ({ page }) => {
99
test.slow();

tests/feedops.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { test, expect } from "./fixtures/loggedIn.ts";
22
import { faker } from "@faker-js/faker";
33
import createFeed from "./helpers/createFeedHelper";
4-
import path from "path";
4+
import getProjectFile from "./helpers/projectFile.ts";
55

6-
const SOME_FILE = path.join(__dirname, "..", "package-lock.json");
6+
const SOME_FILE = getProjectFile("package-lock.json");
77

88
test("Can perform feed operations", async ({ page, isMobile }) => {
99
test.slow();

tests/helpers/projectFile.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import path from "path";
2+
import { fileURLToPath } from "url";
3+
4+
export default function getProjectFile(...parts: string[]): string {
5+
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
6+
const __dirname = path.dirname(__filename); // get the name of the directory
7+
return path.join(__dirname, "..", "..", ...parts);
8+
}

tests/library.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, expect } from "./fixtures/loggedIn.ts";
2-
import path from "path";
2+
import getProjectFile from "./helpers/projectFile.ts";
33

44
test("Tests File Uploads", async ({ page }) => {
55
//Avoids timeouts.
@@ -28,7 +28,7 @@ test("Tests File Uploads", async ({ page }) => {
2828
await page.getByRole("button", { name: /upload files/i }).click();
2929
const fileChooser = await fileChooserPromise;
3030

31-
const SOME_FILE = path.join(__dirname, "..", "package-lock.json");
31+
const SOME_FILE = getProjectFile("package-lock.json");
3232
await fileChooser.setFiles(SOME_FILE);
3333

3434
await page.waitForSelector("input[name='horizontal-form-name']");

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"noUnusedLocals": true,
2020
"noUnusedParameters": true,
2121
"noFallthroughCasesInSwitch": true,
22-
"noImplicitAny":true,
22+
"noImplicitAny": true
2323
},
2424
"references": [{ "path": "./tsconfig.node.json" }]
2525
}

0 commit comments

Comments
 (0)