Uncomment out expect statement

This commit is contained in:
Alex Holliday committed 2024-10-24 10:04:22 +08:00
1 parent 1c2d758e17
commit 47946cbf34
4 files changed
+58 -40

No files matched your search

+16 -1
View File
@@ -36,7 +36,7 @@ import { useSelector } from "react-redux";
import { CssBaseline } from "@mui/material"; import { CssBaseline } from "@mui/material";
import { useEffect } from "react"; import { useEffect } from "react";
import { useDispatch } from "react-redux"; import { useDispatch } from "react-redux";
import { getAppSettings } from "./Features/Settings/settingsSlice"; import { getAppSettings, updateAppSettings } from "./Features/Settings/settingsSlice";
import { logger } from "./Utils/Logger"; // Import the logger import { logger } from "./Utils/Logger"; // Import the logger
import { networkService } from "./main"; import { networkService } from "./main";
function App() { function App() {
@@ -66,6 +66,21 @@ function App() {
}; };
}, []); }, []);
useEffect(() => {
const thing = async () => {
const action = await dispatch(
updateAppSettings({ authToken, settings: { apiBaseUrl: "test" } })
);
if (action.payload.success) {
console.log(action.payload.data);
} else {
console.log(action);
}
};
thing();
}, [dispatch, authToken]);
return ( return (
<ThemeProvider theme={mode === "light" ? lightTheme : darkTheme}> <ThemeProvider theme={mode === "light" ? lightTheme : darkTheme}>
<CssBaseline /> <CssBaseline />
@@ -49,6 +49,7 @@ export const updateAppSettings = createAsyncThunk(
systemEmailAddress: settings.systemEmailAddress, systemEmailAddress: settings.systemEmailAddress,
systemEmailPassword: settings.systemEmailPassword, systemEmailPassword: settings.systemEmailPassword,
}; };
console.log(parsedSettings);
const res = await networkService.updateAppSettings({ const res = await networkService.updateAppSettings({
settings: parsedSettings, settings: parsedSettings,
authToken, authToken,
+39 -38
View File
@@ -13,6 +13,7 @@ class NetworkService {
this.setBaseUrl(baseURL); this.setBaseUrl(baseURL);
this.unsubscribe = store.subscribe(() => { this.unsubscribe = store.subscribe(() => {
const state = store.getState(); const state = store.getState();
console.log(state.settings.apiBaseUrl);
if (BASE_URL !== undefined) { if (BASE_URL !== undefined) {
baseURL = BASE_URL; baseURL = BASE_URL;
} else if (state?.settings?.apiBaseUrl ?? null) { } else if (state?.settings?.apiBaseUrl ?? null) {
@@ -88,47 +89,47 @@ class NetworkService {
}); });
} }
/** /**
* *
* ************************************ * ************************************
* Check the endpoint resolution * Check the endpoint resolution
* ************************************ * ************************************
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header. * @param {string} config.authToken - The authorization token to be used in the request header.
* @param {Object} config.monitorURL - The monitor url to be sent in the request body. * @param {Object} config.monitorURL - The monitor url to be sent in the request body.
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
*/ */
async checkEndpointResolution(config) { async checkEndpointResolution(config) {
const { authToken, monitorURL } = config; const { authToken, monitorURL } = config;
const params = new URLSearchParams(); const params = new URLSearchParams();
if (monitorURL) params.append("monitorURL", monitorURL); if (monitorURL) params.append("monitorURL", monitorURL);
return this.axiosInstance.get(`/monitors/resolution/url?${params.toString()}`, { return this.axiosInstance.get(`/monitors/resolution/url?${params.toString()}`, {
headers: { headers: {
Authorization: `Bearer ${authToken}`, Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
} },
}) });
} }
/** /**
* *
* ************************************ * ************************************
* Gets monitors and summary of stats by TeamID * Gets monitors and summary of stats by TeamID
* ************************************ * ************************************
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header. * @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.teamId - Team ID * @param {string} config.teamId - Team ID
* @param {Array<string>} config.types - Array of monitor types * @param {Array<string>} config.types - Array of monitor types
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
*/ */
async getMonitorsAndSummaryByTeamId(config) { async getMonitorsAndSummaryByTeamId(config) {
const params = new URLSearchParams(); const params = new URLSearchParams();
if (config.types) { if (config.types) {
config.types.forEach((type) => { config.types.forEach((type) => {
+2 -1
View File
@@ -1,5 +1,6 @@
import sinon from "sinon"; import sinon from "sinon";
import JobQueue from "../../service/jobQueue.js"; import JobQueue from "../../service/jobQueue.js";
import { log } from "console";
class QueueStub { class QueueStub {
constructor(queueName, options) { constructor(queueName, options) {
@@ -202,7 +203,7 @@ describe("JobQueue", () => {
); );
const worker = jobQueue.createWorker(); const worker = jobQueue.createWorker();
await worker.workerTask(); await worker.workerTask();
// expect(networkService.getStatus.calledOnce).to.be.false; expect(networkService.getStatus.calledOnce).to.be.true;
}); });
}); });
describe("getWorkerStats", () => { describe("getWorkerStats", () => {