-
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: Detect user-configured browsers (#23446)
* fix: Detect user-configured browsers * move user browser lookup into BrowserDataSource * refactor out common browser dedupe logic * simplify allBrowsers * resolve non-machine browsers * pr feedback * added tests * fix test * longer timeout Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com> Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com> Co-authored-by: Zachary Williams <ZachJW34@gmail.com>
- Loading branch information
1 parent
63b1a95
commit a75d3ec
Showing
9 changed files
with
163 additions
and
22 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
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
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
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
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,19 @@ | ||
import { FoundBrowser } from "@packages/types"; | ||
|
||
export const foundBrowserChrome: FoundBrowser = { | ||
name: 'chrome', | ||
family: 'chromium', | ||
channel: 'stable', | ||
displayName: 'Chrome', | ||
path: '/usr/bin/chrome', | ||
version: '100.0.0' | ||
} as const | ||
|
||
export const userBrowser: Cypress.Browser = { | ||
...foundBrowserChrome, | ||
name: 'User Custom Chromium Build', | ||
isHeaded: true, | ||
isHeadless: false, | ||
family: 'chromium', | ||
majorVersion: '100', | ||
} |
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
76 changes: 76 additions & 0 deletions
76
packages/data-context/test/unit/sources/BrowserDataSource.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,76 @@ | ||
import chai from 'chai' | ||
import sinon from 'sinon' | ||
import sinonChai from 'sinon-chai' | ||
import { FullConfig } from '@packages/types' | ||
import { createTestDataContext } from '../helper' | ||
import { userBrowser, foundBrowserChrome } from '../../fixtures/browsers' | ||
|
||
chai.use(sinonChai) | ||
const { expect } = chai | ||
|
||
describe('BrowserDataSource', () => { | ||
describe('#allBrowsers', () => { | ||
it('returns machine browser if no user custom browsers resolved in config', async () => { | ||
const fullConfig: FullConfig = { | ||
resolved: {}, | ||
browsers: [], | ||
} | ||
|
||
const ctx = createTestDataContext('run') | ||
|
||
sinon.stub(ctx.lifecycleManager, 'getFullInitialConfig').resolves(fullConfig) | ||
ctx.coreData.machineBrowsers = Promise.resolve([foundBrowserChrome]) | ||
|
||
const result = await ctx.browser.allBrowsers() | ||
|
||
expect(result).to.eql([foundBrowserChrome]) | ||
}) | ||
|
||
it('populates coreData.allBrowsers is not populated', async () => { | ||
const fullConfig: FullConfig = { | ||
resolved: {}, | ||
browsers: [userBrowser], | ||
} | ||
|
||
const ctx = createTestDataContext('run') | ||
|
||
sinon.stub(ctx.lifecycleManager, 'getFullInitialConfig').resolves(fullConfig) | ||
ctx.coreData.machineBrowsers = Promise.resolve([foundBrowserChrome]) | ||
|
||
const result = await ctx.browser.allBrowsers() | ||
|
||
expect(result.length).to.eq(2) | ||
expect(result[1].custom).to.be.true | ||
}) | ||
|
||
it('does not add user custom browser if name and version matchnes a machine browser', async () => { | ||
const browser = { ...userBrowser, name: 'aaa', version: '100' } | ||
const machineBrowser = { ...foundBrowserChrome, name: 'aaa', version: '100' } | ||
|
||
const fullConfig: FullConfig = { | ||
resolved: {}, | ||
browsers: [browser], | ||
} | ||
|
||
const ctx = createTestDataContext('run') | ||
|
||
sinon.stub(ctx.lifecycleManager, 'getFullInitialConfig').resolves(fullConfig) | ||
ctx.coreData.machineBrowsers = Promise.resolve([machineBrowser]) | ||
|
||
const result = await ctx.browser.allBrowsers() | ||
|
||
expect(result).to.eql([machineBrowser]) | ||
}) | ||
|
||
it('returns coreData.allBrowsers if populated', async () => { | ||
const allBrowsers = [foundBrowserChrome] | ||
const ctx = createTestDataContext('run') | ||
|
||
ctx.coreData.allBrowsers = Promise.resolve(allBrowsers) | ||
|
||
const result = await ctx.browser.allBrowsers() | ||
|
||
expect(result).to.eql(allBrowsers) | ||
}) | ||
}) | ||
}) |
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
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
a75d3ec
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:
a75d3ec
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 arm64
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:
a75d3ec
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 arm64
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:
a75d3ec
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:
a75d3ec
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:
a75d3ec
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:
a75d3ec
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: