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-6611] - Add new assertions for linode backup tests #11326

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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-11326-tests-1732566960471.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Add new assertions for linode backup tests ([#11326](https://github.com/linode/manager/pull/11326))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Add new assertions for linode backup tests ([#11326](https://github.com/linode/manager/pull/11326))
Add new assertions for linode backup Cypress tests ([#11326](https://github.com/linode/manager/pull/11326))

Optional nit for clarity

57 changes: 55 additions & 2 deletions packages/manager/cypress/e2e/core/linodes/backup-linode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
interceptEnableLinodeBackups,
interceptGetLinode,
interceptCreateLinodeSnapshot,
interceptCancelLinodeBackups,
} from 'support/intercepts/linodes';
import { ui } from 'support/ui';
import { cleanUp } from 'support/util/cleanup';
Expand All @@ -28,6 +29,11 @@ import { chooseRegion } from 'support/util/regions';
import { expectManagedDisabled } from 'support/api/managed';
import { createTestLinode } from 'support/util/linodes';

const BackupsCancellationNote =
'Once backups for this Linode have been canceled, you cannot re-enable them for 24 hours.';
const ReenableBackupsFailureNote =
'Please wait 24 hours before reactivating backups for this Linode.';

authenticate();
describe('linode backups', () => {
before(() => {
Expand All @@ -39,6 +45,8 @@ describe('linode backups', () => {
* - Confirms that enable backup prompt is shown when backups are not enabled.
* - Confirms that user is warned of additional backups charges before enabling.
* - Confirms that Linode details page updates to reflect that backups are enabled.
* - Confirms that user can cancel Linode backups.
* - Confirms that user cannot re-enable Linode backups after canceling.
*/
it('can enable backups', () => {
cy.tag('method:e2e');
Expand All @@ -60,9 +68,11 @@ describe('linode backups', () => {
).then((linode: Linode) => {
interceptGetLinode(linode.id).as('getLinode');
interceptEnableLinodeBackups(linode.id).as('enableBackups');
interceptCancelLinodeBackups(linode.id).as('cancelBackups');

// Navigate to Linode details page "Backups" tab.
cy.visitWithLogin(`linodes/${linode.id}/backup`);
cy.visitWithLogin(`linodes/${linode.id}`);
cy.findAllByText('Backups').should('be.visible').click();
cy.wait('@getLinode');

// Wait for Linode to finish provisioning.
Expand Down Expand Up @@ -100,6 +110,48 @@ describe('linode backups', () => {
cy.findByText('Automatic and manual backups will be listed here').should(
'be.visible'
);

// Confirm Backups Cancellation Note is visible when cancel Linode backups.
ui.button
.findByTitle('Cancel Backups')
.should('be.visible')
.should('be.enabled')
.click();
ui.dialog
.findByTitle('Confirm Cancellation')
.should('be.visible')
.within(() => {
cy.contains(BackupsCancellationNote).should('be.visible');
ui.button
.findByTitle('Cancel Backups')
.should('be.visible')
.should('be.enabled')
.click();
});
// Confirm toast notification appears and UI updates to reflect cancel backups.
cy.wait('@cancelBackups');
ui.toast.assertMessage('Backups are being canceled for this Linode');

// Confirm that user is warned when attempting to re-enable Linode backups after canceling.
ui.button
.findByTitle('Enable Backups')
.should('be.visible')
.should('be.enabled')
.click();

ui.dialog
.findByTitle('Enable backups?')
.should('be.visible')
.within(() => {
ui.button
.findByTitle('Enable Backups')
.should('be.visible')
.should('be.enabled')
.click();

// Confirm that users cannot re-enable backups without first waiting 24 hrs.
cy.contains(ReenableBackupsFailureNote).should('be.visible');
});
});
});

Expand Down Expand Up @@ -127,7 +179,8 @@ describe('linode backups', () => {
interceptCreateLinodeSnapshot(linode.id).as('createSnapshot');

// Navigate to Linode details page "Backups" tab.
cy.visitWithLogin(`/linodes/${linode.id}/backup`);
cy.visitWithLogin(`linodes/${linode.id}`);
cy.findAllByText('Backups').should('be.visible').click();
cy.wait('@getLinode');

// Wait for the Linode to finish provisioning.
Expand Down
16 changes: 16 additions & 0 deletions packages/manager/cypress/support/intercepts/linodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,19 @@ export const mockGetLinodeIPAddresses = (
makeResponse(ipAddresses)
);
};

/**
* Intercepts POST request to cancel backups for a Linode.
*
* @param linodeId - ID of Linode for which to enable backups.
*
* @returns Cypress chainable.
*/
export const interceptCancelLinodeBackups = (
linodeId: number
): Cypress.Chainable<null> => {
return cy.intercept(
'POST',
apiMatcher(`linode/instances/${linodeId}/backups/cancel`)
);
};