feat: Test case movement (#290)

This commit is contained in:
kimatata
2025-10-05 16:42:06 +09:00
committed by GitHub
parent 49498adf34
commit b87ce0c3be
13 changed files with 368 additions and 105 deletions

View File

@@ -125,6 +125,28 @@ async function updateCase(jwt: string, updateCaseData: CaseType) {
}
}
export async function moveCases(jwt: string, moveCaseIds: number[], targetFolderId: number, projectId: number) {
const fetchOptions = {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${jwt}`,
},
body: JSON.stringify({ caseIds: moveCaseIds, targetFolderId }),
};
const url = `${apiServer}/cases/move?projectId=${projectId}`;
try {
const response = await fetch(url, fetchOptions);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
return data;
} catch (error: unknown) {
logError('Error updating project', error);
}
}
async function deleteCases(jwt: string, deleteCaseIds: number[], projectId: number) {
const fetchOptions = {
method: 'POST',

View File

@@ -0,0 +1,19 @@
const eventBus = new EventTarget();
const TEST_CASE_MOVE = 'testCasesMove';
type MoveEventDetail = {
testCaseIds: number[];
targetFolderId: number;
};
export const emitMoveEvent = (ids: number[], targetFolderId: number) => {
eventBus.dispatchEvent(
new CustomEvent(TEST_CASE_MOVE, { detail: { testCaseIds: ids, targetFolderId: targetFolderId } })
);
};
export const onMoveEvent = (listener: (event: CustomEvent<MoveEventDetail>) => void) => {
const handler = (e: Event) => listener(e as CustomEvent);
eventBus.addEventListener(TEST_CASE_MOVE, handler);
return () => eventBus.removeEventListener(TEST_CASE_MOVE, handler);
};