diff --git a/classes/helpers/FrmFormsHelper.php b/classes/helpers/FrmFormsHelper.php index e40bc62c80..d496d523eb 100644 --- a/classes/helpers/FrmFormsHelper.php +++ b/classes/helpers/FrmFormsHelper.php @@ -279,7 +279,27 @@ public static function get_invalid_error_message( $args ) { */ public static function get_success_message( $atts ) { $message = apply_filters( 'frm_content', $atts['message'], $atts['form'], $atts['entry_id'] ); - $message = do_shortcode( FrmAppHelper::use_wpautop( $message ) ); + + // Only autop if the message includes line breaks. + $autop = strpos( $message, "\n" ) !== false; + + /** + * Filters whether to autop the success message. + * This is false by default if the message does not include line breaks. + * + * @since x.x + * + * @param bool $autop + * @param string $message + * @param object $form + */ + $autop = (bool) apply_filters( 'frm_wpautop_success_message', $autop, $message, $atts['form'] ); + + if ( $autop ) { + $message = FrmAppHelper::use_wpautop( $message ); + } + + $message = do_shortcode( $message ); $message = '
' . $message . '
'; return $message; } diff --git a/classes/models/FrmFormMigrator.php b/classes/models/FrmFormMigrator.php index ddb4adef4c..4612845e9b 100644 --- a/classes/models/FrmFormMigrator.php +++ b/classes/models/FrmFormMigrator.php @@ -50,6 +50,7 @@ private function maybe_add_to_import_page() { } public function import_page() { + $forms = $this->get_forms(); ?>

name ); ?> Importer

@@ -66,11 +67,11 @@ public function import_page() {
get_forms() ) ) { + if ( ! $forms ) { esc_html_e( 'No Forms Found.', 'formidable' ); } ?> - get_forms() as $form_id => $name ) { ?> + $name ) { ?>

-

+ 'submit', + 'class' => 'button button-primary frm-button-primary', + ); + if ( ! $forms ) { + $button_atts['disabled'] = 'disabled'; + } + ?> +

+ +

