| index b70daa5da..3900d8802 100644 |
| --- a/internal/console/accountdomainbuy_test.go |
| +++ b/internal/console/accountdomainbuy_test.go |
| @@ -3,7 +3,9 @@ package console |
| import ( |
| "context" |
| "encoding/json" |
| + "html" |
| "net/http" |
| + "net/http/httptest" |
| "net/url" |
| "strings" |
| "testing" |
| @@ -570,3 +572,19 @@ func (f *purchaseFixture) browserQuote(t *testing.T, c *http.Client, values url. |
| status, _, body = get(t, c, f.ts.URL+loc) |
| return status, body |
| } |
| + |
| +// TestBuyPayAgainShowsQuoteRefusal: when step 3 comes back with a contact |
| +// to correct but the name can no longer be quoted, the page shows the |
| +// quote's refusal, not the contact error it was asked to show. |
| +func TestBuyPayAgainShowsQuoteRefusal(t *testing.T) { |
| + f := newPurchaseFixture(t) |
| + contactRef := &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: domainBuyCopy["contactError"]} |
| + r := httptest.NewRequest(http.MethodPost, "/a/"+f.acct.Sqid+"/domains/buy", strings.NewReader(url.Values{"name": {"shop.zzz"}}.Encode())) |
| + r.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| + w := httptest.NewRecorder() |
| + f.srv.buyPayAgain(w, r, pointOwner(f), "", f.acct, nil, contactRef, "kass", "", "new", ®istrar.Contact{}) |
| + body := w.Body.String() |
| + if !strings.Contains(body, html.EscapeString(domainBuyCopy["notOffered"])) || strings.Contains(body, html.EscapeString(domainBuyCopy["contactError"])) { |
| + t.Fatalf("status %d, want the quote's refusal %q:\n%s", w.Code, domainBuyCopy["notOffered"], body) |
| + } |
| +} |