Skip to content

Commit 60d4517

Browse files
authored
update tests for studio AI being unavailable (#32034)
1 parent 8ff4c7d commit 60d4517

File tree

1 file changed

+80
-1
lines changed

1 file changed

+80
-1
lines changed

packages/app/cypress/e2e/studio/studio-cloud.cy.ts

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ describe('Studio Cloud', () => {
125125
cy.percySnapshot()
126126
})
127127

128-
it('opens a cloud studio session with AI enabled', () => {
128+
// TODO: un-skip this test when we enable Studio AI
129+
it.skip('opens a cloud studio session with AI enabled', () => {
129130
cy.mockNodeCloudRequest({
130131
url: '/studio/testgen/n69px6/enabled',
131132
method: 'get',
@@ -206,6 +207,84 @@ describe('Studio Cloud', () => {
206207
cy.get('[data-cy="recommendation-editor"]').should('contain', aiOutput)
207208
})
208209

210+
it('opens a cloud studio session with AI marked as coming soon', () => {
211+
cy.mockNodeCloudRequest({
212+
url: '/studio/testgen/n69px6/enabled',
213+
method: 'get',
214+
body: { enabled: true },
215+
})
216+
217+
// this endpoint gets called twice, so we need to mock it twice
218+
cy.mockNodeCloudRequest({
219+
url: '/studio/testgen/n69px6/enabled',
220+
method: 'get',
221+
body: { enabled: true },
222+
})
223+
224+
const aiOutput = 'cy.get(\'button\').should(\'have.text\', \'Increment\')'
225+
226+
cy.mockNodeCloudStreamingRequest({
227+
url: '/studio/testgen/n69px6/generate',
228+
method: 'post',
229+
body: { recommendations: [{ content: aiOutput }] },
230+
})
231+
232+
cy.mockStudioFullSnapshot({
233+
fullSnapshot: {
234+
id: 1,
235+
nodeType: 1,
236+
nodeName: 'div',
237+
localName: 'div',
238+
nodeValue: 'div',
239+
children: [],
240+
shadowRoots: [],
241+
},
242+
url: 'http://localhost:3000/cypress/e2e/index.html',
243+
})
244+
245+
const deferred = pDefer()
246+
247+
loadProjectAndRunSpec({ enableCloudStudio: true })
248+
249+
cy.findByTestId('studio-panel').should('not.exist')
250+
251+
cy.intercept('/cypress/e2e/index.html', () => {
252+
// wait for the promise to resolve before responding
253+
// this will ensure the studio panel is loaded before the test finishes
254+
return deferred.promise
255+
}).as('indexHtml')
256+
257+
cy.contains('visits a basic html page')
258+
.closest('.runnable-wrapper')
259+
.findByTestId('launch-studio')
260+
.click()
261+
262+
// regular studio is not loaded until after the test finishes
263+
cy.get('[data-cy="hook-name-studio commands"]').should('not.exist')
264+
// cloud studio is loaded immediately
265+
cy.findByTestId('studio-panel').then(() => {
266+
// check for the loading panel from the app first
267+
cy.get('[data-cy="loading-studio-panel"]').should('be.visible')
268+
// we've verified the studio panel is loaded, now resolve the promise so the test can finish
269+
deferred.resolve()
270+
})
271+
272+
cy.wait('@indexHtml')
273+
274+
// Studio re-executes spec before waiting for commands - wait for the spec to finish executing.
275+
cy.waitForSpecToFinish()
276+
277+
// Verify the studio panel is still open
278+
cy.findByTestId('studio-panel')
279+
cy.get('[data-cy="hook-name-studio commands"]')
280+
281+
// make sure studio is not loading
282+
cy.get('[data-cy="loading-studio-panel"]').should('not.exist')
283+
284+
// Verify that AI is coming soon
285+
cy.get('[data-cy="ai-status-text"]').should('contain.text', 'Coming soon')
286+
})
287+
209288
it('does not exit studio mode if the spec is changed on the file system', () => {
210289
launchStudio({ enableCloudStudio: true })
211290

0 commit comments

Comments
 (0)