From 6dba7ab60a7a80f19c7731ee8dd2aea87d9f589b Mon Sep 17 00:00:00 2001 From: kristianwind Date: Sat, 21 Nov 2026 13:49:27 +0100 Subject: [PATCH 1/3] =?UTF-8?q?feat(alle=20opgaver):=20et=20endepunkt=20me?= =?UTF-8?q?d=20alle=20=C3=A5bne=20opgaver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GET /api/v1/all-tasks: hver åben opgave på øverste niveau i hvert aktivt projekt, man kan se. Arkiverede projekter er udeladt, underopgaver vises som deres forælders tal. Højst 2000, og svaret siger det, når der var flere. Og en kalendertest, der var blevet rød på main: dens begivenhed lå fast på 20. august, og vinduet holder 90 dage tilbage. Co-Authored-By: Claude Opus 5.5 --- docs/openapi.yaml | 28 +++++++++++++ internal/httpapi/calendar_test.go | 24 +++++++---- internal/httpapi/edition_test.go | 1 + internal/httpapi/server.go | 1 + internal/httpapi/views_handlers.go | 40 ++++++++++++++++++ internal/httpapi/views_test.go | 67 ++++++++++++++++++++++++++++++ internal/store/tasks.go | 10 ++++- 7 files changed, 162 insertions(+), 9 deletions(-) diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 197f089..d01dd3d 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -2693,6 +2693,34 @@ paths: type: array items: { $ref: "#/components/schemas/Task" } + /api/v1/all-tasks: + get: + tags: [views] + summary: Every open task, for the "All tasks" view. + description: | + Every open, top-level task in every active (not archived) project you can + see. Sub-tasks are left out: they show as their parent's count, as they do + in a project. + + Flat rather than grouped. The client groups by project group and project, + and it already holds both lists with their names, colours and order. + + At most 2000 tasks are returned. `truncated` is true when there were more, + so a client can say that the list is not complete rather than showing a + shorter one as if it were. + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + properties: + tasks: + type: array + items: { $ref: "#/components/schemas/Task" } + truncated: { type: boolean } + /api/v1/search: get: tags: [views] diff --git a/internal/httpapi/calendar_test.go b/internal/httpapi/calendar_test.go index 97f5b21..3b30370 100644 --- a/internal/httpapi/calendar_test.go +++ b/internal/httpapi/calendar_test.go @@ -141,16 +141,25 @@ func TestAuthorizeWithoutAClientSaysSo(t *testing.T) { // The whole path, minus the consent screen: sync fetches the list, refreshes the // events of what was chosen, and the grid endpoint answers with them. func TestSyncFetchesTheChosenCalendarsAndTheGridReadsThem(t *testing.T) { + // A week from today, not a fixed date: verdande only keeps a window around now, + // and a fixture pinned to August aged out of it in November and turned this + // test red with "events = 0" — which reads like the sync broke. + day := time.Now().AddDate(0, 0, 7) + on := day.Format("2006-01-02") + next := day.AddDate(0, 0, 1).Format("2006-01-02") + grid := "/api/v1/calendar/events?from=" + day.AddDate(0, 0, -10).Format("2006-01-02") + + "&to=" + day.AddDate(0, 0, 10).Format("2006-01-02") + g := newFakeCalendarGoogle(t) g.events["fam"] = []map[string]any{ {"id": "e1", "summary": "Bestyrelsesmøde", "htmlLink": "https://calendar.google.com/e1", - "start": map[string]string{"dateTime": "2026-08-20T14:00:00+02:00"}, - "end": map[string]string{"dateTime": "2026-08-20T15:30:00+02:00"}}, + "start": map[string]string{"dateTime": on + "T14:00:00+01:00"}, + "end": map[string]string{"dateTime": on + "T15:30:00+01:00"}}, } g.events["kw@nolimit.dk"] = []map[string]any{ {"id": "e2", "summary": "Skal ikke med", - "start": map[string]string{"date": "2026-08-21"}, - "end": map[string]string{"date": "2026-08-22"}}, + "start": map[string]string{"date": next}, + "end": map[string]string{"date": day.AddDate(0, 0, 2).Format("2006-01-02")}}, } ts, user := connectedCalendar(t, g, nil) @@ -209,8 +218,7 @@ func TestSyncFetchesTheChosenCalendarsAndTheGridReadsThem(t *testing.T) { t.Fatalf("events = %v, want 1 — only the chosen calendar", body["events"]) } - resp, body = ts.do(t, "GET", - "/api/v1/calendar/events?from=2026-08-01&to=2026-08-31", nil) + resp, body = ts.do(t, "GET", grid, nil) if resp.StatusCode != http.StatusOK { t.Fatalf("events: status %d, body %v", resp.StatusCode, body) } @@ -219,7 +227,7 @@ func TestSyncFetchesTheChosenCalendarsAndTheGridReadsThem(t *testing.T) { t.Fatalf("got %d events, want 1: %v", len(events), body["events"]) } event := events[0].(map[string]any) - if event["summary"] != "Bestyrelsesmøde" || event["start_day"] != "2026-08-20" { + if event["summary"] != "Bestyrelsesmøde" || event["start_day"] != on { t.Errorf("the event came back as %v", event) } // The calendar's colour rides along, or the chip has to ask for it per row. @@ -235,7 +243,7 @@ func TestSyncFetchesTheChosenCalendarsAndTheGridReadsThem(t *testing.T) { // And it is one person's calendar. Somebody else on the same instance sees // nothing of it. other := ts.newUser(t, "andreas@example.dk", "Andreas") - _, body = other.do(t, "GET", "/api/v1/calendar/events?from=2026-08-01&to=2026-08-31", nil) + _, body = other.do(t, "GET", grid, nil) if events, _ := body["events"].([]any); len(events) != 0 { t.Errorf("somebody else's calendar was visible: %v", body["events"]) } diff --git a/internal/httpapi/edition_test.go b/internal/httpapi/edition_test.go index a3f0135..9c8fd9b 100644 --- a/internal/httpapi/edition_test.go +++ b/internal/httpapi/edition_test.go @@ -64,6 +64,7 @@ func TestNotesEditionServesOnlyItsOwnRoutes(t *testing.T) { "DELETE /caldav/{userID}/{projectID}/{taskFile}", "GET /.well-known/caldav", "GET /api/v1/ai/plan", + "GET /api/v1/all-tasks", "GET /api/v1/delegated", "GET /api/v1/export/projects.zip", "GET /api/v1/export/projects/{projectID}.csv", diff --git a/internal/httpapi/server.go b/internal/httpapi/server.go index 7624811..367ca89 100644 --- a/internal/httpapi/server.go +++ b/internal/httpapi/server.go @@ -645,6 +645,7 @@ func New(cfg *config.Config, db *store.DB, log *slog.Logger, web fs.FS) *Server }) r.Get("/upcoming", s.handleUpcoming) r.Get("/delegated", s.handleDelegated) + r.Get("/all-tasks", s.handleAllTasks) } r.Get("/people", s.handlePeople) r.Get("/search", s.handleSearch) diff --git a/internal/httpapi/views_handlers.go b/internal/httpapi/views_handlers.go index 6aaa023..d969b47 100644 --- a/internal/httpapi/views_handlers.go +++ b/internal/httpapi/views_handlers.go @@ -184,6 +184,46 @@ func (s *Server) handleDelegated(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusOK, map[string]any{"people": out}) } +// allTasksCap is how many rows "Alle opgaver" will send. Far above what one +// person has open; it exists so an account with tens of thousands of imported +// tasks gets a slow page rather than an unbounded response. When it is reached the +// response says so, because a list that quietly stops is a list that lies about +// what is left. +const allTasksCap = 2000 + +// handleAllTasks is "Alle opgaver": every open task in every active project the +// caller can see, top level only — a sub-task is shown as its parent's count, the +// way a project shows it, rather than as a second loose row. +// +// Flat, not grouped. The grouping is by project group and project, and the client +// already holds both lists with their names, colours and order; a server-side +// grouping would be a second copy of the sidebar's order to keep in step with the +// first. +func (s *Server) handleAllTasks(w http.ResponseWriter, r *http.Request) { + user := userFrom(r.Context()) + + tasks, err := s.db.ListTasks(r.Context(), user.ID, store.TaskFilter{ + TopLevelOnly: true, + ActiveProjectsOnly: true, + // One past the cap, so "exactly the cap" and "more than the cap" can be told + // apart. + Limit: allTasksCap + 1, + }) + if err != nil { + s.internal(w, r, "all tasks", err) + return + } + + truncated := len(tasks) > allTasksCap + if truncated { + tasks = tasks[:allTasksCap] + } + writeJSON(w, http.StatusOK, map[string]any{ + "tasks": toTaskList(tasks), + "truncated": truncated, + }) +} + // sortByName orders the groups the way a list of people reads. Insertion sort: // this is a handful of entries, and it keeps the package free of a dependency on // sort just for this. diff --git a/internal/httpapi/views_test.go b/internal/httpapi/views_test.go index 371ef5e..f39a589 100644 --- a/internal/httpapi/views_test.go +++ b/internal/httpapi/views_test.go @@ -200,3 +200,70 @@ func TestPeopleIsWhoYouShareWorkWith(t *testing.T) { t.Errorf("a stranger is listed: %v", seen) } } + +// "Alle opgaver" is every open task the caller can act on, and the test names +// each thing that must stay out — because a list of everything passes any check +// that only asks whether the right task is in it. +func TestAllTasksIsEveryOpenTopLevelTaskInActiveProjects(t *testing.T) { + ts := newTestServer(t) + ts.bootstrap(t) + + _, a := ts.do(t, "POST", "/api/v1/projects", map[string]any{"name": "Have"}) + _, b := ts.do(t, "POST", "/api/v1/projects", map[string]any{"name": "Hus"}) + _, gone := ts.do(t, "POST", "/api/v1/projects", map[string]any{"name": "Gammelt"}) + + _, parent := ts.do(t, "POST", "/api/v1/tasks", map[string]any{ + "content": "slå græs", "project_id": a["id"], + }) + ts.do(t, "POST", "/api/v1/tasks", map[string]any{ + "content": "find benzin", "project_id": a["id"], "parent_id": parent["id"], + }) + ts.do(t, "POST", "/api/v1/tasks", map[string]any{ + "content": "mal døren", "project_id": b["id"], + }) + _, done := ts.do(t, "POST", "/api/v1/tasks", map[string]any{ + "content": "skift pære", "project_id": b["id"], + }) + ts.do(t, "POST", "/api/v1/tasks/"+done["id"].(string)+"/complete", nil) + ts.do(t, "POST", "/api/v1/tasks", map[string]any{ + "content": "glemt opgave", "project_id": gone["id"], + }) + if resp, body := ts.do(t, "PATCH", "/api/v1/projects/"+gone["id"].(string), + map[string]any{"archived": true}); resp.StatusCode != http.StatusOK { + t.Fatalf("archive: %d %v", resp.StatusCode, body) + } + + // Somebody else's task, in a project the caller is not in. + other := ts.newUser(t, "tredje@example.dk", "Tredje") + _, theirs := other.do(t, "POST", "/api/v1/projects", map[string]any{"name": "Deres"}) + other.do(t, "POST", "/api/v1/tasks", map[string]any{ + "content": "deres opgave", "project_id": theirs["id"], + }) + + resp, body := ts.do(t, "GET", "/api/v1/all-tasks", nil) + if resp.StatusCode != http.StatusOK { + t.Fatalf("all-tasks: %d %v", resp.StatusCode, body) + } + if body["truncated"] != false { + t.Errorf("truncated = %v on five tasks", body["truncated"]) + } + + got := map[string]bool{} + for _, raw := range body["tasks"].([]any) { + got[raw.(map[string]any)["content"].(string)] = true + } + want := map[string]bool{"slå græs": true, "mal døren": true} + for c := range want { + if !got[c] { + t.Errorf("missing %q: %v", c, got) + } + } + for _, c := range []string{"find benzin", "skift pære", "glemt opgave", "deres opgave"} { + if got[c] { + t.Errorf("%q should not be in Alle opgaver: %v", c, got) + } + } + if len(got) != len(want) { + t.Errorf("got %d tasks, want %d: %v", len(got), len(want), got) + } +} diff --git a/internal/store/tasks.go b/internal/store/tasks.go index a6ddc15..708677b 100644 --- a/internal/store/tasks.go +++ b/internal/store/tasks.go @@ -69,7 +69,12 @@ type TaskFilter struct { // TopLevelOnly excludes sub-tasks, which a project view wants because it // renders them nested under their parents rather than as separate rows. TopLevelOnly bool - AssigneeID string + // ActiveProjectsOnly leaves out tasks in archived projects. An archived + // project is one somebody put away; its open tasks are not work that is + // waiting, and a view of "everything I have to do" that fills up with them is + // a view that has to be read past. + ActiveProjectsOnly bool + AssigneeID string // DelegatedBy is the other side of AssigneeID: assigned, but not to this // person. A second field rather than a magic value in AssigneeID, because the // two are different questions — "what is on my plate" and "what have I handed @@ -140,6 +145,9 @@ func (db *DB) ListTasks(ctx context.Context, userID string, f TaskFilter) ([]Tas if f.TopLevelOnly { where = append(where, `t.parent_id IS NULL`) } + if f.ActiveProjectsOnly { + where = append(where, `p.archived = 0`) + } if f.AssigneeID != "" { where = append(where, `t.assignee_id = ?`) args = append(args, f.AssigneeID) From 2aa56e3b6d5069dc0c779eb43f2f759685fa410a Mon Sep 17 00:00:00 2001 From: kristianwind Date: Sat, 21 Nov 2026 13:57:11 +0100 Subject: [PATCH 2/3] =?UTF-8?q?feat(alle=20opgaver):=20=C3=A9n=20side=20me?= =?UTF-8?q?d=20det=20hele,=20inddelt=20i=20grupper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ny indgang i sidebjælken, Alle opgaver (/alle). Som standard inddelt som sidebjælken selv: Indbakke, hver projektgruppe med sine projekter under sig, projekter uden gruppe og det, der er delt med en. Prioritet og dato er de to andre inddelinger, ét tryk væk, og valget huskes. Hver gruppe kan foldes sammen. I prioritet og dato kommer rækkerne fra alle projekter, så de siger, hvor de bor: TaskRow har fået et valgfrit place. Co-Authored-By: Claude Opus 5.5 --- web/e2e/edition.spec.js | 4 +- web/e2e/smoke.spec.js | 86 +++++ web/src/lib/api.js | 1 + web/src/lib/components/Sidebar.svelte | 24 +- web/src/lib/components/TaskRow.svelte | 14 +- web/src/lib/locales/da.js | 16 + web/src/lib/locales/en.js | 16 + web/src/routes/+layout.svelte | 1 + web/src/routes/alle/+page.svelte | 509 ++++++++++++++++++++++++++ 9 files changed, 666 insertions(+), 5 deletions(-) create mode 100644 web/src/routes/alle/+page.svelte diff --git a/web/e2e/edition.spec.js b/web/e2e/edition.spec.js index 685a0f7..0a67315 100644 --- a/web/e2e/edition.spec.js +++ b/web/e2e/edition.spec.js @@ -82,7 +82,7 @@ test('en gemt adresse til en opgaveside fører til noterne i stedet for et blind // Nogen, der har gemt et link fra en fuld instans, skal lande et sted, der // giver mening. Der er ikke sket noget forkert — adressen hører bare til et // andet program end det, der kører her. - for (const sti of ['/upcoming', '/kalender', '/uddelegeret', '/faerdige']) { + for (const sti of ['/upcoming', '/kalender', '/uddelegeret', '/faerdige', '/alle']) { await page.goto(sti); await expect(page).toHaveURL(/\/noter$/); } @@ -111,7 +111,7 @@ test('⌘K finder noter og ikke opgaver', async ({ page }) => { test('opgaveruterne findes slet ikke på serveren', async ({ page }) => { // Det her er forskellen på skjult og fraværende, målt udefra. - for (const sti of ['/api/v1/tasks', '/api/v1/labels', '/api/v1/upcoming', '/api/v1/filters']) { + for (const sti of ['/api/v1/tasks', '/api/v1/labels', '/api/v1/upcoming', '/api/v1/filters', '/api/v1/all-tasks']) { const svar = await page.request.get(sti); expect(svar.status(), `${sti} svarede ${svar.status()}`).toBe(404); } diff --git a/web/e2e/smoke.spec.js b/web/e2e/smoke.spec.js index f9f4d09..8f7af31 100644 --- a/web/e2e/smoke.spec.js +++ b/web/e2e/smoke.spec.js @@ -252,6 +252,92 @@ test('hvert link i sidebjælken fører et sted hen', async ({ page }) => { expect(trouble).toEqual([]); }); +test('Alle opgaver viser det hele inddelt efter gruppe, prioritet og dato', async ({ page }) => { + const trouble = watchForTrouble(page); + await page.goto('/'); + + // A group with a project in it, and two tasks: one in that project with a + // priority, and one in a project of its own with neither. Unique names, because + // the suite shares one account and other tests leave tasks behind. + const stamp = Date.now(); + const names = await page.evaluate(async (stamp) => { + const send = async (method, path, body) => { + const r = await fetch('/api/v1' + path, { + method, + credentials: 'include', + headers: { 'Content-Type': 'application/json', 'Sec-Fetch-Site': 'same-origin' }, + body: JSON.stringify(body) + }); + if (!r.ok) throw new Error(`${method} ${path}: ${r.status}`); + return r.json(); + }; + const group = await send('POST', '/project-groups', { name: `Hjemmet ${stamp}` }); + const project = await send('POST', '/projects', { + name: `Haven ${stamp}`, + group_id: group.id + }); + await send('POST', '/tasks', { + content: `Slå græs ${stamp}`, + project_id: project.id, + priority: 1 + }); + const loose = await send('POST', '/projects', { name: `Løst ${stamp}` }); + await send('POST', '/tasks', { content: `Ring til VVS ${stamp}`, project_id: loose.id }); + return { group: group.name, project: project.name }; + }, stamp); + + // Through the sidebar, so the entry is tested as well as the page. + await page.reload(); + const sidebar = page.getByRole('navigation', { name: 'Hovedmenu' }); + await sidebar.getByRole('link', { name: 'Alle opgaver' }).click(); + await expect(page.getByRole('heading', { name: 'Alle opgaver', level: 1 })).toBeVisible(); + + // By group: the group's heading, the project under it, the task under that. + const groupSection = page.locator('[data-bucket]').filter({ + has: page.getByRole('heading', { name: names.group }) + }); + await expect(groupSection.getByRole('link', { name: names.project })).toBeVisible(); + await expect(groupSection.getByText(`Slå græs ${stamp}`)).toBeVisible(); + // And the loose project's task is NOT in the group — a list of everything + // passes any check that only asks whether the right task is in it. + await expect(groupSection.getByText(`Ring til VVS ${stamp}`)).toHaveCount(0); + const ungrouped = page.locator('[data-bucket]').filter({ + has: page.getByRole('heading', { name: 'Uden gruppe' }) + }); + await expect(ungrouped.getByText(`Ring til VVS ${stamp}`)).toBeVisible(); + + // Folding a group hides its tasks and keeps its heading. + await groupSection.getByRole('button', { name: names.group }).click(); + await expect(groupSection.getByText(`Slå græs ${stamp}`)).toHaveCount(0); + await groupSection.getByRole('button', { name: names.group }).click(); + await expect(groupSection.getByText(`Slå græs ${stamp}`)).toBeVisible(); + + // By priority: the prioritised task under Prioritet 1, the other under none. + await page.getByRole('button', { name: 'Prioritet', exact: true }).click(); + // Anchored: the heading's name includes its count, so "Ingen prioritet 1" also + // contains "prioritet 1" — and that bucket is the one holding the other task. + const p1 = page.locator('[data-bucket]').filter({ + has: page.getByRole('heading', { name: /^Prioritet 1\b/ }) + }); + await expect(p1.getByText(`Slå græs ${stamp}`)).toBeVisible(); + await expect(p1.getByText(`Ring til VVS ${stamp}`)).toHaveCount(0); + // Out of its project, a row says where it lives. + await expect(p1.getByText(names.project)).toBeVisible(); + + // The choice survives a reload. + await page.reload(); + await expect(page.getByRole('heading', { name: /^Prioritet 1\b/ })).toBeVisible(); + + // By date: neither has one. + await page.getByRole('button', { name: 'Dato', exact: true }).click(); + const noDate = page.locator('[data-bucket]').filter({ + has: page.getByRole('heading', { name: 'Uden dato' }) + }); + await expect(noDate.getByText(`Ring til VVS ${stamp}`)).toBeVisible(); + + expect(trouble).toEqual([]); +}); + test('en opgave kan slumres og hentes frem igen', async ({ page }) => { const trouble = watchForTrouble(page); await page.goto('/'); diff --git a/web/src/lib/api.js b/web/src/lib/api.js index bdf3c03..39a1023 100644 --- a/web/src/lib/api.js +++ b/web/src/lib/api.js @@ -564,6 +564,7 @@ export const api = { today: () => get('/today'), upcoming: (days) => get(`/upcoming${days ? `?days=${days}` : ''}`), delegated: () => get('/delegated'), + allTasks: () => get('/all-tasks'), people: () => get('/people'), search: (q) => get(`/search?q=${encodeURIComponent(q)}`) }; diff --git a/web/src/lib/components/Sidebar.svelte b/web/src/lib/components/Sidebar.svelte index 1e2cb44..d37137f 100644 --- a/web/src/lib/components/Sidebar.svelte +++ b/web/src/lib/components/Sidebar.svelte @@ -193,7 +193,12 @@ // Sidst i rækken, fordi `navOrder` føjer en ukendt nøgle til bagest: står // den et andet sted her, ser en ny konto én rækkefølge og alle // eksisterende en anden. - app.notesOnly ? null : { key: 'calendar', href: '/kalender', label: 'nav.calendar' } + app.notesOnly ? null : { key: 'calendar', href: '/kalender', label: 'nav.calendar' }, + // Alle opgaver bærer en liste frem for en prik, af samme grund som + // kalenderen bærer et gitter: den er ikke endnu et filter over dagene, den + // er det hele. Sidst af samme grund som de to over den — `navOrder` føjer + // en ukendt nøgle til bagest. + app.notesOnly ? null : { key: 'all', href: '/alle', label: 'nav.all' } ].filter(Boolean) ); @@ -607,6 +612,20 @@ /> + {:else if item.key === 'all'} + + {:else if item.key === 'delegated'} + {#if place} + {place} + {/if} {#if assignee} +

{t('all.truncated')}

+ {/if} + + {#snippet heading(key, count, content)} +

+ + {count} +

+ {/snippet} + + {#if mode === 'group'} + {#each byPlace as section (section.key)} +
+ {#snippet label()} + {#if section.color} + + {/if} + {section.name} + {/snippet} + {@render heading(section.key, section.count, label)} + + {#if !folded.has(section.key)} + {#each section.projects as entry (entry.project?.id ?? 'stray')} + {#if !section.flat} + + + {projectName(entry.project)} + {entry.tasks.length} + + {/if} +
+ {#each entry.tasks as task (task.id)} + + {/each} +
+ {/each} + {/if} +
+ {/each} + {:else} + {#each mode === 'priority' ? byPriority : byDate as bucket (bucket.key)} +
+ {#snippet label()} + {#if bucket.priority} + + {/if} + {bucket.name} + {/snippet} + {@render heading(`${mode}:${bucket.key}`, bucket.tasks.length, label)} + + {#if !folded.has(`${mode}:${bucket.key}`)} + {#each bucket.tasks as task (task.id)} + + + {/each} + {/if} +
+ {/each} + {/if} + + {#if loaded && !open.length} +

+ + {t('all.empty')} +

+ {/if} + + + From 22b79cdfa7f830968f20e2219db4f7c4be11b811 Mon Sep 17 00:00:00 2001 From: kristianwind Date: Sat, 21 Nov 2026 14:09:00 +0100 Subject: [PATCH 3/3] =?UTF-8?q?test(e2e):=20Alle=20opgaver-pr=C3=B8ven=20r?= =?UTF-8?q?ydder=20sin=20gruppe=20op=20igen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Den efterlod en projektgruppe på den fælles konto, og to af de andre gruppeprøver regner med, at der kun er deres egen i sidebjælken. Kun gruppen slettes: projekterne i papirkurven gav gendannelsesprøven mere end sin egen at vælge imellem. Co-Authored-By: Claude Opus 5.5 --- web/e2e/smoke.spec.js | 107 +++++++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 44 deletions(-) diff --git a/web/e2e/smoke.spec.js b/web/e2e/smoke.spec.js index 8f7af31..dee81ee 100644 --- a/web/e2e/smoke.spec.js +++ b/web/e2e/smoke.spec.js @@ -283,57 +283,76 @@ test('Alle opgaver viser det hele inddelt efter gruppe, prioritet og dato', asyn }); const loose = await send('POST', '/projects', { name: `Løst ${stamp}` }); await send('POST', '/tasks', { content: `Ring til VVS ${stamp}`, project_id: loose.id }); - return { group: group.name, project: project.name }; + return { + group: group.name, + project: project.name, + ids: { group: group.id } + }; }, stamp); - // Through the sidebar, so the entry is tested as well as the page. - await page.reload(); - const sidebar = page.getByRole('navigation', { name: 'Hovedmenu' }); - await sidebar.getByRole('link', { name: 'Alle opgaver' }).click(); - await expect(page.getByRole('heading', { name: 'Alle opgaver', level: 1 })).toBeVisible(); + // The group is removed again whatever happens below: the suite shares one + // account, and a group left in the sidebar breaks the tests that expect one + // there. Only the group — deleting the projects as well puts them in the trash, + // where the restore test then finds more than its own. + try { - // By group: the group's heading, the project under it, the task under that. - const groupSection = page.locator('[data-bucket]').filter({ - has: page.getByRole('heading', { name: names.group }) - }); - await expect(groupSection.getByRole('link', { name: names.project })).toBeVisible(); - await expect(groupSection.getByText(`Slå græs ${stamp}`)).toBeVisible(); - // And the loose project's task is NOT in the group — a list of everything - // passes any check that only asks whether the right task is in it. - await expect(groupSection.getByText(`Ring til VVS ${stamp}`)).toHaveCount(0); - const ungrouped = page.locator('[data-bucket]').filter({ - has: page.getByRole('heading', { name: 'Uden gruppe' }) - }); - await expect(ungrouped.getByText(`Ring til VVS ${stamp}`)).toBeVisible(); + // Through the sidebar, so the entry is tested as well as the page. + await page.reload(); + const sidebar = page.getByRole('navigation', { name: 'Hovedmenu' }); + await sidebar.getByRole('link', { name: 'Alle opgaver' }).click(); + await expect(page.getByRole('heading', { name: 'Alle opgaver', level: 1 })).toBeVisible(); - // Folding a group hides its tasks and keeps its heading. - await groupSection.getByRole('button', { name: names.group }).click(); - await expect(groupSection.getByText(`Slå græs ${stamp}`)).toHaveCount(0); - await groupSection.getByRole('button', { name: names.group }).click(); - await expect(groupSection.getByText(`Slå græs ${stamp}`)).toBeVisible(); + // By group: the group's heading, the project under it, the task under that. + const groupSection = page.locator('[data-bucket]').filter({ + has: page.getByRole('heading', { name: names.group }) + }); + await expect(groupSection.getByRole('link', { name: names.project })).toBeVisible(); + await expect(groupSection.getByText(`Slå græs ${stamp}`)).toBeVisible(); + // And the loose project's task is NOT in the group — a list of everything + // passes any check that only asks whether the right task is in it. + await expect(groupSection.getByText(`Ring til VVS ${stamp}`)).toHaveCount(0); + const ungrouped = page.locator('[data-bucket]').filter({ + has: page.getByRole('heading', { name: 'Uden gruppe' }) + }); + await expect(ungrouped.getByText(`Ring til VVS ${stamp}`)).toBeVisible(); - // By priority: the prioritised task under Prioritet 1, the other under none. - await page.getByRole('button', { name: 'Prioritet', exact: true }).click(); - // Anchored: the heading's name includes its count, so "Ingen prioritet 1" also - // contains "prioritet 1" — and that bucket is the one holding the other task. - const p1 = page.locator('[data-bucket]').filter({ - has: page.getByRole('heading', { name: /^Prioritet 1\b/ }) - }); - await expect(p1.getByText(`Slå græs ${stamp}`)).toBeVisible(); - await expect(p1.getByText(`Ring til VVS ${stamp}`)).toHaveCount(0); - // Out of its project, a row says where it lives. - await expect(p1.getByText(names.project)).toBeVisible(); + // Folding a group hides its tasks and keeps its heading. + await groupSection.getByRole('button', { name: names.group }).click(); + await expect(groupSection.getByText(`Slå græs ${stamp}`)).toHaveCount(0); + await groupSection.getByRole('button', { name: names.group }).click(); + await expect(groupSection.getByText(`Slå græs ${stamp}`)).toBeVisible(); - // The choice survives a reload. - await page.reload(); - await expect(page.getByRole('heading', { name: /^Prioritet 1\b/ })).toBeVisible(); + // By priority: the prioritised task under Prioritet 1, the other under none. + await page.getByRole('button', { name: 'Prioritet', exact: true }).click(); + // Anchored: the heading's name includes its count, so "Ingen prioritet 1" also + // contains "prioritet 1" — and that bucket is the one holding the other task. + const p1 = page.locator('[data-bucket]').filter({ + has: page.getByRole('heading', { name: /^Prioritet 1\b/ }) + }); + await expect(p1.getByText(`Slå græs ${stamp}`)).toBeVisible(); + await expect(p1.getByText(`Ring til VVS ${stamp}`)).toHaveCount(0); + // Out of its project, a row says where it lives. + await expect(p1.getByText(names.project)).toBeVisible(); - // By date: neither has one. - await page.getByRole('button', { name: 'Dato', exact: true }).click(); - const noDate = page.locator('[data-bucket]').filter({ - has: page.getByRole('heading', { name: 'Uden dato' }) - }); - await expect(noDate.getByText(`Ring til VVS ${stamp}`)).toBeVisible(); + // The choice survives a reload. + await page.reload(); + await expect(page.getByRole('heading', { name: /^Prioritet 1\b/ })).toBeVisible(); + + // By date: neither has one. + await page.getByRole('button', { name: 'Dato', exact: true }).click(); + const noDate = page.locator('[data-bucket]').filter({ + has: page.getByRole('heading', { name: 'Uden dato' }) + }); + await expect(noDate.getByText(`Ring til VVS ${stamp}`)).toBeVisible(); + } finally { + await page.evaluate(async (group) => { + await fetch(`/api/v1/project-groups/${group}`, { + method: 'DELETE', + credentials: 'include', + headers: { 'Sec-Fetch-Site': 'same-origin' } + }); + }, names.ids.group); + } expect(trouble).toEqual([]); });