fix(notify): open configured web run pages from ntfy
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func TestStageNotificationEventsAndArtifactAudit(t *testing.T) {
|
||||
t.Setenv("PIPELINES_WEB_PUBLIC_URL", "https://pipelines.example.com/")
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
store, err := pipeline.Open(filepath.Join(t.TempDir(), "notify.db"))
|
||||
@@ -36,6 +37,9 @@ func TestStageNotificationEventsAndArtifactAudit(t *testing.T) {
|
||||
var calls atomic.Int32
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
count := calls.Add(1)
|
||||
if click := r.Header.Get("Click"); !strings.HasPrefix(click, "https://pipelines.example.com/runs/") {
|
||||
t.Errorf("stage notification lacks web run link: %q", click)
|
||||
}
|
||||
filename, _ := new(mime.WordDecoder).DecodeHeader(r.Header.Get("Filename"))
|
||||
body, _ := io.ReadAll(r.Body)
|
||||
if filename == "report.txt" && string(body) != "created file" {
|
||||
@@ -287,6 +291,7 @@ func TestRunAttentionEventMapping(t *testing.T) {
|
||||
// the run and its pipeline, the click action opens the run, only waiting/failed
|
||||
// publish, and a run that stays waiting is never republished.
|
||||
func TestRunAttentionNotificationDelivery(t *testing.T) {
|
||||
t.Setenv("PIPELINES_WEB_PUBLIC_URL", "https://pipelines.example.com")
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
store, err := pipeline.Open(filepath.Join(t.TempDir(), "attention.db"))
|
||||
@@ -336,7 +341,7 @@ func TestRunAttentionNotificationDelivery(t *testing.T) {
|
||||
if first.title != "Run needs your decision" || !strings.Contains(first.message, "Run #7") || !strings.Contains(first.message, "release") || !strings.Contains(first.message, "decision") || !strings.Contains(first.message, "approve") {
|
||||
t.Fatalf("waiting notification does not identify the run/pipeline/need: %+v", first)
|
||||
}
|
||||
if first.click != "pipelines://run/7" {
|
||||
if first.click != "https://pipelines.example.com/runs/7" {
|
||||
t.Fatalf("waiting notification click does not open the run: %q", first.click)
|
||||
}
|
||||
if first.authorization != "" {
|
||||
@@ -346,7 +351,7 @@ func TestRunAttentionNotificationDelivery(t *testing.T) {
|
||||
if second.title != "Run failed" || !strings.Contains(second.message, "Run #7") || !strings.Contains(second.message, "release") || !strings.Contains(second.message, "deploy") || !strings.Contains(second.message, "provider returned 500") {
|
||||
t.Fatalf("failed notification is not actionable: %+v", second)
|
||||
}
|
||||
if second.click != "pipelines://run/7" {
|
||||
if second.click != "https://pipelines.example.com/runs/7" {
|
||||
t.Fatalf("failed notification click does not open the run: %q", second.click)
|
||||
}
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user