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

test: [M3-8693] - Cypress tests for Credit Card Expired banner #11383

Merged
merged 2 commits into from
Dec 10, 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
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11383-tests-1733523460107.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Add cypress test for Credit Card Expired banner ([#11383](https://github.com/linode/manager/pull/11383))
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { accountFactory } from 'src/factories';
import { mockGetAccount } from 'support/intercepts/account';
import { mockGetUserPreferences } from 'support/intercepts/profile';
import { ui } from 'support/ui';

const creditCardExpiredBannerNotice =
'Your credit card has expired! Please update your payment details.';

describe('Credit Card Expired Banner', () => {
beforeEach(() => {
mockGetUserPreferences({ dismissed_notifications: {} });
});

it('appears when the expiration date is in the past', () => {
mockGetAccount(
accountFactory.build({ credit_card: { expiry: '01/2000' } })
).as('getAccount');
cy.visitWithLogin('/');
cy.wait('@getAccount');
cy.findByText(creditCardExpiredBannerNotice).should('be.visible');
ui.button.findByTitle('Update Card').should('be.visible').click();

// clicking on the link navigates to /account/billing
cy.url().should('endWith', '/account/billing');
});

it('does not appear when the expiration date is in the future', () => {
mockGetAccount(
accountFactory.build({ credit_card: { expiry: '01/2999' } })
).as('getAccount');
cy.visitWithLogin('/account/billing');
cy.wait('@getAccount');
cy.findByText('Payment Methods').should('be.visible');
cy.findByText(creditCardExpiredBannerNotice).should('not.exist');
});
});
Loading