Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky cypress tests to use data-cy #1361

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ exports[`NewsletterPreference component renders correctly and displays marketing

<div
className="emotion-0"
data-cy="13"
onClick={[Function]}
>
<div
Expand Down Expand Up @@ -292,6 +293,7 @@ exports[`NewsletterPreference component will select the checkbox when the select

<div
className="emotion-0"
data-cy="13"
onClick={[Function]}
>
<div
Expand Down
1 change: 1 addition & 0 deletions client/components/mma/identity/MarketingCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const MarketingCheckbox: FC<MarketingCheckboxProps> = (props) => {
const { id, description, selected, title, onClick } = props;
return (
<div
data-cy={id}
onClick={(e) => {
// Checkboxes inside labels will trigger click events twice.
// Ignore the input click event
Expand Down
1 change: 1 addition & 0 deletions client/components/mma/identity/MarketingToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const MarketingToggle: FC<MarketingToggleProps> = (props) => {
const { id, description, selected, title, onClick } = props;
return (
<div
data-cy={id}
css={[
standardSansText,
props.divCss ??
Expand Down
1 change: 1 addition & 0 deletions client/components/mma/identity/NewsletterPreference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const NewsletterPreference: FC<NewsletterPreferenceProps> = (props) => {
} = props;
return (
<div
data-cy={id}
onClick={(e) => {
// Checkboxes inside labels will trigger click events twice.
// Ignore the input click event
Expand Down
2 changes: 1 addition & 1 deletion client/fixtures/consents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const consents = [
isOptOut: false,
isChannel: false,
isProduct: false,
name: 'Guardian products and support',
name: 'Similar Guardian products',
description:
'Information on our products and ways to support and enjoy our independent journalism.',
},
Expand Down
4 changes: 2 additions & 2 deletions cypress/tests/e2e/e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ describe('E2E with Okta', () => {
context('emails tab', () => {
it('should allow the user to update their email preferences', () => {
cy.visit('/email-prefs');
cy.findByText('Guardian products and support').click();
cy.get('[data-cy="similar_guardian_products"]').click();
cy.visit('/email-prefs');
cy.findByText('Guardian products and support')
cy.get('[data-cy="similar_guardian_products"]')
.parents('div')
.get('input[type="checkbox"]')
.should('be.checked');
Expand Down
4 changes: 2 additions & 2 deletions cypress/tests/mocked/parallel-6/emailAndMarketing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Email and Marketing page', () => {
cy.wait('@consents');
cy.wait('@reminders');

cy.findByText('Guardian products and support');
cy.get('[data-cy="similar_guardian_products"]');
cy.findByText('Your subscription/support');
cy.findByText('Supporter newsletter');
});
Expand All @@ -90,7 +90,7 @@ describe('Email and Marketing page', () => {
cy.wait('@consents');
cy.wait('@reminders');

cy.findByText('Guardian products and support');
cy.get('[data-cy="similar_guardian_products"]');
cy.findByText('Your subscription/support');
cy.findByText('Supporter newsletter');
});
Expand Down
Loading