@@ -97,8 +111,13 @@ public function import_page() {

- The import process has finished! We have successfully imported - forms. You can review the results below. + ' + ); + ?>

diff --git a/css/custom_theme.css.php b/css/custom_theme.css.php index f54d7c8825..8a241c423d 100644 --- a/css/custom_theme.css.php +++ b/css/custom_theme.css.php @@ -974,8 +974,12 @@ } .with_frm_style .frm_message p { - margin-bottom: 5px; color: var(--success-text-color); + margin-bottom: 0; +} + +.with_frm_style .frm_message > p:first-of-type { + margin-top: 0; } .with_frm_style .frm_message, diff --git a/tests/cypress/e2e/Forms/fieldsInFormBuilder.cy.js b/tests/cypress/e2e/Forms/fieldsInFormBuilder.cy.js index 29f40f17a2..e3e75fc9c4 100644 --- a/tests/cypress/e2e/Forms/fieldsInFormBuilder.cy.js +++ b/tests/cypress/e2e/Forms/fieldsInFormBuilder.cy.js @@ -39,7 +39,7 @@ describe("Fields in the form builder", () => { cy.get('h1 > .frm_bstooltip').should("contain", "Test Form"); cy.get('.current_page').should("contain", "Build"); - cy.get('.frm_field_list > #frm-nav-tabs > .frm-tabs > #frm_insert_fields_tab').should("contain", "Add Fields"); + cy.xpath("//li[@class='frm-active']//a[@id='frm_insert_fields_tab']").should("contain", "Add Fields"); cy.log("Create and duplicate fields for each type"); const fieldsToDelete = [ @@ -69,7 +69,7 @@ describe("Fields in the form builder", () => { it("should rename a field from each type", () => { - + const createField = (fieldId, fieldType) => { cy.log(`Create a ${fieldType} field`); cy.get(`li[id="${fieldId}"] a[title="${fieldType}"]`).click({ force: true }); @@ -121,7 +121,7 @@ describe("Fields in the form builder", () => { cy.log(`Set ${fieldType} field as require`); cy.get(`li[data-ftype="${fieldId}"] [id^="field_"][id$="_inner_container"] > .frm-field-action-icons > .dropdown > .frm_bstooltip > .frmsvg > use`, { timeout: 10000 }).click({ force: true }); cy.get(`li[data-ftype="${fieldId}"] .frm_select_field > span`).should("contain", "Field Settings").click({ force: true }); - cy.get('.frm_field_list div[id^="frm-single-settings-"] .frm_grid_container .frm-hide-empty input[type="checkbox"]', { timeout: 10000 }).check({ force: true }); + cy.get('input.frm_req_field[type="checkbox"]').check({ force: true }); }; cy.openForm(); @@ -145,7 +145,7 @@ describe("Fields in the form builder", () => { }); cy.log("Update form"); - cy.get('#frm_submit_side_top').should("contain", "Update").click(); + cy.get('#frm_submit_side_top').should("contain", "Update").click({force: true}); cy.log("Click on Preview - Blank Page"); cy.get("#frm-previewDrop",{timeout:5000}).should("contain", "Preview").click(); @@ -177,10 +177,10 @@ describe("Fields in the form builder", () => { cy.log("Navigate back to the formidable form page"); cy.go(-2); }); - + it("should validate forms with javascript setting", () => { - cy.openForm(); + cy.openForm(); cy.log(`Create a text field and set it as required`); cy.get(`li[id="text"] a[title="Text"]`).click({ force: true }); cy.get(`li[data-ftype="text"] [id^="field_"][id$="_inner_container"] > .frm-field-action-icons > .dropdown > .frm_bstooltip > .frmsvg > use`, { timeout: 10000 }).click({ force: true }); @@ -190,10 +190,10 @@ describe("Fields in the form builder", () => { cy.log("Create a phone and email field"); cy.get(`li[id="email"] a[title="Email"]`).click({ force: true }); cy.get(`li[id="phone"] a[title="Phone"]`).click({ force: true }); - + cy.log("Update form"); - cy.get('#frm_submit_side_top').should("contain", "Update").click(); - + cy.get('#frm_submit_side_top').should("contain", "Update").click({force: true}); + cy.log("Enabling the 'Validate this form with javascript' setting"); cy.xpath("//ul[@class='frm_form_nav']//a[contains(text(),'Settings')]").should("contain","Settings").click(); cy.get(':nth-child(3) > td > .frm_inline_block',{timeout:5000}).should("contain","Validate this form with javascript"); @@ -215,7 +215,7 @@ describe("Fields in the form builder", () => { cy.get(`[id^="frm_error_field_"]`).eq(0).should("contain",`Text cannot be blank.`); cy.get(`[id^="frm_error_field_"]`).eq(1).should("contain",`Email is invalid`); cy.get(`[id^="frm_error_field_"]`).eq(2).should("contain",`Phone is invalid`); - cy.get("button[type='submit']").should("contain", "Submit").click(); + cy.get("button[type='submit']").should("contain", "Submit").click(); cy.log("Navigate back to the formidable form page"); cy.go('back'); @@ -236,17 +236,17 @@ describe("Fields in the form builder", () => { cy.get(`[id^="frm_error_field_"]`).eq(1).should("not.exist"); cy.get(`[id^="frm_error_field_"]`).eq(2).should("not.exist"); cy.get('[id^="field_"]').filter('input, textarea').eq(1).clear(); - cy.get('[id^="field_"]').filter('input, textarea').eq(2).clear(); - cy.get("button[type='submit']").should("contain", "Submit").click(); + cy.get('[id^="field_"]').filter('input, textarea').eq(2).clear(); + cy.get("button[type='submit']").should("contain", "Submit").click(); cy.log("Navigate back to the formidable form page"); cy.go('back'); - }); - + }); + afterEach(() => { cy.log("Teardown - Save the form and delete it"); - cy.get("a[aria-label='Close']", { timeout: 5000 }).click({ force: true }); - cy.deleteForm(); + cy.get("a[aria-label='Close']", { timeout: 5000 }).click({ force: true }); + cy.deleteForm(); }); }); diff --git a/tests/cypress/e2e/Forms/formsSettings.cy.js b/tests/cypress/e2e/Forms/formsSettings.cy.js index 7300ebd38f..a8baf61435 100644 --- a/tests/cypress/e2e/Forms/formsSettings.cy.js +++ b/tests/cypress/e2e/Forms/formsSettings.cy.js @@ -128,9 +128,9 @@ describe("Updating form settings", () => { cy.get("button[type='submit']").should("contain", "Submit").click(); cy.log("Verify URL redirect after submitting form"); - cy.origin('https://formidableforms.com', ()=> { - cy.location('href').should('include', 'https://formidableforms.com/') - }); + cy.origin('https://formidableforms.com', () => { + cy.location('href', { timeout: 10000 }).should('include', 'formidableforms.com'); + }); cy.log("Navigate back to the formidable form page"); cy.visit(Origin + "/wp-admin/admin.php?page=formidable"); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index ab820b8016..49b8268ae1 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -66,20 +66,21 @@ Cypress.Commands.add("openForm", () => { cy.get('h1 > .frm_bstooltip').should("contain", "Test Form"); cy.get('.current_page').should("contain", "Build"); - cy.get('.frm_field_list > #frm-nav-tabs > .frm-tabs > #frm_insert_fields_tab').should("contain", "Add Fields"); + cy.xpath("//li[@class='frm-active']//a[@id='frm_insert_fields_tab']").should("contain", "Add Fields"); + }); Cypress.Commands.add("getCurrentFormattedDate", () => { const currentDate = new Date(); const formattedDate = currentDate.toISOString().split('T')[0].replace(/-/g, '/'); return formattedDate; -}); +}); Cypress.Commands.add("emptyTrash", () => { cy.log("Precondition - Clear trash if there are deleted forms in the list"); cy.get('.subsubsub > .trash > a').then(($trashLink) => { if ($trashLink.text().includes("Trash")) { - cy.wrap($trashLink).click(); + cy.wrap($trashLink).click(); cy.get('body').then($body => { if ($body.find('#delete_all').length > 0) { cy.get('#delete_all').should("contain", "Empty Trash").click(); @@ -90,5 +91,5 @@ cy.get('.subsubsub > .trash > a').then(($trashLink) => { } else { cy.log('No forms in the Trash.'); } -}); -}); +}); +}); diff --git a/tests/phpunit/forms/test_FrmFormsController.php b/tests/phpunit/forms/test_FrmFormsController.php index 22884968b1..0ade065d50 100644 --- a/tests/phpunit/forms/test_FrmFormsController.php +++ b/tests/phpunit/forms/test_FrmFormsController.php @@ -346,13 +346,13 @@ public function run_message_after_create( $show_form = 0 ) { $this->assertNotEmpty( $created_entry, 'No entry found with key ' . $entry_key ); $response = FrmFormsController::show_form( $form->id ); // this is where the message is returned - $this->assertNotFalse( strpos( $response, '

Done!

' ) ); - $this->assertNotFalse( strpos( $response, 'frmFrontForm.scrollMsg(' . $form->id . ')' ) ); + $this->assertStringContainsString( '
Done!
', $response ); + $this->assertStringContainsString( 'frmFrontForm.scrollMsg(' . $form->id . ')', $response ); if ( $show_form ) { - $this->assertNotFalse( strpos( $response, '' ) ); + $this->assertStringContainsString( '', $response ); } else { - $this->assertFalse( strpos( $response, '' ) ); + $this->assertStringNotContainsString( '', $response ); } }