Skip to content

Commit

Permalink
Fixup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Mar 21, 2024
1 parent 5d478e1 commit d55c219
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion assets/js/phoenix_live_view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
PHX_CLIENT_ERROR_CLASS,
PHX_SERVER_ERROR_CLASS,
PHX_FEEDBACK_FOR,
PHX_FEEDBACK_GROUP,
PHX_HAS_FOCUSED,
PHX_HAS_SUBMITTED,
PHX_HOOK,
Expand Down Expand Up @@ -104,7 +105,8 @@ let serializeForm = (form, metadata, onlyNames = []) => {
for(let [key, val] of formData.entries()){
if(onlyNames.length === 0 || onlyNames.indexOf(key) >= 0){
let input = elements.find(input => input.name === key)
if(!(DOM.private(input, PHX_HAS_FOCUSED) || DOM.private(input, PHX_HAS_SUBMITTED))){
let isUnused = !(DOM.private(input, PHX_HAS_FOCUSED) || DOM.private(input, PHX_HAS_SUBMITTED))
if(isUnused && !(submitter && submitter.name == key)){
params.append(prependFormDataKey(key, "_unused_"), "")
}
params.append(key, val)
Expand Down
4 changes: 1 addition & 3 deletions assets/test/view_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,6 @@ describe("View + Component", function(){
expect(el.querySelector(`[phx-feedback-for="${last_name.name}"`).classList.contains("phx-no-feedback")).toBeTruthy()

view.channel.nextValidate({"user[first_name]": null, "user[last_name]": null, "_target": "user[last_name]"})
DOM.putPrivate(last_name, "phx-has-focused", true)
view.pushInput(last_name, el, null, "validate", {_target: last_name.name})
window.requestAnimationFrame(() => {
expect(el.querySelector(`[phx-feedback-for="${first_name.name}"`).classList.contains("phx-no-feedback")).toBeFalsy()
Expand Down Expand Up @@ -1133,7 +1132,6 @@ describe("View + Component", function(){
expect(el.querySelector("[phx-feedback-for=\"mygroup\"]").classList.contains("phx-no-feedback")).toBeTruthy()

view.channel.nextValidate({"user[first_name]": null, "user[last_name]": null, "user[email]": null, "_target": "user[first_name]"})
DOM.putPrivate(first_name, "phx-has-focused", true)
view.pushInput(first_name, el, null, "validate", {_target: first_name.name})
window.requestAnimationFrame(() => {
expect(el.querySelector(`[phx-feedback-for="${first_name.name}"`).classList.contains("phx-no-feedback")).toBeFalsy()
Expand Down Expand Up @@ -1412,4 +1410,4 @@ describe("DOM", function(){
expect(target.checked).toEqual(true)
expect(target.id).toEqual("bar")
})
})
})

0 comments on commit d55c219

Please sign in to comment.