Skip to content

Commit 0990ccd

Browse files
wiedldwdoconnell
andauthored
fix: cloud tests for iox behavior (#6497)
* fix: cloud tests for iox behavior * chore: add new cy methods to type declaration * chore: resolve gh test behavior with iox orgs Co-authored-by: wdoconnell <91283923+wdoconnell@users.noreply.github.com>
1 parent eb4065c commit 0990ccd

File tree

4 files changed

+34
-40
lines changed

4 files changed

+34
-40
lines changed

cypress/e2e/cloud/billing.test.ts

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,28 @@ describe('Billing Page Free Users', () => {
1313
'Series Cardinality',
1414
]
1515

16-
interface FreeTestSettings {
17-
orgIsIOx: boolean
18-
}
19-
20-
const setupFreeTest = (settings: FreeTestSettings) => {
21-
cy.intercept('GET', '/api/v2/orgs', req => {
22-
req.continue(res => {
23-
if (settings.orgIsIOx) {
24-
res.body.orgs[0].defaultStorageType = 'iox'
25-
}
26-
})
16+
beforeEach(() => {
17+
cy.flush().then(() => {
18+
cy.signin()
2719
})
20+
})
2821

29-
cy.flush().then(() => {
30-
cy.signin().then(() => {
31-
cy.get('@org').then(({id}: Organization) => {
32-
cy.quartzProvision({
33-
accountType: 'free',
34-
}).then(() => {
35-
cy.visit(`/orgs/${id}/billing`)
36-
cy.getByTestID('billing-page--header').should('be.visible')
37-
})
38-
})
22+
const setupFreeTest = () => {
23+
cy.get('@org').then(({id}: Organization) => {
24+
cy.quartzProvision({
25+
accountType: 'free',
26+
}).then(() => {
27+
cy.visit(`/orgs/${id}/billing`)
28+
cy.getByTestID('billing-page--header').should('be.visible')
3929
})
4030
})
4131
}
4232

4333
it('should display the free billing page for free users', () => {
44-
setupFreeTest({orgIsIOx: false})
34+
cy.isIoxOrg().then(isIOx => {
35+
cy.skipOn(isIOx)
36+
})
37+
setupFreeTest()
4538

4639
cy.getByTestID('cloud-upgrade--button').should('be.visible')
4740
cy.getByTestID('title-header--name')
@@ -62,7 +55,10 @@ describe('Billing Page Free Users', () => {
6255
})
6356

6457
it('should not display the cardinality limit in an iox org', () => {
65-
setupFreeTest({orgIsIOx: true})
58+
cy.isIoxOrg().then(isIOx => {
59+
cy.skipOn(!isIOx)
60+
})
61+
setupFreeTest()
6662

6763
const limitsWithoutCardinality = limitNames.slice(0, -1)
6864

cypress/e2e/cloud/globalHeader.test.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import {makeQuartzUseIDPEOrgID} from 'cypress/support/Utils'
2+
import {Organization} from 'src/client'
23

34
describe('global header', () => {
45
let idpeOrgID: string
6+
let idpeOrg: Organization
7+
8+
const orgIsIOx = () => idpeOrg.defaultStorageType === 'iox'
59

610
before(() => {
711
cy.flush().then(() =>
@@ -14,6 +18,7 @@ describe('global header', () => {
1418
// Store the IDPE org ID so that it can be cloned when intercepting quartz.
1519
if (res.body.orgs) {
1620
idpeOrgID = res.body.orgs[0].id
21+
idpeOrg = res.body.orgs[0]
1722
}
1823
})
1924
})
@@ -180,33 +185,21 @@ describe('global header', () => {
180185
})
181186

182187
describe('cardinality alerts', () => {
183-
interface TestParams {
184-
orgIsIOx: boolean
185-
}
186-
187-
const setupCardinalityTest = (params: TestParams) => {
188+
const setupCardinalityTest = () => {
188189
cy.intercept('GET', 'api/v2private/orgs/**/limits/status', req => {
189190
req.continue(res => {
190191
res.body.cardinality.status = 'exceeded'
191192
})
192193
})
193-
194-
if (params.orgIsIOx) {
195-
cy.intercept('GET', '/api/v2/orgs', req => {
196-
req.continue(res => {
197-
res.body.orgs[0].defaultStorageType = 'iox'
198-
})
199-
})
200-
}
201-
202194
makeQuartzUseIDPEOrgID(idpeOrgID, 'pay_as_you_go')
203195
// Alert will appear in global header on any page (like data explorer)
204196
// that has <LimitChecker />, which displays cardinality alerts.
205197
cy.visit(`/orgs/${idpeOrgID}/data-explorer`)
206198
}
207199

208200
it('shows a cardinality limit alert for TSM orgs if cardinality limits are exceeded', () => {
209-
setupCardinalityTest({orgIsIOx: false})
201+
cy.skipOn(orgIsIOx())
202+
setupCardinalityTest()
210203

211204
cy.getByTestID('rate-alert--banner')
212205
.should('be.visible')
@@ -217,7 +210,8 @@ describe('global header', () => {
217210
})
218211

219212
it('never shows a cardinality limit alert for IOx orgs', () => {
220-
setupCardinalityTest({orgIsIOx: true})
213+
cy.skipOn(!orgIsIOx())
214+
setupCardinalityTest()
221215

222216
cy.getByTestID('rate-alert--banner').should('not.exist')
223217
cy.contains('series cardinality').should('not.exist')

cypress/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint @typescript-eslint/no-unused-vars: "off" */
22
import 'jest'
33
import 'cypress-plugin-tab'
4+
import {skipOn} from '@cypress/skip-test'
45

56
import {
67
signin,
@@ -12,6 +13,7 @@ import {
1213
createSource,
1314
deleteOrg,
1415
flush,
16+
isIoxOrg,
1517
getByTestID,
1618
getByTestIDHead,
1719
getByInputName,
@@ -80,6 +82,8 @@ declare global {
8082
createOrg: typeof createOrg
8183
deleteOrg: typeof deleteOrg
8284
flush: typeof flush
85+
isIoxOrg: typeof isIoxOrg
86+
skipOn: typeof skipOn
8387
getByTestID: typeof getByTestID
8488
getByTestIDHead: typeof getByTestIDHead
8589
getByInputName: typeof getByInputName

cypress/support/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export const wrapDefaultPassword = (): Cypress.Chainable => {
226226
return cy.wrap(password).as('defaultPassword')
227227
}
228228

229-
export const isIoxOrg = (): Cypress.Chainable<Cypress.Response<any>> => {
229+
export const isIoxOrg = (): Cypress.Chainable<boolean> => {
230230
return cy.get('@org').then(({defaultStorageType}: Organization) => {
231231
return Boolean(
232232
defaultStorageType && defaultStorageType.toLowerCase() === 'iox'

0 commit comments

Comments
 (0)