Files
vasyansk 0bb584fe10 feat: folder mapping UI on account add (probe + map modal)
ADD now probes both connections, lists folders on each side, and opens a
mapping modal to route source->destination folders (e.g. Спам -> Spam) so we
append into the existing folder instead of creating a duplicate.

- store: SetTaskFolderMapping (+ round-trip test)
- httpapi: POST /tasks/{id}/probe (test both, return folder lists),
  PUT /tasks/{id}/folder-mapping
- web: FolderMappingModal (reuses Modal, size=lg), submitAccount probes then
  opens the modal; confirm creates the account and saves the task mapping

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMHQTtnQtQqL8muAXHr9kd
2026-07-02 14:39:31 +07:00

35 lines
1.1 KiB
Go

package store
import (
"context"
"testing"
)
func TestSetTaskFolderMappingRoundTrip(t *testing.T) {
s := testStore(t)
ctx := context.Background()
e1, _ := s.CreateEndpoint(ctx, Endpoint{RoleLabel: "s", Host: "a", Port: 993, TLSMode: "ssl"})
e2, _ := s.CreateEndpoint(ctx, Endpoint{RoleLabel: "d", Host: "b", Port: 993, TLSMode: "ssl"})
taskID, _ := s.CreateTask(ctx, Task{Name: "t", SrcEndpointID: e1, DstEndpointID: e2})
m := map[string]string{"Спам": "Spam", "Отправленные": "Sent"}
if err := s.SetTaskFolderMapping(ctx, taskID, m); err != nil {
t.Fatalf("set mapping: %v", err)
}
got, err := s.GetTask(ctx, taskID)
if err != nil {
t.Fatalf("get: %v", err)
}
if got.FolderMapping["Спам"] != "Spam" || got.FolderMapping["Отправленные"] != "Sent" {
t.Fatalf("mapping round-trip failed: %+v", got.FolderMapping)
}
// nil clears to empty object, not null
if err := s.SetTaskFolderMapping(ctx, taskID, nil); err != nil {
t.Fatalf("clear: %v", err)
}
got, _ = s.GetTask(ctx, taskID)
if got.FolderMapping == nil {
t.Fatal("mapping should be non-nil empty map after clear")
}
}