From 7c1b9f21784124e98384b04651f400267d146d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=A9na=20Proxima?= <adam@phenaproxima.net> Date: Thu, 2 Jan 2025 10:41:04 -0500 Subject: [PATCH] Fix the test --- .../config/webform.webform.contact_form.yml | 2 -- .../tests/e2e/contact_form.cy.js | 30 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/recipes/drupal_cms_forms/config/webform.webform.contact_form.yml b/recipes/drupal_cms_forms/config/webform.webform.contact_form.yml index ec27882e..654c6f73 100644 --- a/recipes/drupal_cms_forms/config/webform.webform.contact_form.yml +++ b/recipes/drupal_cms_forms/config/webform.webform.contact_form.yml @@ -9,8 +9,6 @@ third_party_settings: antibot: true honeypot: honeypot: true -_core: - default_config_hash: Fcw7hXWj_zgosggPLJsVnXVpfHDrnjSh7rv8a_EhoVI weight: 0 open: null close: null diff --git a/recipes/drupal_cms_forms/tests/e2e/contact_form.cy.js b/recipes/drupal_cms_forms/tests/e2e/contact_form.cy.js index 8dcf40a5..48c00483 100644 --- a/recipes/drupal_cms_forms/tests/e2e/contact_form.cy.js +++ b/recipes/drupal_cms_forms/tests/e2e/contact_form.cy.js @@ -1,33 +1,33 @@ describe('Contact form', () => { beforeEach(() => { - cy.setUp('standard').applyRecipe().visit('/contact'); + cy.setUp('standard').applyRecipe(); }); after(() => { cy.tearDown(); }); - it('appears in the main menu', () => { + it('requires all fields and has spam protection', () => { // Ensure the viewport is wide enough to see the main menu links. cy.viewport('macbook-13'); - cy.findByText('Main navigation').parent().find('a:contains("Contact")'); - }); + // Use the main menu link to visit the contact form. + cy.findByText('Main navigation') + .parent() + .find('a:contains("Contact")') + .click(); - it('requires all fields', () => { - cy.findByLabelText('Name').should('have.attr', 'required'); - cy.findByLabelText('Email').should('have.attr', 'required'); - cy.findByLabelText('Message').should('have.attr', 'required'); - cy.findByText('CAPTCHA', { selector: 'fieldset > legend' }).should('exist'); - }); + cy.get('[id^"=webform-submission-contact-form-node-"]').within(() => { + cy.findByLabelText('Name').should('have.attr', 'required'); + cy.findByLabelText('Email').should('have.attr', 'required'); + cy.findByLabelText('Message').should('have.attr', 'required'); + cy.findByText('CAPTCHA', { selector: 'fieldset > legend' }) + .should('exist') + .findByText('Click to start verification') + .should('exist'); - it('has spam protection', () => { - // Confirm the Antibot, Honeypot and Friendly CAPTCHA fields exist within the form. - cy.get('[id^=webform-submission-contact-form-node]').within(() => { cy.get('input[type="hidden"][name="antibot_key"]').should('exist'); cy.get('input[name="url"]').should('not.be.visible'); - // Confirm the friendly CAPTCHA is present. - cy.findByText('Click to start verification').should('exist'); }); }); -- GitLab