test(backend): cover locations and overtime level in the HTTP smoke test
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qu4xuNCkFLDByYWUrjanny
This commit is contained in:
parent
4745a45f1b
commit
6aea484c45
1 changed files with 16 additions and 2 deletions
|
|
@ -41,8 +41,18 @@ func TestSmokeFlow(t *testing.T) {
|
|||
t.Fatalf("no token in %s", reg.Body.String())
|
||||
}
|
||||
|
||||
if rec := call(http.MethodPost, "/api/v1/time-entries/start", tok.Token, ""); rec.Code != http.StatusCreated {
|
||||
t.Fatalf("start = %d %s", rec.Code, rec.Body.String())
|
||||
locs := call(http.MethodGet, "/api/v1/locations", tok.Token, "")
|
||||
var places []struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
if err := json.Unmarshal(locs.Body.Bytes(), &places); err != nil || len(places) != 3 || places[1].Name != "Homeoffice" {
|
||||
t.Fatalf("default locations = %d %s", locs.Code, locs.Body.String())
|
||||
}
|
||||
|
||||
start := call(http.MethodPost, "/api/v1/time-entries/start", tok.Token, fmt.Sprintf(`{"locationId":%d}`, places[1].ID))
|
||||
if start.Code != http.StatusCreated || !strings.Contains(start.Body.String(), `"locationName":"Homeoffice"`) {
|
||||
t.Fatalf("start = %d %s", start.Code, start.Body.String())
|
||||
}
|
||||
if rec := call(http.MethodPost, "/api/v1/time-entries/stop", tok.Token, ""); rec.Code != http.StatusOK {
|
||||
t.Fatalf("stop = %d %s", rec.Code, rec.Body.String())
|
||||
|
|
@ -60,6 +70,10 @@ func TestSmokeFlow(t *testing.T) {
|
|||
t.Fatalf("overview = %d %s", ov.Code, ov.Body.String())
|
||||
}
|
||||
|
||||
if !strings.Contains(ov.Body.String(), `"level":"ok"`) || !strings.Contains(ov.Body.String(), `"warnHours":20`) {
|
||||
t.Fatalf("overview lacks the overtime level: %s", ov.Body.String())
|
||||
}
|
||||
|
||||
csv := call(http.MethodGet, "/api/v1/export/csv?from="+day+"&to="+day, tok.Token, "")
|
||||
if csv.Code != http.StatusOK || !strings.Contains(csv.Body.String(), "Smoke") {
|
||||
t.Fatalf("csv = %d %s", csv.Code, csv.Body.String())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue