chore: update
This commit is contained in:
@@ -11,6 +11,7 @@ import com.drinkool.entities.ShiftRegistrationEntity;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -40,13 +41,12 @@ public class ShiftServiceTest {
|
||||
.header(InternalValue.role, Role.Manager)
|
||||
.header(InternalValue.userId, ownerId)
|
||||
.contentType("application/json")
|
||||
.body("{ \"query\": \"{ allShifts { name startTime } }\" }")
|
||||
.body("{ \"query\": \"{ allShifts { startTime } }\" }")
|
||||
.when()
|
||||
.post("/graphql")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("data.allShifts", hasSize(1))
|
||||
.body("data.allShifts[0].name", is("Ca Sáng"));
|
||||
.body("data.allShifts", hasSize(1));
|
||||
}
|
||||
|
||||
// --- TEST MUTATIONS ---
|
||||
@@ -54,18 +54,31 @@ public class ShiftServiceTest {
|
||||
@Test
|
||||
void testCreateShift_AsManager() {
|
||||
String query = """
|
||||
mutation Create($input: CreateShiftInput!)
|
||||
{ createShift(shiftInput: $input) { id name } }""";
|
||||
mutation createShift($shiftInput: CreateShiftInput!) {
|
||||
createShift(shiftInput: $shiftInput) {
|
||||
id
|
||||
date
|
||||
startTime
|
||||
endTime
|
||||
maxStaff
|
||||
wage
|
||||
registeredStaff {
|
||||
staffId
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
Map<String, Object> input = new HashMap<>();
|
||||
input.put("name", "Ca Sáng");
|
||||
input.put("date", "26/04/2026");
|
||||
input.put("startTime", "08:00:00");
|
||||
input.put("endTime", "12:00:00");
|
||||
input.put("maxStaff", 5);
|
||||
input.put("wage", 1000000);
|
||||
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("query", query);
|
||||
body.put("variables", Map.of("input", input));
|
||||
body.put("variables", Map.of("shiftInput", input));
|
||||
|
||||
UUID ownerId = createMockOwner();
|
||||
createMockEatery(ownerId);
|
||||
@@ -78,8 +91,7 @@ public class ShiftServiceTest {
|
||||
.when()
|
||||
.post("/graphql")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("data.createShift.name", is("Ca Sáng"));
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -196,8 +208,10 @@ public class ShiftServiceTest {
|
||||
) {
|
||||
ShiftEntity shift = new ShiftEntity();
|
||||
shift.eatery = eatery;
|
||||
shift.date = new Date();
|
||||
shift.startTime = LocalTime.parse(start);
|
||||
shift.endTime = LocalTime.parse(end);
|
||||
shift.wage = 10000;
|
||||
shift.maxStaff = 5;
|
||||
shift.persist();
|
||||
return shift;
|
||||
|
||||
Reference in New Issue
Block a user