-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2771 add tests for conditional hiding of the fancy field types.
- Loading branch information
Josh Pollock
committed
Oct 20, 2018
1 parent
64a83f4
commit f4c9da9
Showing
8 changed files
with
210 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"_last_updated":"Sat, 20 Oct 2018 17:54:11 +0000","ID":"CF5bcb67b899a38","cf_version":"1.8.0-a.1","name":"Conditional Hide - Fancy Fields","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t","db_support":1,"pinned":0,"hide_form":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_6026662":"1:1","fld_8820637":"2:1","fld_8552574":"3:1","fld_8899889":"4:1","fld_8097741":"5:1","fld_8501163":"5:1"},"structure":"12|12|12|12|12|12"},"fields":{"fld_6026662":{"ID":"fld_6026662","type":"radio","label":"Hide All","slug":"hide_all","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"count","orderby_post":"ID","order":"ASC","default":"","option":{"opt1077485":{"calc_value":"","value":"Yes","label":"Yes"},"opt2055262":{"calc_value":"","value":"No","label":"No"}},"email_identifier":0,"personally_identifying":0}},"fld_8820637":{"ID":"fld_8820637","type":"range_slider","label":"Range","slug":"range","conditions":{"type":"con_3922580031808809"},"caption":"Default 10, Min -5, Max 20 Red handle","config":{"custom_class":"","default":10,"trackcolor":"#e6e6e6","color":"#00ff00","handle":"#ff0000","handleborder":"#cccccc","step":1,"min":-5,"max":20,"showval":1,"prefix":"","suffix":"","email_identifier":0,"personally_identifying":0}},"fld_8552574":{"ID":"fld_8552574","type":"star_rating","label":"Star Default 5\/7 Stars are Black #000000","slug":"star_default_57","conditions":{"type":"con_3922580031808809"},"caption":"","config":{"custom_class":"","default":5,"number":7,"type":"star","size":13,"space":3,"color":"#000000","track_color":"#AFAFAF","email_identifier":0,"personally_identifying":0}},"fld_8899889":{"ID":"fld_8899889","type":"utm","label":"UTM Field","slug":"utm_field","conditions":{"type":"con_3922580031808809"},"caption":"","config":{"custom_class":"","email_identifier":0,"personally_identifying":0}},"fld_8097741":{"ID":"fld_8097741","type":"gdpr","label":"Consent Field","slug":"consent_field","conditions":{"type":"con_3922580031808809"},"caption":"","config":{"custom_class":"","agreement":"Agreement","linked_text":"Privacy page","title_attr":"Title for link","email_identifier":0,"personally_identifying":0}},"fld_8501163":{"ID":"fld_8501163","type":"button","label":"Submit Button","slug":"submit_button","conditions":{"type":"con_3922580031808809"},"caption":"","config":{"custom_class":"","type":"submit","class":"btn btn-default","target":""}}},"page_names":["Page 1"],"mailer":{"sender_name":"Caldera Forms Notification","sender_email":"[email protected]","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Fancy Field Hide\/Show","email_message":"{summary}"},"check_honey":1,"antispam":{"sender_name":"","sender_email":""},"conditional_groups":{"conditions":{"con_3922580031808809":{"id":"con_3922580031808809","name":"Hide All","type":"hide","group":{"rw9088688076208192":{"cl6331319444783873":{"parent":"rw9088688076208192","field":"fld_6026662","compare":"is","value":"opt1077485"}}},"fields":{"cl6331319444783873":"fld_6026662"}}}},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.8.0-a.1","db_id":"145","type":"primary"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"_last_updated":"Sat, 20 Oct 2018 18:24:18 +0000","ID":"CF5bcb71a2d27bf","cf_version":"1.8.0-a.1","name":"Conditionals Fancy Multi-Page","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"avatar_field":null,"form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_6026662":"1:1","fld_2586230":"2:1","fld_8899889":"3:1","fld_8552574":"3:1","fld_8820637":"3:1","fld_8097741":"3:1","fld_7066233":"4:1","fld_8501163":"4:2"},"structure":"12|12#12|6:6"},"fields":{"fld_6026662":{"ID":"fld_6026662","type":"radio","label":"Hide All","slug":"hide_all","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1077485":{"calc_value":"Yes","value":"Yes","label":"Yes"},"opt2055262":{"calc_value":"No","value":"No","label":"No"}},"email_identifier":0,"personally_identifying":0}},"fld_8820637":{"ID":"fld_8820637","type":"range_slider","label":"Range","slug":"range","conditions":{"type":"con_3922580031808809"},"caption":"Default 10, Min -5, Max 20 Red handle","config":{"custom_class":"","default":10,"trackcolor":"#e6e6e6","color":"#00ff00","handle":"#ff0000","handleborder":"#cccccc","step":1,"min":-5,"max":20,"showval":1,"prefix":"","suffix":"","email_identifier":0,"personally_identifying":0}},"fld_8552574":{"ID":"fld_8552574","type":"star_rating","label":"Star Default 5\/7 Stars are Black #000000","slug":"star_default_57","conditions":{"type":"con_3922580031808809"},"caption":"","config":{"custom_class":"","default":5,"number":7,"type":"star","size":13,"space":3,"color":"#000000","track_color":"#AFAFAF","email_identifier":0,"personally_identifying":0}},"fld_8899889":{"ID":"fld_8899889","type":"utm","label":"UTM Field","slug":"utm_field","conditions":{"type":"con_3922580031808809"},"caption":"","config":{"custom_class":"","email_identifier":0,"personally_identifying":0}},"fld_8097741":{"ID":"fld_8097741","type":"gdpr","label":"Consent Field","slug":"consent_field","conditions":{"type":"con_3922580031808809"},"caption":"","config":{"custom_class":"","agreement":"Agreement","linked_text":"Privacy page","title_attr":"Title for link","email_identifier":0,"personally_identifying":0}},"fld_8501163":{"ID":"fld_8501163","type":"button","label":"Submit Button","slug":"submit_button","conditions":{"type":"con_3922580031808809"},"caption":"","config":{"custom_class":"","type":"submit","class":"btn btn-default","target":""}},"fld_2586230":{"ID":"fld_2586230","type":"button","label":"Next page","slug":"next_page","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"next","class":"btn btn-default","target":""}},"fld_7066233":{"ID":"fld_7066233","type":"button","label":"Back Button","slug":"back_button","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"prev","class":"btn btn-default","target":""}}},"page_names":["Page 1","Page 2"],"mailer":{"sender_name":"Caldera Forms Notification","sender_email":"[email protected]","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Fancy Field Hide\/Show","email_message":"{summary}"},"check_honey":1,"antispam":{"sender_name":"","sender_email":""},"conditional_groups":{"conditions":{"con_3922580031808809":{"id":"con_3922580031808809","name":"Hide All","type":"hide","fields":{"cl6331319444783873":"fld_6026662"},"group":{"rw9088688076208192":{"cl6331319444783873":{"parent":"rw9088688076208192","field":"fld_6026662","compare":"is","value":"opt1077485"}}}}}},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.8.0-a.1","db_id":"149","type":"primary"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { | ||
visitPage, | ||
getCfField, | ||
clearCfField, | ||
cfFieldIsVisible, | ||
cfFieldDoesNotExist, | ||
cfFieldHasValue, | ||
cfFieldSelectValue, | ||
cfFieldSetValue, | ||
cfFieldCheckValue, | ||
cfFieldIsDisabled, | ||
cfFieldUnCheckValue, | ||
cfFieldIsNotDisabled, | ||
cfFieldCheckAllValues, | ||
cfFieldCalcFieldValueIs, | ||
cfFieldWrapperHasRangeSliderInIt, | ||
cfStarFieldValueIs, | ||
cfSetStar, | ||
cfFieldGetWrapper, | ||
cfFieldClickButton | ||
} from '../support/util'; | ||
import { addQueryArgs } from '@wordpress/url'; | ||
|
||
|
||
|
||
describe('Conditionals test hide conditionals of fancy fields on page 2', () => { | ||
const utmTerms = { | ||
term:'t1', | ||
campaign: 'c21', | ||
medium: 'm22', | ||
content: 'cc34' | ||
}; | ||
let queryArgs = {}; | ||
Object.keys(utmTerms).forEach( term => queryArgs[`utm_${term}`] = utmTerms[term]); | ||
beforeEach(() => { | ||
visitPage(addQueryArgs('conditionals-fancy-multi-page',queryArgs)); | ||
}); | ||
|
||
const formId = 'CF5bcb67b899a38'; | ||
|
||
const hideAllCheckbox ='fld_6026662'; | ||
const range = 'fld_8820637'; | ||
const star = 'fld_8552574'; | ||
const utm = 'fld_8899889'; | ||
const consent = 'fld_8097741'; | ||
|
||
const nextPageButton = 'fld_2586230'; | ||
const prevPageButton = 'fld_7066233'; | ||
|
||
const testUtmTerms = (fieldId) => { | ||
Object.keys(utmTerms).forEach(term => { | ||
cy.get(`#${fieldId}_utm_${term}_1`).should('have.value', utmTerms[term]); | ||
}); | ||
}; | ||
|
||
function testAllValues() { | ||
testUtmTerms(utm); | ||
cfFieldHasValue(range, '10'); | ||
cfFieldWrapperHasRangeSliderInIt(range); | ||
cfStarFieldValueIs(star, '5', '7'); | ||
cfFieldGetWrapper(consent).find('a.caldera-forms-consent-field-linked_text').contains('Privacy page'); | ||
cfFieldGetWrapper(consent).find('p.caldera-forms-consent-field-agreement').contains('Agreement'); | ||
} | ||
|
||
|
||
|
||
it( 'Has the correct initial load', () => { | ||
|
||
cfFieldClickButton(nextPageButton); | ||
testAllValues(); | ||
}); | ||
|
||
it( 'After hide and unhide, looks the same', () => { | ||
|
||
cfFieldCheckValue(hideAllCheckbox,'Yes' ); | ||
cfFieldCheckValue(hideAllCheckbox,'No' ); | ||
cfFieldClickButton(nextPageButton); | ||
testAllValues(); | ||
|
||
cfFieldClickButton(prevPageButton); | ||
cfFieldCheckValue(hideAllCheckbox,'Yes' ); | ||
cfFieldCheckValue(hideAllCheckbox,'No' ); | ||
cfFieldClickButton(nextPageButton); | ||
testAllValues(); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { | ||
visitPage, | ||
getCfField, | ||
clearCfField, | ||
cfFieldIsVisible, | ||
cfFieldDoesNotExist, | ||
cfFieldHasValue, | ||
cfFieldSelectValue, | ||
cfFieldSetValue, | ||
cfFieldCheckValue, | ||
cfFieldIsDisabled, | ||
cfFieldUnCheckValue, | ||
cfFieldIsNotDisabled, | ||
cfFieldCheckAllValues, | ||
cfFieldCalcFieldValueIs, cfFieldWrapperHasRangeSliderInIt, cfStarFieldValueIs, cfSetStar, cfFieldGetWrapper | ||
} from '../support/util'; | ||
import { addQueryArgs } from '@wordpress/url'; | ||
|
||
|
||
|
||
describe('Conditionals test hide conditionals of fancy fields', () => { | ||
const utmTerms = { | ||
term:'t1', | ||
campaign: 'c21', | ||
medium: 'm22', | ||
content: 'cc34' | ||
}; | ||
let queryArgs = {}; | ||
Object.keys(utmTerms).forEach( term => queryArgs[`utm_${term}`] = utmTerms[term]); | ||
beforeEach(() => { | ||
visitPage(addQueryArgs('conditionals-fancy',queryArgs)); | ||
}); | ||
|
||
const formId = 'CF5bcb67b899a38'; | ||
|
||
const hideAllCheckbox ='fld_6026662'; | ||
const range = 'fld_8820637'; | ||
const star = 'fld_8552574'; | ||
const utm = 'fld_8899889'; | ||
const consent = 'fld_8097741'; | ||
|
||
const testUtmTerms = (fieldId) => { | ||
Object.keys(utmTerms).forEach(term => { | ||
cy.get(`#${fieldId}_utm_${term}_1`).should('have.value', utmTerms[term]); | ||
}); | ||
}; | ||
function testAllValues() { | ||
testUtmTerms(utm); | ||
cfFieldHasValue(range, '10'); | ||
cfFieldWrapperHasRangeSliderInIt(range); | ||
cfStarFieldValueIs(star, '5', '7'); | ||
cfFieldGetWrapper(consent).find('a.caldera-forms-consent-field-linked_text').contains('Privacy page'); | ||
cfFieldGetWrapper(consent).find('p.caldera-forms-consent-field-agreement').contains('Agreement'); | ||
} | ||
|
||
|
||
|
||
it( 'Has the correct initial load', () => { | ||
testAllValues(); | ||
|
||
}); | ||
|
||
it( 'After hide and unhide, looks the same', () => { | ||
|
||
cfFieldCheckValue(hideAllCheckbox,'Yes' ); | ||
cfFieldCheckValue(hideAllCheckbox,'No' ); | ||
testAllValues(); | ||
|
||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters