Skip to content

Commit

Permalink
fix: disappearing title label on verification and recovery flow (#2613)
Browse files Browse the repository at this point in the history
Closes #2591
  • Loading branch information
erolkskn committed Jul 25, 2022
1 parent 4e5aac2 commit 29aa3b6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
"node_type": "input"
},
"messages": [],
"meta": {}
"meta": {
"label": {
"id": 1070007,
"text": "Email",
"type": "info"
}
}
},
{
"type": "input",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
"node_type": "input"
},
"messages": [],
"meta": {}
"meta": {
"label": {
"id": 1070007,
"text": "Email",
"type": "info"
}
}
},
{
"type": "input",
Expand Down
4 changes: 2 additions & 2 deletions selfservice/strategy/link/strategy_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func (s *Strategy) recoveryHandleFormSubmission(w http.ResponseWriter, r *http.R
f.UI.SetCSRF(s.d.GenerateCSRFToken(r))
f.UI.GetNodes().Upsert(
// v0.5: form.Field{Name: "email", Type: "email", Required: true, Value: body.Body.Email}
node.NewInputField("email", body.Email, node.LinkGroup, node.InputAttributeTypeEmail, node.WithRequiredInputAttribute),
node.NewInputField("email", body.Email, node.LinkGroup, node.InputAttributeTypeEmail, node.WithRequiredInputAttribute).WithMetaLabel(text.NewInfoNodeInputEmail()),
)

f.Active = sqlxx.NullString(s.RecoveryNodeGroup())
Expand Down Expand Up @@ -483,7 +483,7 @@ func (s *Strategy) HandleRecoveryError(w http.ResponseWriter, r *http.Request, r
req.UI.SetCSRF(s.d.GenerateCSRFToken(r))
req.UI.GetNodes().Upsert(
// v0.5: form.Field{Name: "email", Type: "email", Required: true, Value: body.Body.Email}
node.NewInputField("email", email, node.LinkGroup, node.InputAttributeTypeEmail, node.WithRequiredInputAttribute),
node.NewInputField("email", email, node.LinkGroup, node.InputAttributeTypeEmail, node.WithRequiredInputAttribute).WithMetaLabel(text.NewInfoNodeInputEmail()),
)
}

Expand Down
4 changes: 2 additions & 2 deletions selfservice/strategy/link/strategy_verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (s *Strategy) handleVerificationError(w http.ResponseWriter, r *http.Reques
f.UI.SetCSRF(s.d.GenerateCSRFToken(r))
f.UI.GetNodes().Upsert(
// v0.5: form.Field{Name: "email", Type: "email", Required: true, Value: body.Body.Email}
node.NewInputField("email", body.Email, node.LinkGroup, node.InputAttributeTypeEmail, node.WithRequiredInputAttribute),
node.NewInputField("email", body.Email, node.LinkGroup, node.InputAttributeTypeEmail, node.WithRequiredInputAttribute).WithMetaLabel(text.NewInfoNodeInputEmail()),
)
}

Expand Down Expand Up @@ -166,7 +166,7 @@ func (s *Strategy) verificationHandleFormSubmission(w http.ResponseWriter, r *ht
f.UI.SetCSRF(s.d.GenerateCSRFToken(r))
f.UI.GetNodes().Upsert(
// v0.5: form.Field{Name: "email", Type: "email", Required: true, Value: body.Body.Email}
node.NewInputField("email", body.Email, node.LinkGroup, node.InputAttributeTypeEmail, node.WithRequiredInputAttribute),
node.NewInputField("email", body.Email, node.LinkGroup, node.InputAttributeTypeEmail, node.WithRequiredInputAttribute).WithMetaLabel(text.NewInfoNodeInputEmail()),
)

f.Active = sqlxx.NullString(s.VerificationNodeGroup())
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ Cypress.Commands.add('recoverApi', ({ email, returnTo }) => {
cy.request({ url })
.then(({ body }) => {
const form = body.ui
// label should still exist after request, for more detail: #2591
expect(form.nodes[1].meta).to.not.be.null
expect(form.nodes[1].meta.label).to.not.be.null
expect(form.nodes[1].meta.label.text).to.equal('Email')

return cy.request({
method: form.method,
body: mergeFields(form, { email, method: 'link' }),
Expand All @@ -415,6 +420,11 @@ Cypress.Commands.add('verificationApi', ({ email, returnTo }) => {
cy.request({ url })
.then(({ body }) => {
const form = body.ui
// label should still exist after request, for more detail: #2591
expect(form.nodes[1].meta).to.not.be.null
expect(form.nodes[1].meta.label).to.not.be.null
expect(form.nodes[1].meta.label.text).to.equal('Email')

return cy.request({
method: form.method,
body: mergeFields(form, { email, method: 'link' }),
Expand Down

0 comments on commit 29aa3b6

Please sign in to comment.