Skip to content

Commit

Permalink
test: [M3-8758]- Fixed delete-volume.spec.ts flaky test (#11365)
Browse files Browse the repository at this point in the history
* test: [M3-8758]- Flake  flaky test

* Added changeset: Fix `delete-volume.spec.ts` flaky test
  • Loading branch information
harsh-akamai authored Dec 6, 2024
1 parent 3d62d31 commit 82c8990
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11365-tests-1733305182663.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Fix `delete-volume.spec.ts` flaky test ([#11365](https://github.com/linode/manager/pull/11365))
19 changes: 17 additions & 2 deletions packages/manager/cypress/e2e/core/volumes/delete-volume.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createVolume } from '@linode/api-v4/lib/volumes';
import { createVolume, VolumeRequestPayload } from '@linode/api-v4/lib/volumes';
import { Volume } from '@linode/api-v4';
import { volumeRequestPayloadFactory } from 'src/factories/volume';
import { authenticate } from 'support/api/authentication';
Expand All @@ -7,6 +7,8 @@ import { randomLabel } from 'support/util/random';
import { ui } from 'support/ui';
import { chooseRegion } from 'support/util/regions';
import { cleanUp } from 'support/util/cleanup';
import { SimpleBackoffMethod } from 'support/util/backoff';
import { pollVolumeStatus } from 'support/util/polling';

// Local storage override to force volume table to list up to 100 items.
// This is a workaround while we wait to get stuck volumes removed.
Expand All @@ -15,6 +17,19 @@ const pageSizeOverride = {
PAGE_SIZE: 100,
};

/**
* Creates a Volume and waits for it to become active.
*
* @param volumeRequest - Volume create request payload.
*
* @returns Promise that resolves to created Volume.
*/
const createActiveVolume = async (volumeRequest: VolumeRequestPayload) => {
const volume = await createVolume(volumeRequest);
await pollVolumeStatus(volume.id, 'active', new SimpleBackoffMethod(10000));
return volume;
};

authenticate();
describe('volume delete flow', () => {
before(() => {
Expand All @@ -37,7 +52,7 @@ describe('volume delete flow', () => {
region: chooseRegion().id,
});

cy.defer(() => createVolume(volumeRequest), 'creating volume').then(
cy.defer(() => createActiveVolume(volumeRequest), 'creating volume').then(
(volume: Volume) => {
interceptDeleteVolume(volume.id).as('deleteVolume');
cy.visitWithLogin('/volumes', {
Expand Down

0 comments on commit 82c8990

Please sign in to comment.