Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(webkit): add video recording #23579

Merged
merged 32 commits into from
Sep 6, 2022
Merged

chore(webkit): add video recording #23579

merged 32 commits into from
Sep 6, 2022

Conversation

flotwig
Copy link
Contributor

@flotwig flotwig commented Aug 27, 2022

User facing changelog

n/a

Additional details

  • Moves browser-specific video recording logic out of run.ts and in to the browsers/* drivers.
    • This happened in e3b1979
    • Browsers now control the video recording more closely, and only expose a small API to run.ts (start/end/restart control)
  • Adds WebKit video recording.
    • This necessitated the above refactor - WebKit only supports recording an entire Page session at a time, and it streams to disk, so we can't use the ffmpeg method we regularly use with WK.
  • Adds a webkit-system-tests job. 60 .its are skipped in this PR since they don't work yet. It breaks down like this:
    • 6 skipped due to needing multidomain support
    • 8 skipped due to missing before:browser:launch support
    • 22 skipped due to broken stack traces
    • 24 other
  • But importantly for this PR, the video_compression system-test spec is unskipped and passing in WebKit
  • Depends on refactor: move more of video capture into browser automations #23587

Steps to test

Run a test project that records video in WebKit, for example:

yarn cypress:run --project ../cypress-test-tiny --browser webkit --config video=true

(the project needs to have playwright-webkit installed)

Video should be recorded to the videosFolder after doing this. No guarantee that the project won't fail for other reasons since WebKit is WIP.

How has the user experience changed?

PR Tasks

  • Have tests been added/updated?
  • [na] Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 27, 2022

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Aug 27, 2022



Test summary

39674 0 3345 0Flakiness 3


Run details

Project cypress
Status Passed
Commit edff645
Started Sep 6, 2022 4:48 PM
Ended Sep 6, 2022 5:03 PM
Duration 15:04 💡
OS Linux Debian - 11.3
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

angular.cy.ts Flakiness
1 Working with angular-14 > should mount a passing test
e2e/origin/events.cy.ts Flakiness
1 cy.origin > window:before:load event
2 cy.origin > post window load events > window:unload

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@flotwig flotwig force-pushed the webkit-video branch 3 times, most recently from 0375b0a to 7886a3d Compare August 27, 2022 16:53
Base automatically changed from browser-types to develop August 29, 2022 19:47
@flotwig flotwig changed the base branch from develop to refactor-defaultBrowserOpts August 30, 2022 01:01
@flotwig flotwig mentioned this pull request Aug 30, 2022
21 tasks
@flotwig flotwig requested a review from tbiethman August 31, 2022 15:40
@@ -1024,7 +1024,6 @@ describe('lib/cypress', () => {
browser: 'electron',
foo: 'bar',
onNewWindow: sinon.match.func,
writeVideoFrame: sinon.match.func,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this unit assertion since it's complex to mock now and is covered by other Electron tests that record video.

@flotwig flotwig requested a review from BlueWinds August 31, 2022 17:52
@flotwig flotwig marked this pull request as ready for review August 31, 2022 18:29
Comment on lines +16 to +19
export type VideoRecording = {
api: RunModeVideoApi
controller?: BrowserVideoController
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm super open to input on these APIs, especially around naming and structure. I know it's currently not the smoothest experience. They're structured the way they are to avoid a complete refactor of this part of run.ts, where two complex, asynchronous code paths that are interdependent require different parts of the BrowserVideoController at different times:

const [results] = await Promise.all([
waitForTestsToFinishRunning({
spec,
config,
project,
estimated,
screenshots,
videoRecording,
exit: options.exit,
testingType: options.testingType,
videoCompression: options.videoCompression,
videoUploadOnPasses: options.videoUploadOnPasses,
quiet: options.quiet,
shouldKeepTabOpen: !isLastSpec,
}),
waitForBrowserToConnect({
spec,
project,
browser,
screenshots,
onError,
videoRecording,
socketId: options.socketId,
webSecurity: options.webSecurity,
projectRoot: options.projectRoot,
testingType: options.testingType,
isFirstSpec,
experimentalSingleTabRunMode: config.experimentalSingleTabRunMode,
shouldLaunchNewTab: !isFirstSpec,
}),
])

Base automatically changed from refactor-defaultBrowserOpts to develop August 31, 2022 18:55
@weyert
Copy link

weyert commented Aug 31, 2022

Nice, great job, that’s a nice approach to add video capturing for Webkit :)

@rachelruderman
Copy link
Contributor

@flotwig can you update the PR description with Steps to Test? 🙏

@flotwig
Copy link
Contributor Author

flotwig commented Sep 1, 2022

can you update the PR description with Steps to Test? pray

@rachelruderman done

Copy link
Contributor

@rachelruderman rachelruderman left a comment

Choose a reason for hiding this comment

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

Tried and tested!! Great job!!

@lmiller1990
Copy link
Contributor

I did not review this one yet (was not assigned, but can take a look this week) - but I did test it out as part of #23662 and the recording feature is working as expected, at least based on a few tests. I did not do more in depth testing yet.

Should we be able to see recordings in the dashboard from WK with this PR @flotwig? My understanding is WK is only installed during local dev, so I guess not?

@@ -529,7 +536,7 @@ export async function open (browser: Browser, url: string, options: BrowserLaunc
// user can overwrite this default with these env vars or --height, --width arguments
MOZ_HEADLESS_WIDTH: '1280',
MOZ_HEADLESS_HEIGHT: '721',
}) as LaunchedBrowser & { browserCriClient: BrowserCriClient}
}) as unknown as BrowserInstance
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't seen this before, tricky.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah... I don't know the "right" way to change the type of an object, type-safely, without using class ... extends .... If there even is a way without as unknown. Would be nice to eventually remove the need for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

This one seems a quick fix #23693

I think what you are referring to is something like

function foo<T extends SomeBaseClass>(arg: T): T {
  // 
}

Now as long as arg extends SomeBaseClass you should get type safety (error if you don't extend the base class).

@flotwig
Copy link
Contributor Author

flotwig commented Sep 6, 2022

Should we be able to see recordings in the dashboard from WK with this PR? My understanding is WK is only installed during local dev, so I guess not?

@lmiller1990 in the monorepo, it's a devDependency, we run most of our tests using the dev version of Cypress so we do have video: https://dashboard.cypress.io/projects/ypt4pf/runs/38732/test-results/abbf0e35-9475-4a03-a446-743cb06c5e22/video

@flotwig flotwig merged commit dc9e9dc into develop Sep 6, 2022
@flotwig flotwig deleted the webkit-video branch September 6, 2022 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants