Skip to content

Commit

Permalink
chore: better test getVideoEmbedHtml code in e2e test (#27667)
Browse files Browse the repository at this point in the history
  • Loading branch information
AtofStryker authored Aug 25, 2023
1 parent 9a5a899 commit f3f7aaa
Showing 1 changed file with 79 additions and 23 deletions.
102 changes: 79 additions & 23 deletions packages/launchpad/cypress/e2e/migration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1734,45 +1734,103 @@ describe('Migrate custom config files', () => {
})

describe('v13 migration welcome page with video', () => {
function stubVideoHtml (): void {
it('Welcome page should appear if video is not present (failure)', () => {
cy.withCtx((ctx, o) => {
const originalGetVideoEmbedHtml = ctx.migration.getVideoEmbedHtml

o.sinon.stub(ctx.migration, 'getVideoEmbedHtml').callsFake(async () => {
return '<span>Stubbed Video Content</span>'
const mockMigrationSourceGetVideoEmbedHtmlCTX = {
ctx: {
coreData: {
migration: {
videoEmbedHtml: undefined,
},
},
versions: {
versionData: () => {
return {
current: {
version: '13.0.0',
},
}
},
},
util: {
fetch: () => {
throw new Error('kaboom')
},
},
},
}

return originalGetVideoEmbedHtml.apply(mockMigrationSourceGetVideoEmbedHtmlCTX)
})
})
}

function unstubVideoHtml (): void {
cy.withCtx((ctx, o) => {
const restoreFn = (ctx.migration.getVideoEmbedHtml as SinonStub).restore

restoreFn?.()
})
}
cy.scaffoldProject('migration-v12-to-v13')
cy.openProject('migration-v12-to-v13')

beforeEach(() => {
stubVideoHtml()
cy.visitLaunchpad()
cy.contains(cy.i18n.majorVersionWelcome.title).should('be.visible')
cy.get('[data-cy="video-container"]').should('not.exist')
})

it('Welcome page should appear if video is not present', () => {
unstubVideoHtml()

cy.scaffoldProject('migration-v12-to-v13')
cy.openProject('migration-v12-to-v13')
it('Welcome page should appear if video is not present (timeout)', () => {
cy.withCtx((ctx, o) => {
const originalGetVideoEmbedHtml = ctx.migration.getVideoEmbedHtml

o.sinon.stub(ctx.migration, 'getVideoEmbedHtml').callsFake(async () => {
return null
const mockMigrationSourceGetVideoEmbedHtmlCTX = {
ctx: {
coreData: {
migration: {
videoEmbedHtml: undefined,
},
},
versions: {
versionData: () => {
return {
current: {
version: '13.0.0',
},
}
},
},
util: {
fetch: () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
// the request should time out before this body is returned
resolve({
json () {
return {
videoHtml: '<span>Stubbed Video Content</span>',
}
},
})
}, 4000)
})
},
},
},
}

return originalGetVideoEmbedHtml.apply(mockMigrationSourceGetVideoEmbedHtmlCTX)
})
})

cy.scaffoldProject('migration-v12-to-v13')
cy.openProject('migration-v12-to-v13')

cy.visitLaunchpad()
cy.contains(cy.i18n.majorVersionWelcome.title).should('be.visible')
cy.contains(cy.i18n.majorVersionWelcome.title, {
timeout: 8000,
}).should('be.visible')

cy.get('[data-cy="video-container"]').should('not.exist')
})

it('Welcome page should appear if video is present', () => {
unstubVideoHtml()

cy.scaffoldProject('migration-v12-to-v13')
cy.openProject('migration-v12-to-v13')

Expand All @@ -1782,8 +1840,6 @@ describe('v13 migration welcome page with video', () => {
})

it('should only hit the video on link once & cache it', () => {
unstubVideoHtml()

cy.scaffoldProject('migration-v12-to-v13')
cy.openProject('migration-v12-to-v13')

Expand Down

5 comments on commit f3f7aaa

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f3f7aaa Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.0.0/darwin-arm64/release/13.0.0-f3f7aaaa40633efcd35c16926cb26e7d97dd4996/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f3f7aaa Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.0.0/linux-x64/release/13.0.0-f3f7aaaa40633efcd35c16926cb26e7d97dd4996/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f3f7aaa Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.0.0/darwin-x64/release/13.0.0-f3f7aaaa40633efcd35c16926cb26e7d97dd4996/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f3f7aaa Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.0.0/linux-arm64/release/13.0.0-f3f7aaaa40633efcd35c16926cb26e7d97dd4996/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f3f7aaa Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.0.0/win32-x64/release/13.0.0-f3f7aaaa40633efcd35c16926cb26e7d97dd4996/cypress.tgz

Please sign in to comment.