|
1 | 1 | import defaultMessages from '@packages/frontend-shared/src/locales/en-US.json' |
2 | 2 | import type { SinonStub } from 'sinon' |
3 | 3 |
|
| 4 | +function scaffoldTestingTypeAndVisitRunsPage (testingType: 'e2e' | 'component') { |
| 5 | + cy.scaffoldProject('cypress-in-cypress') |
| 6 | + cy.openProject('cypress-in-cypress') |
| 7 | + cy.startAppServer(testingType) |
| 8 | + |
| 9 | + cy.loginUser() |
| 10 | + |
| 11 | + // make sure there are no runs found for the project ID |
| 12 | + cy.remoteGraphQLIntercept(async (obj) => { |
| 13 | + if (obj.result.data?.cloudProjectBySlug) { |
| 14 | + obj.result.data.cloudProjectBySlug.runs.nodes = [] |
| 15 | + } |
| 16 | + |
| 17 | + return obj.result |
| 18 | + }) |
| 19 | + |
| 20 | + cy.visitApp() |
| 21 | + |
| 22 | + return cy.get('[href="#/runs"]').click() |
| 23 | +} |
| 24 | + |
4 | 25 | describe('App: Runs', { viewportWidth: 1200 }, () => { |
5 | 26 | context('Runs Page', () => { |
6 | 27 | beforeEach(() => { |
@@ -398,47 +419,40 @@ describe('App: Runs', { viewportWidth: 1200 }, () => { |
398 | 419 | cy.findByText(defaultMessages.runs.connect.buttonProject).should('exist') |
399 | 420 | }) |
400 | 421 |
|
401 | | - it('displays how to record prompt when connected and no runs', () => { |
402 | | - cy.scaffoldProject('component-tests') |
403 | | - cy.openProject('component-tests') |
404 | | - cy.startAppServer('component') |
405 | | - |
406 | | - cy.loginUser() |
407 | | - cy.remoteGraphQLIntercept(async (obj) => { |
408 | | - if (obj.result.data?.cloudProjectBySlug?.runs?.nodes) { |
409 | | - obj.result.data.cloudProjectBySlug.runs.nodes = [] |
410 | | - } |
| 422 | + it('displays how to record prompt when connected and no runs in Component Testing', () => { |
| 423 | + scaffoldTestingTypeAndVisitRunsPage('component') |
| 424 | + cy.contains(defaultMessages.runs.empty.title).should('be.visible') |
| 425 | + cy.contains(defaultMessages.runs.empty.description).should('be.visible') |
| 426 | + cy.contains('cypress run --component --record --key 2aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa').should('be.visible') |
| 427 | + }) |
411 | 428 |
|
412 | | - return obj.result |
413 | | - }) |
| 429 | + it('displays how to record prompt when connected and no runs in E2E', () => { |
| 430 | + scaffoldTestingTypeAndVisitRunsPage('e2e') |
414 | 431 |
|
415 | | - cy.visitApp() |
416 | | - cy.get('[href="#/runs"]').click() |
417 | | - cy.contains(defaultMessages.runs.empty.title) |
418 | | - cy.contains(defaultMessages.runs.empty.description) |
419 | | - cy.contains('--record --key 2aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa') |
| 432 | + cy.contains(defaultMessages.runs.empty.title).should('be.visible') |
| 433 | + cy.contains(defaultMessages.runs.empty.description).should('be.visible') |
| 434 | + cy.contains('cypress run --record --key 2aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa').should('be.visible') |
420 | 435 | }) |
421 | 436 |
|
422 | | - it('displays a copy button', () => { |
423 | | - cy.scaffoldProject('component-tests') |
424 | | - cy.openProject('component-tests') |
425 | | - cy.startAppServer('component') |
426 | | - |
| 437 | + it('displays a copy button and copies correct command in Component Testing', () => { |
| 438 | + scaffoldTestingTypeAndVisitRunsPage('component') |
427 | 439 | cy.withCtx(async (ctx, o) => { |
428 | 440 | o.sinon.stub(ctx.electronApi, 'copyTextToClipboard') |
429 | 441 | }) |
430 | 442 |
|
431 | | - cy.loginUser() |
432 | | - cy.remoteGraphQLIntercept(async (obj) => { |
433 | | - if (obj.result.data?.cloudProjectBySlug?.runs?.nodes) { |
434 | | - obj.result.data.cloudProjectBySlug.runs.nodes = [] |
435 | | - } |
| 443 | + cy.get('[data-cy="copy-button"]').click() |
| 444 | + cy.contains('Copied!') |
| 445 | + cy.withRetryableCtx((ctx) => { |
| 446 | + expect(ctx.electronApi.copyTextToClipboard as SinonStub).to.have.been.calledWith('cypress run --component --record --key 2aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa') |
| 447 | + }) |
| 448 | + }) |
436 | 449 |
|
437 | | - return obj.result |
| 450 | + it('displays a copy button and copies correct command in E2E', () => { |
| 451 | + scaffoldTestingTypeAndVisitRunsPage('e2e') |
| 452 | + cy.withCtx(async (ctx, o) => { |
| 453 | + o.sinon.stub(ctx.electronApi, 'copyTextToClipboard') |
438 | 454 | }) |
439 | 455 |
|
440 | | - cy.visitApp() |
441 | | - cy.get('[href="#/runs"]').click() |
442 | 456 | cy.get('[data-cy="copy-button"]').click() |
443 | 457 | cy.contains('Copied!') |
444 | 458 | cy.withRetryableCtx((ctx) => { |
|
0 commit comments