Skip to content

Commit 92aec32

Browse files
authored
fix: fix variables test to work for IOx (#6572)
* fix: separate iox and tsm tests for variables * fix: update iox env var and flip on ff when testing tsm and iox * fix: don't skip tsm test even in iox * chore: clean up * chore: test for variables tab being hidden in iox * chore: update variable name to shouldShowVariables
1 parent adb9d91 commit 92aec32

File tree

1 file changed

+44
-22
lines changed

1 file changed

+44
-22
lines changed

cypress/e2e/shared/variables.test.ts

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
import {Organization} from '../../../src/types'
22

3-
describe.skip('Variables', () => {
3+
const isIOxOrg = Boolean(Cypress.env('useIox'))
4+
const isTSMOrg = !isIOxOrg
5+
6+
const setupTest = (shouldShowVariables: boolean = true) => {
7+
cy.flush().then(() =>
8+
cy.signin().then(() =>
9+
cy
10+
.setFeatureFlags({
11+
showVariablesInNewIOx: shouldShowVariables,
12+
schemaComposition: true,
13+
})
14+
.then(() =>
15+
cy.get('@org').then(({id}: Organization) => {
16+
cy.createQueryVariable(id)
17+
// cy.wait($time) is necessary to consistently ensure sufficient time for the feature flag override.
18+
// The flag reset happens via redux, (it's not a network request), so we can't cy.wait($intercepted_route).
19+
cy.visit(`orgs/${id}/settings/variables`)
20+
cy.wait(1200)
21+
cy.location('pathname').should('match', /\/variables$/)
22+
})
23+
)
24+
)
25+
)
26+
}
27+
28+
describe('Variables - TSM', () => {
429
beforeEach(() => {
5-
cy.flush()
6-
cy.signin()
7-
cy.get('@org').then(({id}: Organization) => {
8-
cy.createQueryVariable(id)
9-
cy.visit(`orgs/${id}/settings/variables`)
10-
cy.getByTestID('tree-nav')
11-
})
12-
// Double check that the new schemaComposition flag does not interfere.
13-
cy.setFeatureFlags({
14-
schemaComposition: true,
15-
})
16-
// cy.wait($time) is necessary to consistently ensure sufficient time for the feature flag override.
17-
// The flag reset happens via redux, (it's not a network request), so we can't cy.wait($intercepted_route).
18-
cy.wait(1200)
19-
cy.location('pathname').should('match', /\/variables$/)
30+
setupTest()
2031
})
2132

2233
it('can CRUD a CSV, upload, map, and query variable and search for variables based on names', () => {
2334
// Navigate away from and back to variables index using the nav bar
24-
cy.clickNavBarItem('nav-item-dashboards')
35+
cy.clickNavBarItem('nav-item-data-explorer')
2536
cy.clickNavBarItem('nav-item-settings')
26-
cy.getByTestID('templates--tab').click()
37+
cy.getByTestID('labels--tab').click()
2738
cy.getByTestID('variables--tab').click()
2839

2940
cy.getByTestID('resource-card variable').should('have.length', 1)
@@ -87,9 +98,9 @@ describe.skip('Variables', () => {
8798

8899
const lastMapItem = 'Mila Emile,"o61AhpOGr5aO3cYVArC0"'
89100
cy.get('textarea').type(`Juanito MacNeil,"5TKl6l8i4idg15Fxxe4P"
90-
Astrophel Chaudhary,"bDhZbuVj5RV94NcFXZPm"
91-
Ochieng Benes,"YIhg6SoMKRUH8FMlHs3V"
92-
${lastMapItem}`)
101+
Astrophel Chaudhary,"bDhZbuVj5RV94NcFXZPm"
102+
Ochieng Benes,"YIhg6SoMKRUH8FMlHs3V"
103+
${lastMapItem}`)
93104

94105
cy.getByTestID('map-variable-dropdown--button').click()
95106
cy.contains(lastMapItem).click()
@@ -158,7 +169,7 @@ describe.skip('Variables', () => {
158169
cy.getByInputName('name').type(mapVariableName)
159170

160171
cy.get('textarea').type(`Astrophel Chaudhary,"bDhZbuVj5RV94NcFXZPm"
161-
Ochieng Benes,"YIhg6SoMKRUH8FMlHs3V"`)
172+
Ochieng Benes,"YIhg6SoMKRUH8FMlHs3V"`)
162173

163174
cy.getByTestID('map-variable-dropdown--button').click().last().click()
164175

@@ -412,3 +423,14 @@ describe.skip('Variables', () => {
412423
.contains(thirdVariableName)
413424
})
414425
})
426+
427+
describe('Variables - IOx', () => {
428+
it('routes to 404 page when IOx user attempts to access variables', () => {
429+
cy.skipOn(isTSMOrg)
430+
const shouldShowVariables = false
431+
setupTest(shouldShowVariables)
432+
cy.contains('404: Page Not Found')
433+
cy.clickNavBarItem('nav-item-settings')
434+
cy.getByTestID('variables--tab').should('not.exist')
435+
})
436+
})

0 commit comments

Comments
 (0)