Skip to content

Commit

Permalink
webapp/tests: use test specific server url
Browse files Browse the repository at this point in the history
  • Loading branch information
tharvik committed Jan 8, 2025
1 parent 6e3cf2a commit 981ee9f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/lint-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,7 @@ jobs:
with:
working-directory: webapp
install: false
start: npm start
env:
VITE_SERVER_URL: http://server
start: npx vite --mode test --port 1351

test-cli:
needs: [build-lib, build-lib-node, build-server, download-datasets]
Expand Down
2 changes: 1 addition & 1 deletion webapp/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_SERVER_URL=http://localhost:8080
VITE_SERVER_URL=http://server:1351
2 changes: 1 addition & 1 deletion webapp/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as fs from "node:fs/promises";

export default defineConfig({
e2e: {
baseUrl: "http://localhost:8081/",
baseUrl: "http://localhost:1351/",
projectId: "aps8et", // to get recordings on Cypress Cloud
setupNodeEvents(on) {
on("task", {
Expand Down
2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint .",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "vitest --run",
"test:e2e": "VITE_SERVER_URL=http://server start-server-and-test start http://localhost:8081 'cypress run --e2e'"
"test:e2e": "start-server-and-test 'vite --mode test --port 1351' localhost:1351 'cypress run --e2e'"
},
"dependencies": {
"@epfml/discojs": "*",
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/components/testing/__tests__/Testing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createPersistedStatePlugin } from "pinia-plugin-persistedstate-2";
import type { Task } from "@epfml/discojs";
import { models as discoModels } from "@epfml/discojs";

import { CONFIG } from "@/config";
import { useModelsStore } from "@/store";
import { useTasksStore } from "@/store";

Expand Down Expand Up @@ -60,7 +61,7 @@ it("shows stored models", async () => {

it("allows to download server's models", async () => {
vi.stubGlobal("fetch", async (url: string | URL) => {
if (url.toString() === "http://localhost:8080/tasks")
if (url.toString() === new URL("tasks", CONFIG.serverUrl).href)
return new Response(JSON.stringify([TASK]));
throw new Error(`unhandled get: ${url}`);
});
Expand Down
7 changes: 6 additions & 1 deletion webapp/src/components/training/__tests__/Trainer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ import * as fs from "node:fs/promises";
import { defaultTasks, serialization } from "@epfml/discojs";
import { loadCSV } from "@epfml/discojs-web";

import { CONFIG } from "@/config";

import Trainer from "../Trainer.vue";
import TrainingInformation from "../TrainingInformation.vue";

async function setupForTask() {
const provider = defaultTasks.titanic;

vi.stubGlobal("fetch", async (url: string | URL) => {
if (url.toString() === "http://localhost:8080/tasks/titanic/model.json") {
if (
url.toString() ===
new URL("tasks/titanic/model.json", CONFIG.serverUrl).href
) {
const model = await provider.getModel();
const encoded = await serialization.model.encode(model);
return new Response(encoded);
Expand Down

0 comments on commit 981ee9f

Please sign in to comment.