From ea6ec5e69dbdbd958636a65884c31e9baf9a4865 Mon Sep 17 00:00:00 2001 From: Richard Bangay Date: Mon, 14 Oct 2024 14:26:00 +0100 Subject: [PATCH] update cypress e2e test css selectors .. the checkboxes now don't have the css class that was being targeted --- .../NewsletterPreference.test.tsx.snap | 4 ++-- .../mma/identity/NewsletterPreference.tsx | 2 +- client/components/mma/identity/PageSection.tsx | 4 +++- .../emailAndMarketing/NewsletterSection.tsx | 1 + cypress/tests/e2e/e2e.cy.ts | 15 ++++++++------- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/client/__tests__/components/identity/__snapshots__/NewsletterPreference.test.tsx.snap b/client/__tests__/components/identity/__snapshots__/NewsletterPreference.test.tsx.snap index 061a6d7ed..aff1bc555 100644 --- a/client/__tests__/components/identity/__snapshots__/NewsletterPreference.test.tsx.snap +++ b/client/__tests__/components/identity/__snapshots__/NewsletterPreference.test.tsx.snap @@ -234,7 +234,6 @@ html:not(.src-focus-disabled) .emotion-2:focus {
= (props) => { return (
= (props) => { ]} > ( @@ -50,9 +51,10 @@ const getSubtext = (subtext: PageSectionProps['subtext']) => ( ); export const PageSection: FC = (props) => { - const { children, description, title, subtext } = props; + const { children, description, title, subtext, testSelector } = props; return (
= (props) => { const { newsletters, clickHandler } = props; return ( { cy.get('[data-cy="similar_guardian_products"]').click(); cy.visit('/email-prefs'); cy.get('[data-cy="similar_guardian_products"]') - .parents('div') - .get('.checkbox') - .should('have.attr', 'aria-checked') - .and('eq', 'true'); + .find('input[type=checkbox]') + .should('be.checked'); }); it('should allow the user to unsubscribe from all emails', () => { cy.visit('/email-prefs'); cy.findByText('Unsubscribe from all emails').click(); cy.visit('/email-prefs'); - cy.get('.checkbox') - .should('have.attr', 'aria-checked') - .and('eq', 'false'); + cy.get('[data-cy="similar_guardian_products"]') + .find('input[type=checkbox]') + .should('not.be.checked'); + cy.get('[data-cy="your_newsletters"]') + .find('input[type=checkbox]') + .should('not.be.checked'); }); });