Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-deploy-verify.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'leroa': patch
---

Fix deploy verify: check the login page for the current "Explore a seeded demo" copy instead of the removed "Try the live demo" text.
7 changes: 6 additions & 1 deletion scripts/release/deploy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ func get(client *http.Client, url string) (string, string, error) {
return resp.Request.URL.String(), string(body), nil
}

// demoLoginMarker is copy on the sign-in page shown only in demo mode.
const demoLoginMarker = "Explore a seeded demo"

func demoLoginOK(body string) bool { return strings.Contains(body, demoLoginMarker) }

// verify is a var so tests can stub it.
var verify = func(app string) error {
base := fmt.Sprintf("https://%s.173.249.220.229.nip.io", app)
Expand All @@ -119,7 +124,7 @@ var verify = func(app string) error {
if err != nil {
return err
}
if !strings.Contains(login, "Try the live demo") {
if !demoLoginOK(login) {
return errors.New("demo login missing")
}
req, err := http.NewRequest(http.MethodPost, base+"/demo", strings.NewReader(""))
Expand Down
19 changes: 19 additions & 0 deletions scripts/release/deploy/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,22 @@ func indexOf(s []string, v string) int {
}
return -1
}

// The verify login check must match the copy actually rendered on the sign-in
// page; it silently rolled back releases when the copy changed without it.
func TestDemoLoginMarkerMatchesLoginPage(t *testing.T) {
page, err := os.ReadFile(filepath.Join(
"..", "..", "..", "src", "routes", "(auth)", "login", "+page.svelte"))
if err != nil {
t.Fatal(err)
}
if !strings.Contains(string(page), demoLoginMarker) {
t.Fatalf("login page no longer contains %q; update demoLoginMarker", demoLoginMarker)
}
if !demoLoginOK(`<p>Explore a seeded demo — staff view.</p>`) {
t.Fatal("demoLoginOK rejected current login copy")
}
if demoLoginOK(`<p>Try the live demo</p>`) {
t.Fatal("demoLoginOK accepted stale login copy")
}
}
Loading