Skip to content

Commit

Permalink
test: update test config
Browse files Browse the repository at this point in the history
  • Loading branch information
typeWolffo committed Nov 4, 2024
1 parent c0bc9f8 commit aef41e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/web/app/api/api-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useAuthStore } from "~/modules/Auth/authStore";
import { API } from "./generated-api";

const isTestEnv = process.env.NODE_ENV === "test";

export const ApiClient = new API({
baseURL: import.meta.env.VITE_API_URL,
secure: true,
Expand All @@ -13,7 +15,7 @@ ApiClient.instance.interceptors.request.use((config) => {
config.url?.includes("/refresh") ||
config.url?.includes("/register");

if (!isAuthEndpoint && !useAuthStore.getState().isLoggedIn) {
if (!isTestEnv && !isAuthEndpoint && !useAuthStore.getState().isLoggedIn) {
const controller = new AbortController();
controller.abort();
config.signal = controller.signal;
Expand Down
6 changes: 6 additions & 0 deletions apps/web/app/utils/mocks/handlers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ export const handlers = [
http.get("/api/auth/current-user", () => {
return HttpResponse.json(currentUser);
}),
http.post("/api/auth/refresh", () => {
return HttpResponse.json({
accessToken: "mock-access-token",
refreshToken: "mock-refresh-token",
});
}),
];
1 change: 1 addition & 0 deletions apps/web/app/utils/mocks/handlers/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const availableCoursesHandler = withSearchParams(
);

export const handlers = [
http.get("/api/courses", availableCoursesHandler),
http.get("/api/courses/available-courses", availableCoursesHandler),
http.get("/api/courses/get-student-courses", () => {
return HttpResponse.json(studentCourses);
Expand Down

0 comments on commit aef41e4

Please sign in to comment.