File tree Expand file tree Collapse file tree 6 files changed +75
-16
lines changed
backend/code-execution-service/tests Expand file tree Collapse file tree 6 files changed +75
-16
lines changed Original file line number Diff line number Diff line change 1
1
import supertest from "supertest" ;
2
- import app from "../app" ;
2
+ import app from "../src/ app" ;
3
3
import {
4
4
ERROR_MISSING_REQUIRED_FIELDS_MESSAGE ,
5
5
ERROR_UNSUPPORTED_LANGUAGE_MESSAGE ,
Original file line number Diff line number Diff line change @@ -8,6 +8,37 @@ import { MemoryRouter } from "react-router-dom";
8
8
9
9
jest . mock ( "axios" ) ;
10
10
11
+ jest . mock ( "../../utils/api" , ( ) => ( {
12
+ getUserUrl : jest . fn ( ) . mockReturnValue ( "http://localhost:3001/api" ) ,
13
+ getQuestionsUrl : jest
14
+ . fn ( )
15
+ . mockReturnValue ( "http://localhost:3000/api/questions" ) ,
16
+ getCodeExecutionUrl : jest
17
+ . fn ( )
18
+ . mockReturnValue ( "http://localhost:3004/api/run" ) ,
19
+ getQnHistoriesUrl : jest
20
+ . fn ( )
21
+ . mockReturnValue ( "http://localhost:3006/api/qnhistories" ) ,
22
+ } ) ) ;
23
+
24
+ jest . mock ( "../../utils/matchSocket" , ( ) => ( {
25
+ getMatchSocketUrl : jest . fn ( ) . mockReturnValue ( "http://localhost:3002" ) ,
26
+ } ) ) ;
27
+
28
+ jest . mock ( "../../utils/collabSocket" , ( ) => ( {
29
+ getCollabSocketUrl : jest . fn ( ) . mockReturnValue ( "http://localhost:3003" ) ,
30
+ } ) ) ;
31
+
32
+ jest . mock ( "../../utils/communicationSocket" , ( ) => ( {
33
+ getCommunicationSocketUrl : jest . fn ( ) . mockReturnValue ( "http://localhost:3005" ) ,
34
+ } ) ) ;
35
+
36
+ jest . mock ( "y-protocols/awareness.js" , ( ) => {
37
+ return {
38
+ Awareness : jest . fn ( ) ,
39
+ } ;
40
+ } ) ;
41
+
11
42
const mockedAxios = axios as jest . Mocked < typeof axios > ;
12
43
13
44
const mockUseNavigate = jest . fn ( ) ;
Original file line number Diff line number Diff line change 1
1
import axios from "axios" ;
2
2
3
- const usersUrl =
4
- import . meta. env . VITE_USER_SERVICE_URL ?? "http://localhost:3001/api" ;
5
- const questionsUrl =
6
- import . meta. env . VITE_QN_SERVICE_URL ?? "http://localhost:3000/api/questions" ;
7
- const codeExecutionUrl =
8
- import . meta. env . VITE_CODE_EXEC_SERVICE_URL ?? "http://localhost:3004/api/run" ;
9
- const qnHistoriesUrl =
10
- import . meta. env . VITE_QN_HIST_SERVICE_URL ??
11
- "http://localhost:3006/api/qnhistories" ;
3
+ const getUserUrl = ( ) => {
4
+ return import . meta. env . VITE_USER_SERVICE_URL ?? "http://localhost:3001/api" ;
5
+ } ;
6
+
7
+ const getQuestionsUrl = ( ) => {
8
+ return (
9
+ import . meta. env . VITE_QN_SERVICE_URL ?? "http://localhost:3000/api/questions"
10
+ ) ;
11
+ } ;
12
+
13
+ const getCodeExecutionUrl = ( ) => {
14
+ return (
15
+ import . meta. env . VITE_CODE_EXEC_SERVICE_URL ??
16
+ "http://localhost:3004/api/run"
17
+ ) ;
18
+ } ;
19
+
20
+ const getQnHistoriesUrl = ( ) => {
21
+ return (
22
+ import . meta. env . VITE_QN_HIST_SERVICE_URL ??
23
+ "http://localhost:3006/api/qnhistories"
24
+ ) ;
25
+ } ;
26
+
27
+ const usersUrl = getUserUrl ( ) ;
28
+ const questionsUrl = getQuestionsUrl ( ) ;
29
+ const codeExecutionUrl = getCodeExecutionUrl ( ) ;
30
+ const qnHistoriesUrl = getQnHistoriesUrl ( ) ;
12
31
13
32
export const questionClient = axios . create ( {
14
33
baseURL : questionsUrl ,
Original file line number Diff line number Diff line change @@ -27,8 +27,11 @@ export enum CollabEvents {
27
27
SOCKET_RECONNECT_FAILED = "reconnect_failed" ,
28
28
}
29
29
30
- const COLLAB_SOCKET_URL =
31
- import . meta. env . VITE_COLLAB_SERVICE_URL ?? "http://localhost:3003" ;
30
+ const getCollabSocketUrl = ( ) => {
31
+ return import . meta. env . VITE_COLLAB_SERVICE_URL ?? "http://localhost:3003" ;
32
+ } ;
33
+
34
+ const COLLAB_SOCKET_URL = getCollabSocketUrl ( ) ;
32
35
33
36
export const createCollabSocket = ( ) =>
34
37
io ( COLLAB_SOCKET_URL , {
Original file line number Diff line number Diff line change @@ -16,8 +16,11 @@ export enum CommunicationEvents {
16
16
DISCONNECTED = "disconnected" ,
17
17
}
18
18
19
- const COMMUNICATION_SOCKET_URL =
20
- import . meta. env . VITE_COMM_SERVICE_URL ?? "http://localhost:3005" ;
19
+ const getCommunicationSocketUrl = ( ) => {
20
+ return import . meta. env . VITE_COMM_SERVICE_URL ?? "http://localhost:3005" ;
21
+ } ;
22
+
23
+ const COMMUNICATION_SOCKET_URL = getCommunicationSocketUrl ( ) ;
21
24
22
25
export const createCommunicationSocket = ( ) =>
23
26
io ( COMMUNICATION_SOCKET_URL , {
Original file line number Diff line number Diff line change @@ -27,8 +27,11 @@ export enum MatchEvents {
27
27
SOCKET_RECONNECT_FAILED = "reconnect_failed" ,
28
28
}
29
29
30
- const MATCH_SOCKET_URL =
31
- import . meta. env . VITE_MATCH_SERVICE_URL ?? "http://localhost:3002" ;
30
+ const getMatchSocketUrl = ( ) => {
31
+ return import . meta. env . VITE_MATCH_SERVICE_URL ?? "http://localhost:3002" ;
32
+ } ;
33
+
34
+ const MATCH_SOCKET_URL = getMatchSocketUrl ( ) ;
32
35
33
36
export const createMatchSocket = ( ) =>
34
37
io ( MATCH_SOCKET_URL , {
You can’t perform that action at this time.
0 commit comments