Skip to content

Commit 7ab52d8

Browse files
authored
fix: intercept the correct api calls and other minor fixes for pinned notebooks tests (#4272)
1 parent df24966 commit 7ab52d8

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

cypress/e2e/cloud/pinned.test.ts

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ from(bucket: "${name}"{rightarrow}
211211
cy.setFeatureFlags({
212212
pinnedItems: true,
213213
})
214-
cy.intercept('GET', '**/notebooks').as('getNotebooks')
215-
cy.getByTestID('nav-item-flows').should('be.visible')
216-
cy.clickNavBarItem('nav-item-flows')
214+
cy.intercept('GET', '/api/v2private/notebooks*').as('getNotebooks')
215+
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
216+
217217
const now = Date.now()
218218
cy.writeData(
219219
[
@@ -224,21 +224,24 @@ from(bucket: "${name}"{rightarrow}
224224
],
225225
'defbuck'
226226
)
227+
cy.getByTestID('nav-item-flows').should('be.visible')
228+
cy.clickNavBarItem('nav-item-flows')
229+
cy.wait('@getNotebooks')
230+
227231
cy.getByTestID('preset-new')
228232
.first()
229233
.click()
234+
cy.wait('@getNotebooks')
235+
cy.wait('@updateNotebook')
230236

231237
cy.getByTestID('page-title')
232238
.first()
233239
.click()
234-
cy.intercept('GET', '**/notebooks').as('getNotebooks')
235-
cy.intercept('PATCH', '**/notebooks/*').as('updateNotebook')
236240
cy.getByTestID('renamable-page-title--input')
237241
.clear()
238-
.type('Flow')
239-
.type('{enter}')
240-
242+
.type('Flow{enter}')
241243
cy.wait('@updateNotebook')
244+
242245
cy.getByTestID('time-machine-submit-button')
243246
.should('be.visible')
244247
.and('be.disabled')
@@ -253,7 +256,6 @@ from(bucket: "${name}"{rightarrow}
253256
.last()
254257
.click()
255258
})
256-
cy.wait('@updateNotebook')
257259
cy.visit(`/orgs/${orgID}/notebooks`)
258260
cy.wait('@getNotebooks')
259261
})
@@ -263,6 +265,7 @@ from(bucket: "${name}"{rightarrow}
263265
cy.getByTestID('context-menu-flow').click()
264266
})
265267
cy.getByTestID('context-pin-flow').click()
268+
cy.getByTestID('notification-success').should('be.visible')
266269

267270
cy.visit('/')
268271
cy.getByTestID('tree-nav')
@@ -276,7 +279,11 @@ from(bucket: "${name}"{rightarrow}
276279
cy.getByTestID('context-menu-flow').click()
277280
})
278281
cy.getByTestID('context-pin-flow').click()
279-
cy.getByTestID('notification-success--children').should('exist')
282+
cy.getByTestID('notification-success').should('be.visible')
283+
cy.getByTestID('notification-success--dismiss').click()
284+
285+
cy.intercept('PUT', '**/pinned/*').as('updatePinned')
286+
const updatedName = 'Bucks in Six'
280287

281288
cy.getByTestID('resource-editable-name')
282289
.first()
@@ -285,43 +292,35 @@ from(bucket: "${name}"{rightarrow}
285292
cy.getByTestID('flow-card--name-button')
286293
.first()
287294
.click()
288-
cy.intercept('PUT', '**/pinned/*').as('updatePinned')
289295

290296
cy.get('.cf-input-field')
291297
.last()
292-
.focus()
293-
.type('Bucks In Six')
294-
.type('{enter}')
295-
cy.getByTestID('notification-success--children').should('exist')
298+
.type(`${updatedName}{enter}`)
299+
300+
cy.getByTestID('notification-success').should('be.visible')
296301
cy.wait('@updatePinned')
297302
cy.wait('@updateNotebook')
298303
cy.visit('/')
299304
cy.getByTestID('tree-nav')
300305
cy.getByTestID('pinneditems--container').within(() => {
301-
cy.getByTestID('pinneditems--link').should(
302-
'contain.text',
303-
'Bucks In Six'
304-
)
306+
cy.getByTestID('pinneditems--link').should('contain.text', updatedName)
305307
})
306308
})
307309

308310
it('unpins when the resource it is pointing to is deleted', () => {
309-
cy.getByTestID('resource-editable-name')
310-
.first()
311-
.trigger('mouseover')
312-
313-
cy.getByTestID('flow-card--name-button')
314-
.first()
315-
.click()
316-
317311
cy.getByTestID('flow-card--Flow').within(() => {
318312
cy.getByTestID('context-menu-flow').click()
319313
})
320314
cy.getByTestID('context-pin-flow').click()
315+
cy.getByTestID('notification-success').should('be.visible')
316+
cy.getByTestID('notification-success--dismiss').click()
317+
321318
cy.getByTestID('flow-card--Flow').within(() => {
322319
cy.getByTestID(`context-delete-menu--button`).click()
323320
})
324321
cy.getByTestID(`context-delete-menu--confirm-button`).click()
322+
cy.getByTestID('notification-success').should('be.visible')
323+
325324
cy.visit('/')
326325
cy.getByTestID('tree-nav')
327326
cy.getByTestID('pinneditems--emptystate').should(

0 commit comments

Comments
 (0)