mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-27 02:14:36 -05:00
1f28650d68
* hacky way to update snapshots * new hack to update snapshots * trying again * hacky fix * ci: snapshots * ci: snapshots * snapshots * mas updates * update spec API * fix test * fix test * update * update test * fix test * update plugin * update spec * webpack optinos * Update launchpad tests * fix screenshot paths * updated snapshot * change pattern * guard * fix smoke test * patch code coverage * update percy config * fix specs * try updating example project * update snapshots * remove old test * remove snapshot hack * add back appveyor * remove old code * update snapshot * Fix tests * wip * revert snapshot * reverted all snaps * remove only * remove commnet * remove old code * reverted file * lint * revert video compression spec * update snapshot * update spec path logic * update snap * updated snap * snaps * snaps * fix spec * rename ignoreTestFiles to ignoreSpecPattern * update screenshot dir for runner-ct * update deprecations * update * upate * fix test * update snaps * update snap * updating snap * added missing snaps * updated cypress run mode integration spec * electron snapshot * update default * rename integration->e2e * rename integration->e2e in packages * spec.ts -> cy.ts * spec.ts -> cy.ts * _spec.js -> .cy.js * .spec.js -> .cy.js * .spec.js -> .cy.js * update config * update config * update * update spec ext * update config * update config * ensure newly scaffold specs are cached * fix launchpad spec * types * update test * transpile based on spec pattern * add back example * remove unnecessary async and nodeVersion * spec.tsx -> cy.tsx * update stop-only config * exclude CT from E2E * removed old test * update spec pattern in angular * update spec pattern in design system * update all specs npm npm/react * update spec name * update spec patterns * remove old script * update tests path * update config * fix test * update snapshots * update examples * update ignore patterns * update snapshots * unit tests * update tests * patch code coverage * revert spec name * rename a lot of speces * update * update spec ext * update spec * update spec * update spec ext * update lint * update rules * update lint * snaps * update spec dir * update paths * remove unused pluginsfile config opt * update smoke test * update create cypress tests * update gitignore * update types * update paths * update spe * update test * update all snaps * update tests * update http request spec * update spec file names * snaps * update snaps * updated snaps * update snaps * spacing * spacing * spacing * spacing * fix perf spec * update * update * revert * update * snaps * snaps * rename spec * update snaps * snapshots * update tests * update tests * update * fix * update test projects * update * updating * update run-ct test * update spec pattern and add defensive check around platform * fix system test script * update snap * snaps * update test * update spe * update for FF * ff * remove unused feature flag * added tests * fix react example * update test * update config * update test projects * update snapshots * correctly remove private prefix on darwin * fix types * rename integration -> e2e * update config * updatec onfig * fixing app scaffold integration tests * remove code * exclude e2e specs from CT * update snapshot * integration->e2e * update path for test file in ts project * update schematic * use updated branch for CI * update config * update config * revert some changes * remove built code * revert changes * update gitignore * include test spec * update scaffold script * wip: renames * script * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * mass rename * rename * rename * fix angular * update spec in create cypress tests * remove old file * fix tests * access specPattern in a more idiomatic fashion * do not duplicate variable * pass correct params to findSpec in files controller * add comment explaining spec finding * remove reference to old file that no longer exist * resolve conflicts * fix types * transpile cypress dir * update circle ymlg * update spec pattern for example project * supportFile: false * fix circle yml * update test glob * rename some specs to use correct .cy ext * more ext renames * rename spec * update extensions * update extensions * update specs Co-authored-by: estrada9166 <estrada9166@hotmail.com> Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
98 lines
3.6 KiB
JavaScript
98 lines
3.6 KiB
JavaScript
// ffprobe is necessary to extract chapters data from mp4 files.
|
|
// ffprobe is usually installed with ffmpeg.
|
|
// But in our CI, it doesn't. That's why we're installing ffprobe here.
|
|
const ffprobePath = require('@ffprobe-installer/ffprobe').path
|
|
const ffmpeg = require('fluent-ffmpeg')
|
|
|
|
ffmpeg.setFfprobePath(ffprobePath)
|
|
|
|
const path = require('path')
|
|
const fs = require('fs-extra')
|
|
const humanInterval = require('human-interval')
|
|
const systemTests = require('../lib/system-tests').default
|
|
const glob = require('@packages/server/lib/util/glob')
|
|
const videoCapture = require('@packages/server/lib/video_capture')
|
|
const Fixtures = require('../lib/fixtures')
|
|
|
|
const NUM_TESTS = 40
|
|
const MS_PER_TEST = 500
|
|
const EXPECTED_DURATION_MS = NUM_TESTS * MS_PER_TEST
|
|
|
|
// ffmpeg command that extracts the final frame as a jpg
|
|
function outputFinalFrameAsJpg (inputFile, outputFile) {
|
|
return new Promise((resolve, reject) => {
|
|
return ffmpeg(inputFile)
|
|
.inputOption('-sseof -3')
|
|
.outputOptions(['-vsync 2', '-update 1'])
|
|
.on('end', resolve)
|
|
.on('error', reject)
|
|
.save(outputFile)
|
|
})
|
|
}
|
|
|
|
describe('e2e video compression', () => {
|
|
systemTests.setup()
|
|
|
|
return [
|
|
true,
|
|
false,
|
|
].forEach((headed) => {
|
|
systemTests.it(`passes (head${headed ? 'ed' : 'less'})`, {
|
|
// videos are corrupted in firefox due to known issues
|
|
browser: '!firefox',
|
|
spec: 'video_compression.cy.js',
|
|
snapshot: false,
|
|
headed,
|
|
config: {
|
|
env: {
|
|
NUM_TESTS,
|
|
MS_PER_TEST,
|
|
},
|
|
},
|
|
async onRun (exec) {
|
|
process.env.VIDEO_COMPRESSION_THROTTLE = 10
|
|
|
|
const { stdout } = await exec()
|
|
const videosPath = Fixtures.projectPath('e2e/cypress/videos/*')
|
|
const files = await glob(videosPath)
|
|
|
|
expect(files).to.have.length(1, `globbed for videos and found: ${files.length}. Expected to find 1 video. Search in videosPath: ${videosPath}.`)
|
|
|
|
const lastFrameFile = path.join(path.dirname(files[0]), 'lastFrame.jpg')
|
|
|
|
await outputFinalFrameAsJpg(files[0], lastFrameFile)
|
|
// https://github.com/cypress-io/cypress/issues/9265
|
|
// if video is seekable and not just one frozen frame, this file should exist
|
|
await fs.stat(lastFrameFile).catch((err) => {
|
|
throw new Error(`Expected video to have seekable ending frame, but it did not. The video may be corrupted.`)
|
|
})
|
|
|
|
const { duration } = await videoCapture.getCodecData(files[0])
|
|
const durationMs = videoCapture.getMsFromDuration(duration)
|
|
|
|
expect(durationMs).to.be.ok
|
|
expect(durationMs).to.be.closeTo(EXPECTED_DURATION_MS, humanInterval('15 seconds'))
|
|
|
|
const { chapters } = await videoCapture.getChapters(files[0])
|
|
|
|
// There are 40 chapters but we test only the first one
|
|
// because what we want to check is if chapters are added properly.
|
|
// In a chapter object, there are properties like 'end' and 'end_time'.
|
|
// We don't check them here because they return the test time in milliseconds.
|
|
// They cannot be guessed correctly and they can cause flakiness.
|
|
expect(chapters[0].id).to.eq(0)
|
|
expect(chapters[0].start).to.eq(0)
|
|
expect(chapters[0].start_time).to.eq(0)
|
|
expect(chapters[0]['TAG:title']).to.eq('num: 1 makes some long tests')
|
|
expect(chapters[0].time_base).to.eq('1/1000')
|
|
expect(chapters[0].end).to.be.a('number')
|
|
expect(Number.isNaN(chapters[0].end)).to.be.false
|
|
expect(chapters[0].end_time).to.be.a('number')
|
|
expect(Number.isNaN(chapters[0].end_time)).to.be.false
|
|
|
|
expect(stdout).to.match(/Compression progress:\s+\d{1,3}%/)
|
|
},
|
|
})
|
|
})
|
|
})
|