//go:build e2etest package main // E2E-only hooks, compiled only with -tags e2etest (CI's corescope-server-e2e): // the "fake" mail provider and GET /__e2e/last-mail, which returns the newest // fake mail so Playwright can follow its link. Never part of a release build. import ( "net/http" "github.com/gorilla/mux" "github.com/meshcore-analyzer/mailer" ) type e2eMail struct { To string `json:"to"` Subject string `json:"subject"` Text string `json:"text"` } func init() { fakeMailerAllowed = true e2eRoutes = func(s *Server, r *mux.Router) { r.HandleFunc("/__e2e/last-mail", func(w http.ResponseWriter, _ *http.Request) { f, ok := s.auth.mail.(*mailer.Fake) if !ok { writeError(w, http.StatusNotFound, "not using the fake mailer") return } m, _, ok := f.Last() if !ok { writeError(w, http.StatusNotFound, "no mail sent yet") return } writeJSON(w, e2eMail{To: m.To, Subject: m.Subject, Text: m.Text}) }).Methods("GET") } }