Introduce prettier
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { UserType } from "@/types/user";
|
||||
import { avatars } from "@/config/selection";
|
||||
import Config from "@/config/config";
|
||||
import { UserType } from '@/types/user';
|
||||
import { avatars } from '@/config/selection';
|
||||
import Config from '@/config/config';
|
||||
const apiServer = Config.apiServer;
|
||||
|
||||
async function signUp(newUser: UserType) {
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(newUser),
|
||||
};
|
||||
@@ -22,16 +22,16 @@ async function signUp(newUser: UserType) {
|
||||
const token = await response.json();
|
||||
return token;
|
||||
} catch (error: any) {
|
||||
console.error("Error sign up:", error);
|
||||
console.error('Error sign up:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function signIn(signInUser: UserType) {
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(signInUser),
|
||||
};
|
||||
@@ -46,7 +46,7 @@ async function signIn(signInUser: UserType) {
|
||||
const token = await response.json();
|
||||
return token;
|
||||
} catch (error: any) {
|
||||
console.error("Error sign in:", error);
|
||||
console.error('Error sign in:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import { expect, test } from "vitest";
|
||||
import { isValidEmail, isValidPassword } from "./validate";
|
||||
import { expect, test } from 'vitest';
|
||||
import { isValidEmail, isValidPassword } from './validate';
|
||||
|
||||
test("validate email", () => {
|
||||
const email1 = "aaa@gmail.com";
|
||||
test('validate email', () => {
|
||||
const email1 = 'aaa@gmail.com';
|
||||
expect(isValidEmail(email1)).toBe(true);
|
||||
|
||||
const email2 = "gmail.com";
|
||||
const email2 = 'gmail.com';
|
||||
expect(isValidEmail(email2)).toBe(false);
|
||||
|
||||
const email23 = "";
|
||||
const email23 = '';
|
||||
expect(isValidEmail(email23)).toBe(false);
|
||||
});
|
||||
|
||||
test("validate password", () => {
|
||||
const pass1 = "aaaaaaaa";
|
||||
test('validate password', () => {
|
||||
const pass1 = 'aaaaaaaa';
|
||||
expect(isValidPassword(pass1)).toBe(true);
|
||||
|
||||
const pass2 = "abcdefg";
|
||||
const pass2 = 'abcdefg';
|
||||
expect(isValidPassword(pass2)).toBe(false);
|
||||
|
||||
const pass3 = "";
|
||||
const pass3 = '';
|
||||
expect(isValidPassword(pass3)).toBe(false);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
function isValidEmail(email: string) {
|
||||
const validRegex =
|
||||
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
|
||||
const validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
|
||||
if (email.match(validRegex)) {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { expect, test } from "vitest";
|
||||
import { isImage } from "./isImage";
|
||||
import { AttachmentType } from "@/types/case";
|
||||
import { expect, test } from 'vitest';
|
||||
import { isImage } from './isImage';
|
||||
import { AttachmentType } from '@/types/case';
|
||||
|
||||
test("isImage", () => {
|
||||
test('isImage', () => {
|
||||
type CaseAttachmentType = {
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
@@ -19,17 +19,17 @@ test("isImage", () => {
|
||||
|
||||
const sampleAttachment: AttachmentType = {
|
||||
id: 1,
|
||||
title: "",
|
||||
detail: "",
|
||||
path: "",
|
||||
title: '',
|
||||
detail: '',
|
||||
path: '',
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
caseAttachments: sampleCaseAttachment,
|
||||
};
|
||||
|
||||
sampleAttachment.path = "public/uploads/abc.png";
|
||||
sampleAttachment.path = 'public/uploads/abc.png';
|
||||
expect(isImage(sampleAttachment)).toBe(true);
|
||||
|
||||
sampleAttachment.path = "public/uploads/abc.mp3";
|
||||
sampleAttachment.path = 'public/uploads/abc.mp3';
|
||||
expect(isImage(sampleAttachment)).toBe(false);
|
||||
});
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import Config from "@/config/config";
|
||||
import Config from '@/config/config';
|
||||
const apiServer = Config.apiServer;
|
||||
|
||||
async function fetchDownloadAttachment(
|
||||
attachmentId: number,
|
||||
downloadFileName: string
|
||||
) {
|
||||
async function fetchDownloadAttachment(attachmentId: number, downloadFileName: string) {
|
||||
const fetchOptions = {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -23,14 +20,14 @@ async function fetchDownloadAttachment(
|
||||
const blob = await response.blob();
|
||||
const downloadUrl = window.URL.createObjectURL(blob);
|
||||
|
||||
const link = document.createElement("a");
|
||||
const link = document.createElement('a');
|
||||
link.href = downloadUrl;
|
||||
link.download = downloadFileName;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
} catch (error: any) {
|
||||
console.error("Error downloading file:", error);
|
||||
console.error('Error downloading file:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -39,31 +36,31 @@ async function fetchCreateAttachments(caseId: number, files: File[]) {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
formData.append("files", files[i]);
|
||||
formData.append('files', files[i]);
|
||||
}
|
||||
|
||||
const url = `${apiServer}/attachments?parentCaseId=${caseId}`;
|
||||
const response = await fetch(url, {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Network response was not ok");
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
|
||||
const responseData = await response.json();
|
||||
return responseData;
|
||||
} catch (error: any) {
|
||||
console.error("Error uploading files:", error);
|
||||
console.error('Error uploading files:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchDeleteAttachment(attachmentId: number) {
|
||||
const fetchOptions = {
|
||||
method: "DELETE",
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -75,13 +72,9 @@ async function fetchDeleteAttachment(attachmentId: number) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error("Error deleting file:", error);
|
||||
console.error('Error deleting file:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
fetchDownloadAttachment,
|
||||
fetchCreateAttachments,
|
||||
fetchDeleteAttachment,
|
||||
};
|
||||
export { fetchDownloadAttachment, fetchCreateAttachments, fetchDeleteAttachment };
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { AttachmentType } from "@/types/case";
|
||||
import { AttachmentType } from '@/types/case';
|
||||
|
||||
function isImage(attachmentFile: AttachmentType) {
|
||||
let path = attachmentFile.path;
|
||||
let extension = path.substring(path.lastIndexOf(".") + 1).toLowerCase();
|
||||
let extension = path.substring(path.lastIndexOf('.') + 1).toLowerCase();
|
||||
if (
|
||||
extension === "png" ||
|
||||
extension === "jpg" ||
|
||||
extension === "jpeg" ||
|
||||
extension === "gif" ||
|
||||
extension === "bmp" ||
|
||||
extension === "svg"
|
||||
extension === 'png' ||
|
||||
extension === 'jpg' ||
|
||||
extension === 'jpeg' ||
|
||||
extension === 'gif' ||
|
||||
extension === 'bmp' ||
|
||||
extension === 'svg'
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import Config from "@/config/config";
|
||||
import Config from '@/config/config';
|
||||
const apiServer = Config.apiServer;
|
||||
|
||||
async function fetchCreateStep(newStepNo: number, parentCaseId: number) {
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -18,16 +18,16 @@ async function fetchCreateStep(newStepNo: number, parentCaseId: number) {
|
||||
}
|
||||
return await response.json();
|
||||
} catch (error: any) {
|
||||
console.error("Error deleting project:", error);
|
||||
console.error('Error deleting project:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchDeleteStep(stepId: number, parentCaseId: number) {
|
||||
const fetchOptions = {
|
||||
method: "DELETE",
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -39,12 +39,9 @@ async function fetchDeleteStep(stepId: number, parentCaseId: number) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error("Error deleting project:", error);
|
||||
console.error('Error deleting project:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
fetchCreateStep,
|
||||
fetchDeleteStep,
|
||||
};
|
||||
export { fetchCreateStep, fetchDeleteStep };
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import Config from "@/config/config";
|
||||
import Config from '@/config/config';
|
||||
const apiServer = Config.apiServer;
|
||||
import { CaseType } from "@/types/case";
|
||||
import { CaseType } from '@/types/case';
|
||||
|
||||
async function fetchCase(caseId: number) {
|
||||
const url = `${apiServer}/cases/${caseId}`;
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ async function fetchCase(caseId: number) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error fetching data:", error.message);
|
||||
console.error('Error fetching data:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ async function fetchCases(folderId: string) {
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -42,28 +42,28 @@ async function fetchCases(folderId: string) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error fetching data:", error.message);
|
||||
console.error('Error fetching data:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function createCase(folderId: string) {
|
||||
const newCase = {
|
||||
title: "untitled case",
|
||||
title: 'untitled case',
|
||||
state: 0,
|
||||
priority: 2,
|
||||
type: 0,
|
||||
automationStatus: 0,
|
||||
description: "",
|
||||
description: '',
|
||||
template: 0,
|
||||
preConditions: "",
|
||||
expectedResults: "",
|
||||
preConditions: '',
|
||||
expectedResults: '',
|
||||
folderId: folderId,
|
||||
};
|
||||
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(newCase),
|
||||
};
|
||||
@@ -78,16 +78,16 @@ async function createCase(folderId: string) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error creating case:", error);
|
||||
console.error('Error creating case:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function updateCase(updateCaseData: CaseType) {
|
||||
const fetchOptions = {
|
||||
method: "PUT",
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(updateCaseData),
|
||||
};
|
||||
@@ -102,16 +102,16 @@ async function updateCase(updateCaseData: CaseType) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error updating project:", error);
|
||||
console.error('Error updating project:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteCase(caseId: number) {
|
||||
const fetchOptions = {
|
||||
method: "DELETE",
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -123,16 +123,16 @@ async function deleteCase(caseId: number) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error("Error deleting case:", error);
|
||||
console.error('Error deleting case:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteCases(deleteCases: string[]) {
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ caseIds: deleteCases }),
|
||||
};
|
||||
@@ -145,16 +145,9 @@ async function deleteCases(deleteCases: string[]) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error("Error deleting cases:", error);
|
||||
console.error('Error deleting cases:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
fetchCase,
|
||||
fetchCases,
|
||||
updateCase,
|
||||
createCase,
|
||||
deleteCase,
|
||||
deleteCases,
|
||||
};
|
||||
export { fetchCase, fetchCases, updateCase, createCase, deleteCase, deleteCases };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Config from "@/config/config";
|
||||
import Config from '@/config/config';
|
||||
const apiServer = Config.apiServer;
|
||||
|
||||
/**
|
||||
@@ -8,9 +8,9 @@ async function fetchFolders(projectId: string) {
|
||||
try {
|
||||
const url = `${apiServer}/folders?projectId=${projectId}`;
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -21,19 +21,14 @@ async function fetchFolders(projectId: string) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error fetching data:", error.message);
|
||||
console.error('Error fetching data:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create project
|
||||
*/
|
||||
async function createFolder(
|
||||
name: string,
|
||||
detail: string,
|
||||
projectId: strting,
|
||||
parentFolderId: number
|
||||
) {
|
||||
async function createFolder(name: string, detail: string, projectId: strting, parentFolderId: number) {
|
||||
const newFolderData = {
|
||||
name: name,
|
||||
detail: detail,
|
||||
@@ -42,9 +37,9 @@ async function createFolder(
|
||||
};
|
||||
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(newFolderData),
|
||||
};
|
||||
@@ -59,7 +54,7 @@ async function createFolder(
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error creating new project:", error);
|
||||
console.error('Error creating new project:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -67,13 +62,7 @@ async function createFolder(
|
||||
/**
|
||||
* Update folder
|
||||
*/
|
||||
async function updateFolder(
|
||||
folderId: number,
|
||||
name: string,
|
||||
detail: string,
|
||||
projectId: string,
|
||||
parentFolderId: number
|
||||
) {
|
||||
async function updateFolder(folderId: number, name: string, detail: string, projectId: string, parentFolderId: number) {
|
||||
const updateFolderData = {
|
||||
name: name,
|
||||
detail: detail,
|
||||
@@ -82,9 +71,9 @@ async function updateFolder(
|
||||
};
|
||||
|
||||
const fetchOptions = {
|
||||
method: "PUT",
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(updateFolderData),
|
||||
};
|
||||
@@ -99,7 +88,7 @@ async function updateFolder(
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error updating project:", error);
|
||||
console.error('Error updating project:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -109,9 +98,9 @@ async function updateFolder(
|
||||
*/
|
||||
async function deleteFolder(folderId: number) {
|
||||
const fetchOptions = {
|
||||
method: "DELETE",
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -123,7 +112,7 @@ async function deleteFolder(folderId: number) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error("Error deleting project:", error);
|
||||
console.error('Error deleting project:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ProjectType } from "@/types/project";
|
||||
import { testTypes, priorities, testRunCaseStatus } from "@/config/selection";
|
||||
import { HomeMessages } from "./page";
|
||||
import { ProjectType } from '@/types/project';
|
||||
import { testTypes, priorities, testRunCaseStatus } from '@/config/selection';
|
||||
import { HomeMessages } from './page';
|
||||
|
||||
// aggregate folder, case, run mum
|
||||
function aggregateBasicInfo(project: ProjectType) {
|
||||
@@ -85,9 +85,4 @@ function aggregateProgress(project: ProjectType, messages: HomeMessages) {
|
||||
return { series, categories };
|
||||
}
|
||||
|
||||
export {
|
||||
aggregateBasicInfo,
|
||||
aggregateTestType,
|
||||
aggregateTestPriority,
|
||||
aggregateProgress,
|
||||
};
|
||||
export { aggregateBasicInfo, aggregateTestType, aggregateTestPriority, aggregateProgress };
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import Config from "@/config/config";
|
||||
import Config from '@/config/config';
|
||||
const apiServer = Config.apiServer;
|
||||
import { RunType, RunCaseInfoType } from "@/types/run";
|
||||
import { RunType, RunCaseInfoType } from '@/types/run';
|
||||
|
||||
async function fetchRun(runId: string) {
|
||||
const url = `${apiServer}/runs/${runId}`;
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ async function fetchRun(runId: string) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error fetching data:", error.message);
|
||||
console.error('Error fetching data:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ async function fetchRuns(projectId: string) {
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -42,23 +42,23 @@ async function fetchRuns(projectId: string) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error fetching data:", error.message);
|
||||
console.error('Error fetching data:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function createRun(projectId: string) {
|
||||
const newTestRun = {
|
||||
name: "untitled run",
|
||||
name: 'untitled run',
|
||||
configurations: 0,
|
||||
description: "",
|
||||
description: '',
|
||||
state: 0,
|
||||
projectId: projectId,
|
||||
};
|
||||
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(newTestRun),
|
||||
};
|
||||
@@ -73,16 +73,16 @@ async function createRun(projectId: string) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error creating new test run:", error);
|
||||
console.error('Error creating new test run:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function updateRun(updateTestRun: RunType) {
|
||||
const fetchOptions = {
|
||||
method: "PUT",
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(updateTestRun),
|
||||
};
|
||||
@@ -97,16 +97,16 @@ async function updateRun(updateTestRun: RunType) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error updating run:", error);
|
||||
console.error('Error updating run:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteRun(runId: number) {
|
||||
const fetchOptions = {
|
||||
method: "DELETE",
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -118,7 +118,7 @@ async function deleteRun(runId: number) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error("Error deleting run:", error);
|
||||
console.error('Error deleting run:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -128,9 +128,9 @@ async function fetchRunCases(runId: string) {
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -141,15 +141,15 @@ async function fetchRunCases(runId: string) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error fetching data:", error.message);
|
||||
console.error('Error fetching data:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function createRunCase(runId: string, caseId: number) {
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -163,16 +163,16 @@ async function createRunCase(runId: string, caseId: number) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error creating new runcase:", error);
|
||||
console.error('Error creating new runcase:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function updateRunCase(runId: string, caseId: number, status: number) {
|
||||
const fetchOptions = {
|
||||
method: "PUT",
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -186,16 +186,16 @@ async function updateRunCase(runId: string, caseId: number, status: number) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error updating runcase:", error);
|
||||
console.error('Error updating runcase:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function bulkCreateRunCases(runCaseInfo: RunCaseInfoType[]) {
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(runCaseInfo),
|
||||
};
|
||||
@@ -210,16 +210,16 @@ async function bulkCreateRunCases(runCaseInfo: RunCaseInfoType[]) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error creating new runcase:", error);
|
||||
console.error('Error creating new runcase:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteRunCase(runId: string, caseId: number) {
|
||||
const fetchOptions = {
|
||||
method: "DELETE",
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -231,16 +231,16 @@ async function deleteRunCase(runId: string, caseId: number) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error("Error deleting runcase:", error);
|
||||
console.error('Error deleting runcase:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function bulkDeleteRunCases(runCaseInfo: RunCaseInfoType[]) {
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(runCaseInfo),
|
||||
};
|
||||
@@ -253,7 +253,7 @@ async function bulkDeleteRunCases(runCaseInfo: RunCaseInfoType[]) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error("Error deleting runcase:", error);
|
||||
console.error('Error deleting runcase:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Config from "@/config/config";
|
||||
import Config from '@/config/config';
|
||||
const apiServer = Config.apiServer;
|
||||
|
||||
/**
|
||||
@@ -9,9 +9,9 @@ async function fetchProjects() {
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ async function fetchProjects() {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error fetching data:", error.message);
|
||||
console.error('Error fetching data:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ async function createProject(name: string, detail: string) {
|
||||
};
|
||||
|
||||
const fetchOptions = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(newProjectData),
|
||||
};
|
||||
@@ -53,7 +53,7 @@ async function createProject(name: string, detail: string) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error creating new project:", error);
|
||||
console.error('Error creating new project:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -68,9 +68,9 @@ async function updateProject(projectId: number, name: string, detail: string) {
|
||||
};
|
||||
|
||||
const fetchOptions = {
|
||||
method: "PUT",
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(updatedProjectData),
|
||||
};
|
||||
@@ -85,7 +85,7 @@ async function updateProject(projectId: number, name: string, detail: string) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("Error updating project:", error);
|
||||
console.error('Error updating project:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -95,9 +95,9 @@ async function updateProject(projectId: number, name: string, detail: string) {
|
||||
*/
|
||||
async function deleteProject(projectId: number) {
|
||||
const fetchOptions = {
|
||||
method: "DELETE",
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -109,7 +109,7 @@ async function deleteProject(projectId: number) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error("Error deleting project:", error);
|
||||
console.error('Error deleting project:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user