oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package thintest
2
3import (
4 "regexp"
5 "testing"
6)
7
8// inlineStyle is a style attribute in markup, which production's policy
9// refuses (style-src has no 'unsafe-inline'); the page then draws without
10// it (Paul's staging: avatar hues, meter widths, the mark's motes).
11var inlineStyle = regexp.MustCompile(`<[^>]*\sstyle=`)
12
13// noInlineStyles: no screen of the gallery renders an inline style
14// attribute: colours and widths come from classes and data attributes.
15// TestPagesInnerScreens runs it on its gallery (one gallery, one budget).
16func noInlineStyles(t *testing.T, g *gallery) {
17 t.Helper()
18 a := g.a
19 owner := a.inst.Cookie()
20 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"}
21 for _, id := range []string{g.unchecked, g.stopped, g.noras, g.merging, g.running, g.looking} {
22 if id != "" {
23 paths = append(paths, "/tasks/"+id)
24 }
25 }
26 projects, err := a.client.Projects(a.ctx)
27 if err != nil {
28 t.Fatal(err)
29 }
30 for _, p := range projects.Items {
31 paths = append(paths, "/projects/"+p.ID)
32 }
33 for _, path := range paths {
34 page := a.get(owner, path, 200)
35 if m := inlineStyle.FindAllString(page, 3); len(m) > 0 {
36 t.Errorf("%s renders inline styles: %q", path, m)
37 }
38 }
39}
40