Skip to content

Commit

Permalink
test: [M3-6611] - Add new assertions for linode backup tests (#11326)
Browse files Browse the repository at this point in the history
* Add new assertions for linode backup tests

* Update comments

* Added changeset: Add new assertions for linode backup tests

* update changeset comment
  • Loading branch information
AzureLatte authored Dec 3, 2024
1 parent 9afb2bc commit 8dfa028
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
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 Cypress tests ([#11326](https://github.com/linode/manager/pull/11326))
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`)
);
};

0 comments on commit 8dfa028

Please sign in to comment.