Files
cypress/packages/server/test/unit/browsers/webkit_spec.ts
T
Ryan Manuel 0daf7e639f chore: support studio lifecycle in protocol (#31239)
* update url with studio params

* updates

* spec updates

* adding tests

* updating changelog

* skip adding visit log during start

* update url support

* cy origin tests

* fix tests

* updates

* update origin test

* chore: support studio lifecycle in protocol

* merge changes

* fix types

* fix tests

* fix tests

* fix tests

* fix more tests

* fix more tests

* fix more tests

* fix test

* fix bugs

* fix tests

* attempt to fix test

* further fixes

* improve cloud studio enablement

* refactoring

* remove new dom link

* fix last test

* Update packages/app/cypress/e2e/studio/studio.cy.ts

* Update packages/server/lib/project-base.ts

* Update packages/proxy/lib/http/request-middleware.ts

Co-authored-by: Matt Schile <mschile@cypress.io>

* PR comments

* fix build

* fix build

* update

* Update packages/server/lib/project-base.ts

Co-authored-by: Matt Schile <mschile@cypress.io>

* fix unit test

* rework save logic

---------

Co-authored-by: Matthew Schile <mschile@cypress.io>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
2025-03-13 20:30:29 -05:00

89 lines
2.5 KiB
TypeScript

import { proxyquire } from '../../spec_helper'
import { expect } from 'chai'
import utils from '../../../lib/browsers/utils'
import * as plugins from '../../../lib/plugins'
function getWebkit (dependencies = {}) {
return proxyquire('../lib/browsers/webkit', dependencies) as typeof import('../../../lib/browsers/webkit')
}
describe('lib/browsers/webkit', () => {
context('#open', () => {
let browser
let options
let automation
let webkit
beforeEach(async () => {
browser = {}
options = { experimentalWebKitSupport: true }
automation = { use: sinon.stub() }
const launchOptions = {
extensions: [],
args: [],
preferences: { },
}
const pwWebkit = {
webkit: {
connect: sinon.stub().resolves({
on: sinon.stub(),
}),
launchServer: sinon.stub().resolves({
wsEndpoint: sinon.stub().returns('ws://debugger'),
process: sinon.stub().returns({ pid: 'pid' }),
}),
},
}
const wkAutomation = {
WebKitAutomation: {
create: sinon.stub().resolves({}),
},
}
sinon.stub(utils, 'executeBeforeBrowserLaunch').resolves(launchOptions as any)
sinon.stub(plugins, 'execute').resolves()
sinon.stub(plugins, 'has')
webkit = getWebkit({
'playwright-webkit': pwWebkit,
'./webkit-automation': wkAutomation,
})
})
it('sends after:browser:launch with debugger url', async () => {
(plugins.has as any).returns(true)
await webkit.open(browser as any, 'http://the.url', options as any, automation as any)
expect(plugins.execute).to.be.calledWith('after:browser:launch', browser, {
webSocketDebuggerUrl: 'ws://debugger',
})
})
it('executeAfterBrowserLaunch is noop if after:browser:launch is not registered', async () => {
(plugins.has as any).returns(false)
await webkit.open(browser as any, 'http://the.url', options as any, automation as any)
expect(plugins.execute).not.to.be.calledWith('after:browser:launch')
})
})
context('#connectProtocolToBrowser', () => {
it('throws error', () => {
const webkit = getWebkit()
expect(webkit.connectProtocolToBrowser).to.throw('Protocol is not yet supported in WebKit.')
})
})
context('#closeProtocolConnection', () => {
it('throws error', async () => {
const webkit = getWebkit()
expect(webkit.closeProtocolConnection).to.throw('Protocol is not yet supported in WebKit.')
})
})
})