Skip to content

Commit 63d8069

Browse files
authored
fix(6562): extract common cypress methods, and fix script builder iox tests (#6593)
* chore: extract reusable script methods into cypress commands * chore: have the default be showing new dataExplorer, and have tests explicit set which explorer they need * chore: have the script crud buttons match the new cypress fixtures * chore: stop clearing downloads folder, since we don't read from fs (instead, we intercept the network request) * fix(6562): have scriptBuilder tests use the new cypress fixtures, unskip and debug * chore: debugging. * fix(6562): extract mockIsCloud2Org cypress method, and use in the explorer tests whicih are failing due to AppSettings.scriptQueryBuilder being out of alignment when using showOldDataExplorerInNewIOx
1 parent 4ad60ce commit 63d8069

File tree

14 files changed

+337
-462
lines changed

14 files changed

+337
-462
lines changed

cypress/e2e/cloud/explorer.test.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,28 @@ function getTimeMachineText() {
1515
}
1616

1717
describe('DataExplorer', () => {
18+
before(() => {
19+
cy.flush().then(() => cy.signin())
20+
})
21+
1822
beforeEach(() => {
19-
cy.flush().then(() =>
20-
cy.signin().then(() => {
21-
cy.setFeatureFlags({
22-
showOldDataExplorerInNewIOx: true,
23-
}).then(() =>
24-
cy.get('@org').then(({id}: Organization) => {
25-
cy.createMapVariable(id)
26-
cy.fixture('routes').then(({orgs, explorer}) => {
27-
cy.visit(`${orgs}/${id}${explorer}`)
28-
cy.getByTestID('tree-nav').should('be.visible')
29-
})
23+
cy.mockIsCloud2Org().then(() =>
24+
cy.signinWithoutUserReprovision().then(() =>
25+
cy
26+
.setFeatureFlags({
27+
newDataExplorer: true,
3028
})
31-
)
32-
})
29+
.then(() =>
30+
cy.get('@org').then(({id}: Organization) => {
31+
return cy.fixture('routes').then(({orgs, explorer}) => {
32+
cy.visit(`${orgs}/${id}${explorer}`)
33+
cy.getByTestID('tree-nav').should('be.visible')
34+
cy.switchToDataExplorer('old')
35+
cy.getByTestID('switch-to-script-editor').should('exist')
36+
})
37+
})
38+
)
39+
)
3340
)
3441
})
3542

cypress/e2e/cloud/releases.test.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import {Organization} from '../../../src/types'
22

3-
// webpack bundling error if try importing --> due to imports in the constants file
4-
const IOX_SWITCHOVER_CREATION_DATE = '2023-01-31T00:00:00Z'
5-
63
describe('Deprecations per cloud release', () => {
74
before(() => {
85
cy.flush().then(() =>
@@ -133,20 +130,8 @@ describe('Deprecations per cloud release', () => {
133130
})
134131

135132
describe('iox users prior to the Marty-release date', () => {
136-
const beforeCutoff = new Date(
137-
new Date(IOX_SWITCHOVER_CREATION_DATE) - 10000
138-
).toISOString()
139133
beforeEach(() => {
140-
cy.intercept('GET', '/api/v2/orgs', req => {
141-
req.continue(res => {
142-
const orgs = res.body.orgs.map(org => ({
143-
...org,
144-
createdAt: beforeCutoff,
145-
}))
146-
res.body.orgs = orgs
147-
})
148-
})
149-
cy.signinWithoutUserReprovision()
134+
cy.mockIsCloud2Org().then(() => cy.signinWithoutUserReprovision())
150135
})
151136

152137
it('have everything exist except notebooks', () => {

cypress/e2e/oss/explorer.test.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,25 @@ function getTimeMachineText() {
2424
}
2525
describe('DataExplorer', () => {
2626
beforeEach(() => {
27-
cy.flush()
28-
cy.signin()
29-
cy.get('@org').then(({id}: Organization) => {
30-
cy.createMapVariable(id)
31-
cy.fixture('routes').then(({orgs, explorer}) => {
32-
cy.visit(`${orgs}/${id}${explorer}`)
33-
cy.getByTestID('tree-nav').should('be.visible')
34-
})
35-
})
27+
cy.flush().then(() =>
28+
cy.signin().then(() =>
29+
cy
30+
.setFeatureFlags({
31+
newDataExplorer: true,
32+
})
33+
.then(() =>
34+
cy.get('@org').then(({id}: Organization) => {
35+
cy.fixture('routes').then(({orgs, explorer}) => {
36+
cy.visit(`${orgs}/${id}${explorer}`)
37+
cy.getByTestID('tree-nav').should('be.visible')
38+
cy.switchToDataExplorer('old')
39+
})
40+
})
41+
)
42+
)
43+
)
3644
})
45+
3746
describe('raw script editing', () => {
3847
beforeEach(() => {
3948
cy.getByTestID('switch-to-script-editor').should('be.visible').click()

cypress/e2e/shared/editor.test.ts

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

3-
const DEFAULT_FLUX_EDITOR_TEXT =
4-
'// Start by selecting data from the schema browser or typing flux here'
5-
63
// to see list of monaco-editor widgets to check:
74
// document.querySelectorAll('[widgetid]')
85

@@ -89,6 +86,7 @@ describe('Editor+LSP communication', () => {
8986
cy.fixture('routes').then(({orgs, explorer}) => {
9087
cy.visit(`${orgs}/${id}${explorer}`)
9188
cy.getByTestID('tree-nav').should('be.visible')
89+
cy.switchToDataExplorer('old')
9290
})
9391
})
9492
// Double check that the new schemaComposition flag does not interfere.
@@ -99,57 +97,19 @@ describe('Editor+LSP communication', () => {
9997
})
10098

10199
describe('in Script Editor', () => {
102-
const setScriptToFlux = () => {
103-
return cy.isIoxOrg().then(isIox => {
104-
if (isIox) {
105-
cy.getByTestID('query-builder--new-script')
106-
.should('be.visible')
107-
.click()
108-
cy.getByTestID('script-dropdown__flux').should('be.visible').click()
109-
cy.getByTestID('overlay--container').within(() => {
110-
cy.getByTestID('script-query-builder--no-save')
111-
.should('be.visible')
112-
.click()
113-
})
114-
}
115-
return cy.getByTestID('flux-editor').within(() => {
116-
cy.get('textarea.inputarea').should(
117-
'have.value',
118-
DEFAULT_FLUX_EDITOR_TEXT
119-
)
120-
})
121-
})
122-
}
123-
124100
before(() => {
125101
cy.flush()
126102
cy.signin()
127103
cy.setFeatureFlags({
128104
newDataExplorer: true,
129-
schemaComposition: false,
130105
saveAsScript: true,
131106
enableFluxInScriptBuilder: true,
132107
})
133108
cy.get('@org').then(({id}: Organization) => {
134109
cy.visit(`/orgs/${id}/data-explorer`)
135110
cy.getByTestID('tree-nav').should('be.visible')
136-
cy.isIoxOrg().then(isIox => {
137-
if (!isIox) {
138-
cy.getByTestID('script-query-builder-toggle').then($toggle => {
139-
cy.wrap($toggle).should('be.visible')
140-
// Switch to Script Editor if not yet
141-
if ($toggle.hasClass('active')) {
142-
// active means showing the old Data Explorer
143-
// hasClass is a jQuery function
144-
$toggle.click()
145-
cy.getByTestID('script-query-builder--menu').contains(
146-
'New Script'
147-
)
148-
}
149-
})
150-
}
151-
})
152-
return setScriptToFlux()
111+
cy.switchToDataExplorer('new')
112+
cy.setScriptToFlux()
153113
})
154114
})
155115

cypress/e2e/shared/explorerVisualizations.test.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,33 @@ const VIS_TYPES = [
1818
const NUM_POINTS = 360
1919

2020
describe('visualizations', () => {
21-
beforeEach(() => {
21+
before(() => {
2222
cy.flush().then(() =>
23-
cy.signin().then(() =>
23+
cy.signin().then(() => {
24+
cy.get('@org').then(({id}: Organization) => {
25+
cy.createMapVariable(id)
26+
})
27+
cy.writeData(points(NUM_POINTS))
28+
})
29+
)
30+
})
31+
32+
beforeEach(() => {
33+
cy.mockIsCloud2Org().then(() =>
34+
cy.signinWithoutUserReprovision().then(() =>
2435
cy
2536
.setFeatureFlags({
26-
showOldDataExplorerInNewIOx: true,
37+
newDataExplorer: true,
2738
showVariablesInNewIOx: true,
2839
})
2940
.then(() => {
3041
cy.get('@org').then(({id}: Organization) => {
31-
cy.createMapVariable(id)
3242
cy.fixture('routes').then(({orgs, explorer}) => {
3343
cy.visit(`${orgs}/${id}${explorer}`)
44+
cy.getByTestID('tree-nav').should('be.visible')
45+
cy.switchToDataExplorer('old')
3446
})
3547
})
36-
cy.writeData(points(NUM_POINTS))
3748
cy.getByTestID('time-machine--bottom')
3849
})
3950
)
@@ -85,7 +96,10 @@ describe('visualizations', () => {
8596

8697
cy.log('can revert back to query builder mode (with confirmation)')
8798
cy.getByTestID('switch-to-script-editor').should('be.visible').click()
99+
100+
cy.getByTestID('flux-toolbar-search--input').click().type('bottom')
88101
cy.getByTestID('flux--bottom--inject').click()
102+
cy.getByTestID('flux-toolbar-search--input').clear()
89103

90104
cy.log('check to see if new flux function is at the bottom')
91105
cy.get('.view-line').last().prev().contains('bottom')

cypress/e2e/shared/loadDataSources.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ describe('Load Data Sources', () => {
1414
cy.signin()
1515
cy.setFeatureFlags({
1616
newDataExplorer: true,
17-
showOldDataExplorerInNewIOx: true,
1817
})
1918
cy.get('@org').then(({id}: Organization) =>
2019
cy.fixture('routes').then(({orgs}) => {
@@ -175,8 +174,6 @@ describe('Load Data Sources', () => {
175174
// use new data explorer, since old data explorer is being deprecated
176175
cy.getByTestID('nav-item-data-explorer').click({force: true})
177176

178-
cy.getByTestID('script-query-builder-toggle').click()
179-
180177
cy.getByTestID('timerange-dropdown').click()
181178

182179
// time range start

0 commit comments

Comments
 (0)