Skip to content

Commit bfd1346

Browse files
committed
Fix Failing tests.
1 parent 8910450 commit bfd1346

File tree

3 files changed

+22
-70
lines changed

3 files changed

+22
-70
lines changed

tests/cypress/e2e/settings/data-persistence.test.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/cypress/e2e/settings/settings.test.js

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,11 @@ describe('Admin can update plugin settings', () => {
8787
// Form is able to be submitted with custom styles
8888
cy.get('#mc_signup_submit')
8989
.scrollIntoView({ offset: { top: -100, left: 0 } })
90-
.should('be.visible') // Check if the button is visible
90+
.should('be.visible') // Check if the button is visible
9191
.and('not.be.disabled'); // Ensure the button is not disabled
9292

9393
// Ensure that custom CSS does not cover submit button
94-
cy.get('#mc_signup_submit')
95-
.then(($el) => {
94+
cy.get('#mc_signup_submit').then(($el) => {
9695
const rect = $el[0].getBoundingClientRect();
9796

9897
// Check that the element is within the viewport
@@ -106,17 +105,17 @@ describe('Admin can update plugin settings', () => {
106105
expect(windowWidth).to.be.greaterThan(0);
107106
expect(rect.bottom).to.be.lessThan(windowHeight);
108107
expect(rect.right).to.be.lessThan(windowWidth);
109-
});
108+
});
110109

111-
// Check if the center of the element is not covered by another element
112-
const centerX = rect.x + $el[0].offsetWidth / 2;
113-
const centerY = rect.y + $el[0].offsetHeight / 2;
110+
// Check if the center of the element is not covered by another element
111+
const centerX = rect.x + $el[0].offsetWidth / 2;
112+
const centerY = rect.y + $el[0].offsetHeight / 2;
114113

115-
cy.document().then((doc) => {
116-
const topElement = doc.elementFromPoint(centerX, centerY);
117-
expect(topElement).to.equal($el[0]);
118-
});
114+
cy.document().then((doc) => {
115+
const topElement = doc.elementFromPoint(centerX, centerY);
116+
expect(topElement).to.equal($el[0]);
119117
});
118+
});
120119
});
121120

122121
// Reset
@@ -222,8 +221,8 @@ describe('Admin can update plugin settings', () => {
222221
});
223222
});
224223

225-
// TODO: BLOCKED - Need separate Mailchimp user to finish this test
226-
it.skip('Ensure settings persist between logging out and logging back in of Mailchimp account', () => {
224+
// TODO: Add case for separate account login and settings get reset.
225+
it('Ensure settings persist between logging out and logging back in of Mailchimp account', () => {
227226
// Step 1: Visit Mailchimp settings page
228227
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
229228
cy.get('#mailchimp_sf_oauth_connect').should('not.exist');
@@ -234,37 +233,22 @@ describe('Admin can update plugin settings', () => {
234233
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
235234

236235
// Verify the custom header is saved
237-
cy.get('#mc-message .success_msg b').contains('Success!');
236+
cy.get('#mc-message .success_msg').contains(
237+
'Successfully Updated your List Subscribe Form Settings!',
238+
);
238239
cy.get('#mc_header_content').should('have.value', customHeader);
239240

240241
// Step 3: Log out of the Mailchimp account
241242
cy.get('input[value="Logout"]').click();
243+
242244
// Verify the logout was successful
243245
cy.get('#mailchimp_sf_oauth_connect').should('exist');
244246

245-
// Step 4: Log in with a different Mailchimp account
246-
// TODO: BLOCKED - We need a separate Mailchimp account to test the login here
247-
cy.mailchimpLogin('different@mailchimp.com', 'password123'); // TODO: CHANGE LOG IN HERE
248-
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
249-
250-
// Verify the default options are displayed for the new account
251-
cy.get('#mc_header_content').should('not.have.value', customHeader); // Expect default value
252-
253-
// Step 5: Set another option with the second account to test persistence
254-
const differentHeader = 'Another Custom Header';
255-
cy.get('#mc_header_content').clear().type(differentHeader);
256-
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
257-
258-
// Verify the new setting is saved for the second account
259-
cy.get('#mc-message .success_msg b').contains('Success!');
260-
cy.get('#mc_header_content').should('have.value', differentHeader);
261-
262-
// Step 6: Log back in with the original Mailchimp account
263-
cy.get('input[value="Logout"]').click();
264-
cy.mailchimpLogin(); // Default to user set in env
247+
// Step 4: Log in back
248+
cy.mailchimpLogin();
265249
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
266250

267-
// Step 7: Ensure the original settings persist
251+
// Step 5: Ensure the original settings persist
268252
cy.get('#mc_header_content').should('have.value', customHeader);
269253
});
270254
});

tests/cypress/e2e/validation/address.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ describe('Address Field Validation', () => {
8484
cy.submitFormAndVerifyError();
8585

8686
if (!address.addr1) {
87-
cy.get('.mc_error_msg').contains('Address: Please enter a value');
87+
cy.get('.mc_error_msg').contains('Address: Please enter a complete address');
8888
}
8989
if (!address.city) {
90-
cy.get('.mc_error_msg').contains('Address: Please enter a value');
90+
cy.get('.mc_error_msg').contains('Address: Please enter a complete address');
9191
}
9292
});
9393
});
94-
});
94+
});

0 commit comments

Comments
 (0)