oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1//go:build browser
2
3package thintest
4
5import (
6 "context"
7 "os"
8 "path/filepath"
9 "strconv"
10 "testing"
11
12 "github.com/chromedp/chromedp"
13)
14
15func TestBrowserAutonomySettings(t *testing.T) {
16 r := &toolRig{rig: newRig(t)}
17 if err := r.inst.DB.G.Exec("INSERT INTO chat_projects(id,repo,title,state,revision) VALUES ('autonomy-project','amadan.net/oficina/sample','Sample project','active',1)").Error; err != nil {
18 t.Fatal(err)
19 }
20 for _, size := range settingsSizes {
21 p := openInner(t, r.inst.URL, r.inst.Cookie(), size.w, size.h, size.touch, "light", "no-preference")
22 p.open("/conversation/settings/autonomy")
23 p.check(`document.documentElement.scrollWidth<=innerWidth`, "settings overflow")
24 p.check(`document.querySelectorAll('#autonomy input[type=checkbox]').length===3`, "three choices")
25 p.check(`(()=>{for(const e of document.querySelectorAll('#autonomy input[type=checkbox]')){if(!document.querySelector('label[for="'+e.id+'"]')||!document.getElementById(e.getAttribute('aria-describedby')))return false}return true})()`, "switch labels and descriptions")
26 p.check(`(()=>{window.__page=1;for(const e of document.querySelectorAll('#autonomy input[type=checkbox]'))e.checked=true;return true})()`, "choose settings")
27 p.click(`#autonomy button[type=submit]`)
28 p.wait(`document.querySelector('#autonomy input[name=revision]').value!=='0'`, "saved revision")
29 p.check(`window.__page===1`, "save reloaded the page")
30 if dir := os.Getenv("EQUIPO_AUTONOMY_SHOTS"); dir != "" {
31 var shot []byte
32 p.do(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
33 var err error
34 shot, err = chromedp.FullScreenshot(90)(ctx, target)
35 return err
36 }))
37 if err := os.WriteFile(filepath.Join(dir, "autonomy-"+strconv.FormatInt(size.w, 10)+".png"), shot, 0600); err != nil {
38 t.Fatal(err)
39 }
40 }
41 p.stop()
42 }
43}
44