package slidestest import ( "encoding/json" "testing" ) // The talk carries the deck's uploaded fonts as the font manifest does, // under the session, so a presenter or slide window that holds it learns // a font the deck took on after it opened (final review, I6). func TestTheTalkCarriesTheDecksUploadedFonts(t *testing.T) { a, _ := newFontsApp(t) cookies := signedIn(t, a, allowedAddress) token := mintAgent(t, a, cookies, "claude") sqid := apiDeck(t, a, token, "Talk") brand := brandFont(t, "LiberationSerif-Regular.ttf", "Brand") uploadFonts(t, a, cookies, upFile{"brand.ttf", brand}) session, _ := startPresenting(t, a, "/d/"+sqid, cookies) var before struct { Uploaded map[string]any `json:"uploaded"` } json.Unmarshal(talkRequest(a, session, "", "", cookies).Body.Bytes(), &before) if before.Uploaded != nil { t.Errorf("a deck with no fonts of its own: uploaded %v", before.Uploaded) } useFamily(t, a, token, sqid, pickedFamily(t, a, sqid, "Brand", cookies)) var after struct { Uploaded map[string]struct { CSS string `json:"css"` Faces []struct { URL string `json:"url"` Format string `json:"format"` Weight any `json:"weight"` Style string `json:"style"` } `json:"faces"` } `json:"uploaded"` } rec := talkRequest(a, session, "", "", cookies) if err := json.Unmarshal(rec.Body.Bytes(), &after); err != nil { t.Fatal(err) } fam, ok := after.Uploaded["u:Brand"] if !ok || fam.CSS != "Brand" || len(fam.Faces) != 1 { t.Fatalf("the talk's uploaded fonts: %s", rec.Body.String()[:min(400, rec.Body.Len())]) } if f := fam.Faces[0]; f.URL != "/p/"+session+"/fonts/"+sha(brand) || f.Format != "truetype" || f.Style != "normal" { t.Errorf("the face is %+v", f) } }