Skip to content

Commit d194eb9

Browse files
authored
test: [M3-9860] - Fix Cypress Linode clone test (linode#12403)
* M3-9860 Fix Cypress Linode clone test * Added changeset: Fix Cypress Linode clone test
1 parent 9b546a5 commit d194eb9

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Tests
3+
---
4+
5+
Fix Cypress Linode clone test ([#12403](https://github.com/linode/manager/pull/12403))

packages/manager/cypress/e2e/core/linodes/clone-linode.spec.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
LINODE_CREATE_TIMEOUT,
2222
} from 'support/constants/linodes';
2323
import { mockGetLinodeConfigs } from 'support/intercepts/configs';
24+
import { interceptEvents } from 'support/intercepts/events';
2425
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
2526
import {
2627
interceptCloneLinode,
@@ -46,7 +47,7 @@ import {
4647
} from 'support/util/random';
4748
import { chooseRegion, extendRegion } from 'support/util/regions';
4849

49-
import type { Linode } from '@linode/api-v4';
50+
import type { Event, Linode } from '@linode/api-v4';
5051

5152
/**
5253
* Returns the Cloud Manager URL to clone a given Linode.
@@ -78,7 +79,7 @@ describe('clone linode', () => {
7879
*/
7980
it('can clone a Linode from Linode details page', () => {
8081
cy.tag('method:e2e', 'purpose:dcTesting');
81-
const linodeRegion = chooseRegion({ capabilities: ['Vlans'] });
82+
const linodeRegion = chooseRegion({ capabilities: ['Linodes', 'Vlans'] });
8283
const linodePayload = createLinodeRequestFactory.build({
8384
booted: false,
8485
label: randomLabel(),
@@ -96,6 +97,7 @@ describe('clone linode', () => {
9697
createTestLinode(linodePayload, { securityMethod: 'vlan_no_internet' })
9798
).then((linode: Linode) => {
9899
interceptCloneLinode(linode.id).as('cloneLinode');
100+
interceptEvents().as('cloneEvents');
99101
cy.visitWithLogin(`/linodes/${linode.id}`);
100102

101103
// Wait for Linode to boot, then initiate clone flow.
@@ -138,9 +140,30 @@ describe('clone linode', () => {
138140
});
139141

140142
ui.toast.assertMessage(`Your Linode ${newLinodeLabel} is being created.`);
141-
ui.toast.assertMessage(
142-
`Linode ${linode.label} has been cloned to ${newLinodeLabel}.`,
143-
{ timeout: LINODE_CLONE_TIMEOUT }
143+
144+
// Change the way to check the clone progress due to M3-9860
145+
cy.wait('@cloneEvents').then((xhr) => {
146+
const eventData: Event[] = xhr.response?.body?.data;
147+
const cloneEvent = eventData.filter(
148+
(event: Event) => event['action'] === 'linode_clone'
149+
);
150+
cy.get('[id="menu-button--notification-events-menu"]')
151+
.should('be.visible')
152+
.click();
153+
cy.get(`[data-qa-event="${cloneEvent[0]['id']}"]`).should('be.visible');
154+
cy.get('[data-testid="linear-progress"]').should('be.visible');
155+
// The progress bar should disappear when the clone is done.
156+
cy.get('[data-testid="linear-progress"]', {
157+
timeout: LINODE_CLONE_TIMEOUT,
158+
}).should('not.exist');
159+
});
160+
161+
cy.visit('/linodes');
162+
cy.findByText(newLinodeLabel, { timeout: LINODE_CLONE_TIMEOUT }).should(
163+
'be.visible'
164+
);
165+
cy.findByText(linode.label, { timeout: LINODE_CLONE_TIMEOUT }).should(
166+
'be.visible'
144167
);
145168
});
146169
});

packages/manager/cypress/support/intercepts/events.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,11 @@ export const mockGetNotifications = (
8383
paginateResponse(notifications)
8484
);
8585
};
86+
87+
/* Intercepts GET request to get progress events.
88+
*
89+
* @returns Cypress chainable.
90+
*/
91+
export const interceptEvents = (): Cypress.Chainable<null> => {
92+
return cy.intercept('GET', apiMatcher(`account/events*`));
93+
};

0 commit comments

Comments
 (0)