Skip to content

Commit 600c1ce

Browse files
authored
fix(6609): deflake scripts crud test, by making scripts fixture via network calls durign setup (#6611)
1 parent eeceab6 commit 600c1ce

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

cypress/e2e/cloud/scriptQueryBuilder.scriptsCrud.test.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,20 @@ describe('Script Builder -- scripts crud on cloud', () => {
6767

6868
before(() => {
6969
cy.scriptsLoginWithFlags({}).then(() => {
70-
cy.switchToDataExplorer('new')
71-
cy.getByTestID('flux-editor', {timeout: DELAY_FOR_LAZY_LOAD_EDITOR})
72-
cy.clearFluxScriptSession()
73-
saveScript(
74-
`from(bucket: "defbuck") |> range(start: v.timeRangeStart, stop: v.timeRangeStop)`,
75-
scriptName
70+
cy.createScript(
71+
scriptName,
72+
`from(bucket: "defbuck") |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
73+
|> yield(name: "${scriptName}")`
7674
)
77-
cy.clearFluxScriptSession()
78-
cy.wait(DELAY_FOR_UPDATE)
79-
saveScript(
80-
`from(bucket: "defbuck") |> range(start: v.timeRangeStart, stop: v.timeRangeStop)`,
81-
anotherScriptName
75+
cy.createScript(
76+
anotherScriptName,
77+
`from(bucket: "defbuck") |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
78+
|> yield(name: "${anotherScriptName}")`
8279
)
83-
cy.clearFluxScriptSession()
84-
cy.wait(DELAY_FOR_UPDATE)
85-
saveScript(
86-
`from(bucket: "defbuck") |> range(start: v.timeRangeStart, stop: v.timeRangeStop)`,
87-
scriptToDelete
80+
cy.createScript(
81+
scriptToDelete,
82+
`from(bucket: "defbuck") |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
83+
|> yield(name: "${scriptToDelete}")`
8884
)
8985
})
9086
})
@@ -97,8 +93,7 @@ describe('Script Builder -- scripts crud on cloud', () => {
9793
})
9894
})
9995

100-
// Flaky test https://github.com/influxdata/ui/issues/6609
101-
it.skip('can search existing scripts, and open new one', () => {
96+
it('can search existing scripts, and open new one', () => {
10297
cy.getByTestID('script-query-builder--open-script')
10398
.should('be.visible')
10499
.click()

cypress/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import {
6565
selectScriptMeasurement,
6666
selectScriptFieldOrTag,
6767
scriptsLoginWithFlags,
68+
createScript,
6869
} from './support/commands'
6970

7071
declare global {
@@ -137,6 +138,7 @@ declare global {
137138
selectScriptMeasurement: typeof selectScriptMeasurement
138139
selectScriptFieldOrTag: typeof selectScriptFieldOrTag
139140
scriptsLoginWithFlags: typeof scriptsLoginWithFlags
141+
createScript: typeof createScript
140142
}
141143
}
142144
}

cypress/support/commands.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,19 @@ export const switchToDataExplorer = (typ: 'new' | 'old') => {
923923
})
924924
}
925925

926+
export const createScript = (
927+
name: string,
928+
script: string,
929+
language = 'flux'
930+
): Cypress.Chainable<Cypress.Response<any>> => {
931+
return cy.request('POST', '/api/v2/scripts', {
932+
description: 'words',
933+
name,
934+
script,
935+
language,
936+
})
937+
}
938+
926939
export const scriptsLoginWithFlags = (flags): Cypress.Chainable<any> => {
927940
return cy.signinWithoutUserReprovision().then(() => {
928941
return cy.get('@org').then(({id}: Organization) => {
@@ -1563,6 +1576,7 @@ Cypress.Commands.add('selectScriptBucket', selectScriptBucket)
15631576
Cypress.Commands.add('selectScriptMeasurement', selectScriptMeasurement)
15641577
Cypress.Commands.add('selectScriptFieldOrTag', selectScriptFieldOrTag)
15651578
Cypress.Commands.add('scriptsLoginWithFlags', scriptsLoginWithFlags)
1579+
Cypress.Commands.add('createScript', createScript)
15661580

15671581
// variables
15681582
Cypress.Commands.add('createQueryVariable', createQueryVariable)

0 commit comments

Comments
 (0)