package thintest import ( "regexp" "testing" ) // inlineStyle is a style attribute in markup, which production's policy // refuses (style-src has no 'unsafe-inline'); the page then draws without // it (Paul's staging: avatar hues, meter widths, the mark's motes). var inlineStyle = regexp.MustCompile(`<[^>]*\sstyle=`) // noInlineStyles: no screen of the gallery renders an inline style // attribute: colours and widths come from classes and data attributes. // TestPagesInnerScreens runs it on its gallery (one gallery, one budget). func noInlineStyles(t *testing.T, g *gallery) { t.Helper() a := g.a owner := a.inst.Cookie() paths := []string{"/conversation", "/tasks", "/projects", "/needs-you", "/housekeeping", "/conversation/settings", "/conversation/settings/thinking", "/conversation/settings/connections", "/conversation/settings/connections/add", "/conversation/settings/machines", "/conversation/settings/machines/add", "/conversation/settings/housekeeping", "/conversation/settings/notebook", "/work"} for _, id := range []string{g.unchecked, g.stopped, g.noras, g.merging, g.running, g.looking} { if id != "" { paths = append(paths, "/tasks/"+id) } } projects, err := a.client.Projects(a.ctx) if err != nil { t.Fatal(err) } for _, p := range projects.Items { paths = append(paths, "/projects/"+p.ID) } for _, path := range paths { page := a.get(owner, path, 200) if m := inlineStyle.FindAllString(page, 3); len(m) > 0 { t.Errorf("%s renders inline styles: %q", path, m) } } }