Skip to content

Commit 7e0f015

Browse files
authored
feat: shared bucket context (#4393)
1 parent d2ee4de commit 7e0f015

File tree

19 files changed

+1086
-316
lines changed

19 files changed

+1086
-316
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const parse = () => {}
2+
3+
export const format_from_js_file = () => ''

cypress/e2e/shared/flows.test.ts

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ describe('Flows', () => {
1515
})
1616

1717
it('CRUD a flow from the index page', () => {
18+
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
19+
1820
const now = Date.now()
1921
cy.writeData(
2022
[
@@ -34,7 +36,10 @@ describe('Flows', () => {
3436
cy.getByTestID('page-title')
3537
.first()
3638
.click()
37-
cy.getByTestID('renamable-page-title--input').type('My Flow {enter}')
39+
cy.getByTestID('renamable-page-title--input')
40+
.clear()
41+
.type('My Flow {enter}')
42+
cy.wait('@updateNotebook')
3843

3944
// "Add Another Panel" menu is present and there is a Query Builder button
4045
cy.get('.insert-cell-menu.always-on').contains('Add Another Panel')
@@ -73,6 +78,8 @@ describe('Flows', () => {
7378
})
7479

7580
it('can execute preview, see results, change tags, execute preview, see different results', () => {
81+
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
82+
7683
const newBucketName = 'lets goooo'
7784
const now = Date.now()
7885
cy.get<Organization>('@org').then(({id, name}: Organization) => {
@@ -96,7 +103,10 @@ describe('Flows', () => {
96103
cy.getByTestID('page-title')
97104
.first()
98105
.click()
99-
cy.getByTestID('renamable-page-title--input').type('My Flow {enter}')
106+
cy.getByTestID('renamable-page-title--input')
107+
.clear()
108+
.type('My Flow {enter}')
109+
cy.wait('@updateNotebook')
100110

101111
// "Add Another Panel" menu is present and there is a Query Builder button
102112
cy.get('.insert-cell-menu.always-on').contains('Add Another Panel')
@@ -197,7 +207,9 @@ describe('Flows', () => {
197207
.first()
198208
.click()
199209

200-
cy.getByTestID('renamable-page-title--input').type(`${flowName}{enter}`)
210+
cy.getByTestID('renamable-page-title--input')
211+
.clear()
212+
.type(`${flowName}{enter}`)
201213
cy.wait('@updateNotebook')
202214

203215
cy.getByTestID('page-title').contains(flowName)
@@ -264,13 +276,20 @@ describe('Flows', () => {
264276
cy.getByTestID('autorefresh-dropdown--button').should('not.exist')
265277

266278
cy.clickNavBarItem('nav-item-flows')
279+
cy.get('@org').then(({id}: Organization) =>
280+
cy.fixture('routes').then(({orgs}) => {
281+
cy.location('pathname').should('eq', `${orgs}/${id}/notebooks`)
282+
})
283+
)
267284

268285
cy.get('.cf-resource-card').should('have.length', 1)
269286

270287
cy.getByTestID('resource-editable-name').contains(`${flowName}`)
271288
})
272289

273290
it('should have the same number of flow panels and no presentation panel when presentation mode is off', () => {
291+
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
292+
274293
const newBucketName = 'shmucket'
275294
const now = Date.now()
276295
cy.get<Organization>('@org').then(({id, name}: Organization) => {
@@ -296,7 +315,10 @@ describe('Flows', () => {
296315
cy.getByTestID('page-title')
297316
.first()
298317
.click()
299-
cy.getByTestID('renamable-page-title--input').type(`${flowName}`)
318+
cy.getByTestID('renamable-page-title--input')
319+
.clear()
320+
.type(`${flowName}{enter}`)
321+
cy.wait('@updateNotebook')
300322

301323
// "Add Another Panel" menu is present and there is a Query Builder button
302324
cy.get('.insert-cell-menu.always-on').contains('Add Another Panel')
@@ -370,6 +392,8 @@ describe('Flows', () => {
370392
})
371393

372394
it('should have a presentation panel and no flow panels when presentation mode is on', () => {
395+
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
396+
373397
const newBucketName = 'shmucket'
374398
const now = Date.now()
375399
cy.get<Organization>('@org').then(({id, name}: Organization) => {
@@ -395,7 +419,10 @@ describe('Flows', () => {
395419
cy.getByTestID('page-title')
396420
.first()
397421
.click()
398-
cy.getByTestID('renamable-page-title--input').type(`${flowName}`)
422+
cy.getByTestID('renamable-page-title--input')
423+
.clear()
424+
.type(`${flowName}{enter}`)
425+
cy.wait('@updateNotebook')
399426

400427
// "Add Another Panel" menu is present and there is a Query Builder button
401428
cy.get('.insert-cell-menu.always-on').contains('Add Another Panel')
@@ -524,7 +551,6 @@ describe('Flows', () => {
524551
]
525552

526553
// Intercepts
527-
cy.intercept('/api/v2/buckets?*').as('fetchAllBuckets')
528554
cy.intercept('/api/v2/orgs/*/secrets').as('fetchSecrets')
529555

530556
items.forEach(item => {
@@ -541,9 +567,7 @@ describe('Flows', () => {
541567
cy.getByTestID(`add-flow-btn--${item.panel}`)
542568
.last()
543569
.click()
544-
if (item.panel === 'queryBuilder') {
545-
cy.wait('@fetchAllBuckets')
546-
} else if (item.panel === 'notification') {
570+
if (item.panel === 'notification') {
547571
cy.wait('@fetchSecrets')
548572
}
549573
})
@@ -564,6 +588,8 @@ describe('Flows', () => {
564588
})
565589

566590
it('can create a Band plot without crashing', () => {
591+
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
592+
567593
const newBucketName = 'lets goooo'
568594
const now = Date.now()
569595
cy.get<Organization>('@org').then(({id, name}: Organization) => {
@@ -590,6 +616,7 @@ describe('Flows', () => {
590616
cy.getByTestID('renamable-page-title--input').type(
591617
'I am not afraid of Band Plot {enter}'
592618
)
619+
cy.wait('@updateNotebook')
593620

594621
// select our bucket
595622
cy.getByTestID('bucket-selector').within(() => {

jestSetup.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@ jest.mock('src/languageSupport/languages/flux/parser', () => ({
3737
format_from_js_file: jest.fn(),
3838
}))
3939

40+
class Worker {
41+
public url = ''
42+
43+
constructor(stringUrl) {
44+
this.url = stringUrl
45+
}
46+
47+
onmessage(_) {}
48+
onerror(_) {}
49+
50+
postMessage(_) {}
51+
52+
terminate() {}
53+
addEventListener(_, __, ___) {}
54+
removeEventListener(_, __, ___) {}
55+
dispatchEvent(_): boolean {
56+
return false
57+
}
58+
}
59+
60+
window.Worker = Worker
61+
4062
// cleans up state between @testing-library/react tests
4163
afterEach(() => {
4264
window.localStorage.clear()

src/flows/context/bucket.scoped.tsx

Lines changed: 0 additions & 156 deletions
This file was deleted.

0 commit comments

Comments
 (0)