Skip to content

Commit 4db0e0c

Browse files
test: [M3 9573] - Fix OBJ enrollment test failures in DevCloud (linode#12135)
* mock pricing for previously mocked regions * remove querystring from apiMatcher * simplify param for intercept * Added changeset: Bugfix for object enrollment tests in devcloud
1 parent c6e15e8 commit 4db0e0c

File tree

4 files changed

+145
-2
lines changed

4 files changed

+145
-2
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+
Bugfix for object enrollment tests in devcloud ([#12135](https://github.com/linode/manager/pull/12135))

packages/manager/cypress/e2e/core/objectStorage/enable-object-storage.spec.ts

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import {
1313
mockGetAccountSettings,
1414
} from 'support/intercepts/account';
1515
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
16+
import { mockGetPrices } from 'support/intercepts/network-transfer';
1617
import {
1718
mockCancelObjectStorage,
1819
mockCreateAccessKey,
1920
mockGetAccessKeys,
2021
mockGetBuckets,
2122
mockGetClusters,
23+
mockGetObjectStorageTypes,
2224
} from 'support/intercepts/object-storage';
2325
import { mockGetProfile } from 'support/intercepts/profile';
2426
import { mockGetRegions } from 'support/intercepts/regions';
@@ -29,6 +31,7 @@ import type {
2931
AccountSettings,
3032
ObjectStorageCluster,
3133
ObjectStorageClusterID,
34+
PriceType,
3235
Region,
3336
} from '@linode/api-v4';
3437

@@ -113,10 +116,90 @@ describe('Object Storage enrollment', () => {
113116
}),
114117
];
115118

119+
const mockPrices: PriceType[] = [
120+
{
121+
id: 'distributed_network_transfer',
122+
label: 'Distributed Network Transfer',
123+
price: {
124+
hourly: 0.01,
125+
monthly: null,
126+
},
127+
region_prices: [],
128+
transfer: 0,
129+
},
130+
{
131+
id: 'network_transfer',
132+
label: 'Network Transfer',
133+
price: {
134+
hourly: 0.005,
135+
monthly: null,
136+
},
137+
region_prices: [
138+
{
139+
id: 'id-cgk',
140+
hourly: 0.015,
141+
monthly: null,
142+
},
143+
{
144+
id: 'br-gru',
145+
hourly: 0.007,
146+
monthly: null,
147+
},
148+
],
149+
transfer: 0,
150+
},
151+
];
152+
const mockObjectStorageTypes = [
153+
{
154+
id: 'objectstorage',
155+
label: 'Object Storage',
156+
price: {
157+
hourly: 0.0075,
158+
monthly: 5,
159+
},
160+
region_prices: [
161+
{
162+
id: 'id-cgk',
163+
hourly: 0.0075,
164+
monthly: 5,
165+
},
166+
{
167+
id: 'br-gru',
168+
hourly: 0.0075,
169+
monthly: 5,
170+
},
171+
],
172+
transfer: 1000,
173+
},
174+
{
175+
id: 'objectstorage-overage',
176+
label: 'Object Storage Overage',
177+
price: {
178+
hourly: 0.02,
179+
monthly: null,
180+
},
181+
region_prices: [
182+
{
183+
id: 'id-cgk',
184+
hourly: 0.024,
185+
monthly: null,
186+
},
187+
{
188+
id: 'br-gru',
189+
hourly: 0.028,
190+
monthly: null,
191+
},
192+
],
193+
transfer: 0,
194+
},
195+
];
116196
const mockAccessKey = objectStorageKeyFactory.build({
117197
label: randomLabel(),
118198
});
119-
199+
mockGetPrices(mockPrices).as('getPrices');
200+
mockGetObjectStorageTypes(mockObjectStorageTypes).as(
201+
'getObjectStorageTypes'
202+
);
120203
mockGetAccountSettings(mockAccountSettings).as('getAccountSettings');
121204
mockGetClusters(mockClusters).as('getClusters');
122205
mockGetBuckets([]).as('getBuckets');
@@ -140,7 +223,7 @@ describe('Object Storage enrollment', () => {
140223
.should('be.visible')
141224
.should('be.enabled')
142225
.click();
143-
226+
cy.wait(['@getPrices', '@getObjectStorageTypes']);
144227
ui.drawer
145228
.findByTitle('Create Bucket')
146229
.should('be.visible')
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @file Cypress intercepts and mocks for Cloud Manager Object Storage operations.
3+
*/
4+
5+
import { apiMatcher } from 'support/util/intercepts';
6+
import { paginateResponse } from 'support/util/paginate';
7+
8+
import type { PriceType } from '@linode/api-v4';
9+
10+
/**
11+
* Intercepts GET requests to fetch network-transfer prices and mocks response.
12+
*
13+
* Only returns data for the first request intercepted.
14+
*
15+
* @param priceTypes - Object storage buckets with which to mock response.
16+
*
17+
* @returns Cypress chainable.
18+
*/
19+
export const mockGetPrices = (
20+
priceTypes: PriceType[]
21+
): Cypress.Chainable<null> => {
22+
/*
23+
* Only the first mocked response will contain data. Subsequent responses
24+
* will contain an empty array.
25+
*
26+
* This is necessary because the Object Storage Buckets landing page makes
27+
* an indeterminate number of requests to `/object-storage/buckets/<region>`,
28+
* where `<region>` may be any region where Object Storage is supported.
29+
*/
30+
return cy.intercept(
31+
'GET',
32+
apiMatcher('network-transfer/prices*'),
33+
paginateResponse(priceTypes)
34+
);
35+
};

packages/manager/cypress/support/intercepts/object-storage.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import type {
1717
ObjectStorageCluster,
1818
ObjectStorageEndpoint,
1919
ObjectStorageKey,
20+
PriceType,
2021
} from '@linode/api-v4';
2122

2223
/**
@@ -55,6 +56,25 @@ export const mockGetBuckets = (
5556
);
5657
};
5758

59+
/**
60+
* Intercepts GET requests to fetch object-storage types and mocks response.
61+
*
62+
* Only returns data for the first request intercepted.
63+
*
64+
* @param priceTypes - Object storage buckets with which to mock response.
65+
*
66+
* @returns Cypress chainable.
67+
*/
68+
export const mockGetObjectStorageTypes = (
69+
priceTypes: PriceType[]
70+
): Cypress.Chainable<null> => {
71+
return cy.intercept(
72+
'GET',
73+
apiMatcher('object-storage/types*'),
74+
paginateResponse(priceTypes)
75+
);
76+
};
77+
5878
/**
5979
* Intercepts GET request to fetch buckets for a region and mocks response.
6080
*

0 commit comments

Comments
 (0)