-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Time out loading embed html for migration video, stub in e2e tes…
…ts (#22165)
- Loading branch information
1 parent
9505edd
commit 474f026
Showing
3 changed files
with
114 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/data-context/test/unit/sources/MigrationDataSource.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { expect } from 'chai' | ||
import dedent from 'dedent' | ||
import sinon from 'sinon' | ||
|
||
import { DataContext } from '../../../src' | ||
import { MigrationDataSource } from '../../../src/sources' | ||
import { createTestDataContext } from '../helper' | ||
|
||
const pkg = require('@packages/root') | ||
|
||
describe('MigrationDataSource', () => { | ||
context('.migration', () => { | ||
let ctx: DataContext | ||
let fetchStub: sinon.SinonStub | ||
|
||
beforeEach(() => { | ||
ctx = createTestDataContext('open') | ||
|
||
ctx.coreData.currentTestingType = 'e2e' | ||
|
||
fetchStub = sinon.stub() | ||
|
||
sinon.stub(ctx.util, 'fetch').callsFake(fetchStub) | ||
}) | ||
|
||
afterEach(() => { | ||
fetchStub.reset() | ||
sinon.restore() | ||
}) | ||
|
||
describe('getVideoEmbedHtml', () => { | ||
const expectedPayload = { | ||
videoHtml: dedent` | ||
<iframe | ||
src="https://player.vimeo.com/video/668764401?h=0cbc785eef" | ||
class="rounded h-full bg-gray-1000 w-full" | ||
frameborder="0" | ||
allow="autoplay; fullscreen; picture-in-picture" | ||
allowfullscreen | ||
/> | ||
`, | ||
} | ||
|
||
it('loads the video embed html', async () => { | ||
fetchStub | ||
.withArgs(`https://on.cypress.io/v10-video-embed/${pkg.version}`) | ||
.resolves({ | ||
json: sinon.stub().resolves(expectedPayload), | ||
}) | ||
|
||
const migrationDataSource = new MigrationDataSource(ctx) | ||
|
||
const videoEmbedHtml = await migrationDataSource.getVideoEmbedHtml() | ||
|
||
expect(videoEmbedHtml).to.eql(expectedPayload.videoHtml) | ||
}) | ||
|
||
it('gracefully returns null when request fails', async () => { | ||
const jsonStub = sinon.fake(async () => { | ||
throw new Event('abort') | ||
}) | ||
|
||
fetchStub | ||
.withArgs(`https://on.cypress.io/v10-video-embed/${pkg.version}`) | ||
.resolves({ | ||
json: jsonStub, | ||
}) | ||
|
||
const migrationDataSource = new MigrationDataSource(ctx) | ||
|
||
const videoEmbedHtml = await migrationDataSource.getVideoEmbedHtml() | ||
|
||
expect(videoEmbedHtml).to.eql(null) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
474f026
There was a problem hiding this comment.
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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
474f026
There was a problem hiding this comment.
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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
474f026
There was a problem hiding this comment.
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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: