From 28de67fad6c79c0044ab5590ad66a132ba0cbcb7 Mon Sep 17 00:00:00 2001 From: Azure Shi Date: Thu, 21 Nov 2024 10:17:09 -0500 Subject: [PATCH 1/3] Add new assertions for linode backup tests --- .../e2e/core/linodes/backup-linode.spec.ts | 54 ++++++++++++++++++- .../cypress/support/intercepts/linodes.ts | 16 ++++++ 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/packages/manager/cypress/e2e/core/linodes/backup-linode.spec.ts b/packages/manager/cypress/e2e/core/linodes/backup-linode.spec.ts index 54eaf02e5b6..a01cabb6071 100644 --- a/packages/manager/cypress/e2e/core/linodes/backup-linode.spec.ts +++ b/packages/manager/cypress/e2e/core/linodes/backup-linode.spec.ts @@ -19,6 +19,7 @@ import { interceptEnableLinodeBackups, interceptGetLinode, interceptCreateLinodeSnapshot, + interceptCancelLinodeBackups, } from 'support/intercepts/linodes'; import { ui } from 'support/ui'; import { cleanUp } from 'support/util/cleanup'; @@ -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(() => { @@ -60,9 +66,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. @@ -100,6 +108,47 @@ 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'); + + 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 user is warned of additional backup charges. + cy.contains(ReenableBackupsFailureNote).should('be.visible'); + }); }); }); @@ -127,7 +176,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. diff --git a/packages/manager/cypress/support/intercepts/linodes.ts b/packages/manager/cypress/support/intercepts/linodes.ts index 2a665ac49bc..5511492da28 100644 --- a/packages/manager/cypress/support/intercepts/linodes.ts +++ b/packages/manager/cypress/support/intercepts/linodes.ts @@ -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 => { + return cy.intercept( + 'POST', + apiMatcher(`linode/instances/${linodeId}/backups/cancel`) + ); +}; From cb16fefb052f4657d1e96a1bd631630511af294b Mon Sep 17 00:00:00 2001 From: Azure Shi Date: Mon, 25 Nov 2024 15:32:19 -0500 Subject: [PATCH 2/3] Update comments --- .../manager/cypress/e2e/core/linodes/backup-linode.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/manager/cypress/e2e/core/linodes/backup-linode.spec.ts b/packages/manager/cypress/e2e/core/linodes/backup-linode.spec.ts index a01cabb6071..3f6518e2bec 100644 --- a/packages/manager/cypress/e2e/core/linodes/backup-linode.spec.ts +++ b/packages/manager/cypress/e2e/core/linodes/backup-linode.spec.ts @@ -45,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'); @@ -130,6 +132,7 @@ describe('linode 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') @@ -146,7 +149,7 @@ describe('linode backups', () => { .should('be.enabled') .click(); - // Confirm that user is warned of additional backup charges. + // Confirm that users cannot re-enable backups without first waiting 24 hrs. cy.contains(ReenableBackupsFailureNote).should('be.visible'); }); }); From 47415d3e8dfc110c19a6448e236547c5a6142776 Mon Sep 17 00:00:00 2001 From: Azure Shi Date: Mon, 25 Nov 2024 15:36:00 -0500 Subject: [PATCH 3/3] Added changeset: Add new assertions for linode backup tests --- packages/manager/.changeset/pr-11326-tests-1732566960471.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/manager/.changeset/pr-11326-tests-1732566960471.md diff --git a/packages/manager/.changeset/pr-11326-tests-1732566960471.md b/packages/manager/.changeset/pr-11326-tests-1732566960471.md new file mode 100644 index 00000000000..0b9010605e3 --- /dev/null +++ b/packages/manager/.changeset/pr-11326-tests-1732566960471.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Tests +--- + +Add new assertions for linode backup tests ([#11326](https://github.com/linode/manager/pull/11326))