Skip to content

Commit

Permalink
fix: [M3-7508] - Follow up on tests to check Parent and Child 'Close …
Browse files Browse the repository at this point in the history
…Account' flows (linode#10316)

* M3-7508 Fixed previous PR comments

* Added changeset: Add tests to check Parent and Child Close Account flows

* Added original PR link

* Fix constants
  • Loading branch information
cliu-akamai authored and bnussman committed Apr 4, 2024
1 parent faa220b commit 5ae37fa
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 29 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10316-tests-1711480175744.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Add tests to check Parent and Child Close Account flows ([#10316](https://github.com/linode/manager/pull/10316), [#10296](https://github.com/linode/manager/pull/10296))
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import {
mockCancelAccount,
mockCancelAccountError,
} from 'support/intercepts/account';
import {
cancellationDataLossWarning,
cancellationPaymentErrorMessage,
} from 'support/constants/account';
import {
CHILD_USER_CLOSE_ACCOUNT_TOOLTIP_TEXT,
PARENT_USER_CLOSE_ACCOUNT_TOOLTIP_TEXT,
PROXY_USER_CLOSE_ACCOUNT_TOOLTIP_TEXT,
} from 'src/features/Account/constants';
import { mockGetProfile } from 'support/intercepts/profile';
import { ui } from 'support/ui';
import {
Expand All @@ -24,29 +33,6 @@ import {
} from 'support/intercepts/feature-flags';
import { makeFeatureFlagData } from 'support/util/feature-flags';

// Data loss warning which is displayed in the account cancellation dialog.
const cancellationDataLossWarning =
'Please note this is an extremely destructive action. Closing your account \
means that all services Linodes, Volumes, DNS Records, etc will be lost and \
may not be able be restored.';

// Error message that appears when a payment failure occurs upon cancellation attempt.
const cancellationPaymentErrorMessage =
'We were unable to charge your credit card for services rendered. \
We cannot cancel this account until the balance has been paid.';

// Tooltip message that appears when a child account tries to close the account.
const contactParentUserTooltipsMessage =
'Contact your parent user to close your account.';

// Tooltip message that appears when a child account tries to close the account.
const contactCustomerSupportTooltipsMessage =
'Contact customer support to close this account.';

// Tooltip message that appears when a parent account with one and more child accounts tries to close the account.
const removeChildAccountTooltipsMessage =
'Remove child accounts before closing the account.';

describe('Account cancellation', () => {
/*
* - Confirms that a user can cancel their account from the Account Settings page.
Expand Down Expand Up @@ -246,15 +232,15 @@ describe('Parent/Child account cancellation', () => {
.trigger('mouseover');
// Click the button first, then confirm the tooltip is shown.
ui.tooltip
.findByText(contactParentUserTooltipsMessage)
.findByText(CHILD_USER_CLOSE_ACCOUNT_TOOLTIP_TEXT)
.should('be.visible');
});
});

/**
* Confirms that a proxy account cannot close the account
*/
it('disables a proxy account to close the account', () => {
it('disables "Close Account" button for proxy users', () => {
const mockAccount = accountFactory.build();
const mockProfile = profileFactory.build({
username: 'proxy-user',
Expand All @@ -280,15 +266,15 @@ describe('Parent/Child account cancellation', () => {
.trigger('mouseover');
// Click the button first, then confirm the tooltip is shown.
ui.tooltip
.findByText(contactCustomerSupportTooltipsMessage)
.findByText(PROXY_USER_CLOSE_ACCOUNT_TOOLTIP_TEXT)
.should('be.visible');
});
});

/**
* Confirms that a parent account with one or more active child accounts cannot close the account
*/
it('disables a parent account with one or more active child accounts to close the account', () => {
it('disables "Close Account" button for parent users', () => {
const mockAccount = accountFactory.build();
const mockProfile = profileFactory.build({
username: 'parent-user',
Expand All @@ -314,7 +300,7 @@ describe('Parent/Child account cancellation', () => {
.trigger('mouseover');
// Click the button first, then confirm the tooltip is shown.
ui.tooltip
.findByText(removeChildAccountTooltipsMessage)
.findByText(PARENT_USER_CLOSE_ACCOUNT_TOOLTIP_TEXT)
.should('be.visible');
});
});
Expand All @@ -326,7 +312,7 @@ describe('Parent/Child account cancellation', () => {
const mockAccount = accountFactory.build();
const mockProfile = profileFactory.build({
username: 'default-user',
restricted: true,
restricted: false,
user_type: 'default',
});
const mockCancellationResponse: CancelAccount = {
Expand Down
14 changes: 14 additions & 0 deletions packages/manager/cypress/support/constants/account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Data loss warning which is displayed in the account cancellation dialog.
*/
export const cancellationDataLossWarning =
'Please note this is an extremely destructive action. Closing your account \
means that all services Linodes, Volumes, DNS Records, etc will be lost and \
may not be able be restored.';

/**
* Error message that appears when a payment failure occurs upon cancellation attempt.
*/
export const cancellationPaymentErrorMessage =
'We were unable to charge your credit card for services rendered. \
We cannot cancel this account until the balance has been paid.';

0 comments on commit 5ae37fa

Please sign in to comment.