Skip to content

Commit 30b968b

Browse files
committed
Merge branch 'develop' of github.com:cypress-io/cypress into misc/use_webdriver
2 parents a937c50 + 619a9ab commit 30b968b

File tree

6 files changed

+190
-77
lines changed

6 files changed

+190
-77
lines changed

browser-versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"chrome:beta": "130.0.6723.19",
3-
"chrome:stable": "129.0.6668.70",
3+
"chrome:stable": "129.0.6668.89",
44
"chrome:minimum": "64.0.3282.0"
55
}

cli/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ _Released 10/1/2024 (PENDING)_
99
- Cypress now consumes [webdriver](https://github.com/webdriverio/webdriverio/tree/main/packages/webdriver) to help automate the Firefox browser and [firefox-profile](https://github.com/saadtazi/firefox-profile-js) to create a firefox profile and convert it to Base64 to save user screen preferences via `xulstore.json`. Addresses [#30300](https://github.com/cypress-io/cypress/issues/30300) and [#30301](https://github.com/cypress-io/cypress/issues/30301).
1010
- Pass spec information to protocol's `beforeSpec` to improve troubleshooting when reporting on errors. Addressed in [#30316](https://github.com/cypress-io/cypress/pull/30316).
1111

12+
**Dependency Updates:**
13+
14+
- Updated `simple-git` from `3.16.0` to `3.25.0`. Addressed in [#30076](https://github.com/cypress-io/cypress/pull/30076).
15+
1216
## 13.15.0
1317

1418
_Released 9/25/2024_

packages/data-context/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"randomstring": "1.3.0",
5252
"react-docgen": "6.0.4",
5353
"semver": "7.3.2",
54-
"simple-git": "3.16.0",
54+
"simple-git": "3.25.0",
5555
"stringify-object": "^3.0.0",
5656
"underscore.string": "^3.3.6",
5757
"wonka": "^4.0.15"

packages/data-context/test/unit/sources/GitDataSource.spec.ts

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -216,75 +216,6 @@ describe('GitDataSource', () => {
216216
expect(errorStub).to.be.callCount(1)
217217
})
218218

219-
context('Git hashes', () => {
220-
let clock: sinon.SinonFakeTimers
221-
222-
beforeEach(() => {
223-
clock = sinon.useFakeTimers()
224-
})
225-
226-
afterEach(() => {
227-
clock.restore()
228-
})
229-
230-
it('loads git hashes when first loaded', async () => {
231-
const dfd = pDefer()
232-
233-
gitInfo = new GitDataSource({
234-
isRunMode: false,
235-
projectRoot: projectPath,
236-
onBranchChange: sinon.stub(),
237-
onGitInfoChange: sinon.stub(),
238-
onError: sinon.stub(),
239-
onGitLogChange: dfd.resolve,
240-
})
241-
242-
await dfd.promise
243-
244-
expect(gitInfo.currentHashes).to.have.length(1)
245-
246-
expect(gitInfo.currentCommitInfo).to.exist
247-
expect(gitInfo.currentCommitInfo.message).to.eql('add all specs')
248-
expect(gitInfo.currentCommitInfo.hash).to.exist
249-
})
250-
251-
it('detects change in hashes after a commit', async () => {
252-
const dfd = pDefer()
253-
const afterCommit = pDefer()
254-
255-
const logCallback = sinon.stub()
256-
257-
logCallback.onFirstCall().callsFake(dfd.resolve)
258-
logCallback.onSecondCall().callsFake(afterCommit.resolve)
259-
260-
gitInfo = new GitDataSource({
261-
isRunMode: false,
262-
projectRoot: projectPath,
263-
onBranchChange: sinon.stub(),
264-
onGitInfoChange: sinon.stub(),
265-
onError: sinon.stub(),
266-
onGitLogChange: logCallback,
267-
})
268-
269-
await dfd.promise
270-
271-
expect(gitInfo.currentHashes).to.have.length(1)
272-
273-
const afterCommitSpec = toPosix(path.join(e2eFolder, 'afterCommit.cy.js'))
274-
275-
await fs.createFile(afterCommitSpec)
276-
277-
git.add(afterCommitSpec)
278-
git.commit('add afterCommit spec')
279-
280-
await clock.tickAsync(60010)
281-
282-
await afterCommit.promise
283-
284-
expect(gitInfo.currentHashes).to.have.length(2)
285-
})
286-
})
287-
288219
context('Git Hashes - no fake timers', () => {
289220
it('does not include commits that are part of the Git tree from a merge', async () => {
290221
const dfd = pDefer()
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
import { expect, use } from 'chai'
2+
import sinonChai from 'sinon-chai'
3+
import sinon from 'sinon'
4+
import proxyquire from 'proxyquire'
5+
import pDefer, { DeferredPromise } from 'p-defer'
6+
7+
import { SimpleGit } from 'simple-git'
8+
import type { GitDataSource, GitDataSourceConfig } from '../../../src/sources/GitDataSource'
9+
import Chokidar from 'chokidar'
10+
11+
use(sinonChai)
12+
13+
type P<F extends keyof SimpleGit> = Parameters<SimpleGit[F]>
14+
type R<F extends keyof SimpleGit> = ReturnType<SimpleGit[F]>
15+
16+
interface GitDataSourceConstructor {
17+
new (config: GitDataSourceConfig): GitDataSource
18+
}
19+
20+
type GDSImport = {
21+
GitDataSource: GitDataSourceConstructor
22+
}
23+
24+
describe('GitDataSource', () => {
25+
let stubbedSimpleGit: {
26+
// Parameters<> only gets the last overload defined, which is
27+
// supposed to be the most permissive. However, SimpleGit defines
28+
// overloads in the opposite order, and we need the one that takes
29+
// a string.
30+
revparse: sinon.SinonStub<[option: string], R<'revparse'>>
31+
branch: sinon.SinonStub<P<'branch'>, R<'branch'>>
32+
status: sinon.SinonStub<P<'status'>, R<'status'>>
33+
log: sinon.SinonStub<P<'log'>, R<'log'>>
34+
}
35+
let stubbedWatchInstance: sinon.SinonStubbedInstance<Chokidar.FSWatcher>
36+
37+
let gitDataSourceImport: GDSImport
38+
let fakeTimers: sinon.SinonFakeTimers
39+
40+
beforeEach(() => {
41+
fakeTimers = sinon.useFakeTimers()
42+
stubbedSimpleGit = {
43+
revparse: sinon.stub<[option: string], R<'revparse'>>(),
44+
branch: sinon.stub<P<'branch'>, R<'branch'>>(),
45+
status: sinon.stub<P<'status'>, R<'status'>>(),
46+
log: sinon.stub<P<'log'>, R<'log'>>(),
47+
}
48+
49+
stubbedWatchInstance = sinon.createStubInstance(Chokidar.FSWatcher)
50+
sinon.stub(Chokidar, 'watch').returns(stubbedWatchInstance)
51+
52+
gitDataSourceImport = proxyquire.noCallThru()('../../../src/sources/GitDataSource', {
53+
'simple-git' () {
54+
return stubbedSimpleGit
55+
},
56+
})
57+
})
58+
59+
afterEach(() => {
60+
sinon.restore()
61+
fakeTimers.restore()
62+
})
63+
64+
describe('Unit', () => {
65+
describe('in open mode', () => {
66+
let gds: GitDataSource
67+
let projectRoot: string
68+
let branchName: string
69+
let onBranchChange: sinon.SinonStub<[branch: string | null], void>
70+
let onGitInfoChange: sinon.SinonStub<[specPath: string[]], void>
71+
let onError: sinon.SinonStub<[err: any], void>
72+
let onGitLogChange: sinon.SinonStub<[shas: string[]], void>
73+
const firstHashes = [
74+
{ hash: 'abc' },
75+
]
76+
const firstHashesReturnValue = ['abc']
77+
const secondHashes = [...firstHashes, { hash: 'efg' }]
78+
const secondHashesReturnValue = [...firstHashesReturnValue, 'efg']
79+
let firstGitLogCall: DeferredPromise<void>
80+
let secondGitLogCall: DeferredPromise<void>
81+
82+
beforeEach(async () => {
83+
firstGitLogCall = pDefer()
84+
secondGitLogCall = pDefer()
85+
branchName = 'main'
86+
onBranchChange = sinon.stub()
87+
onGitInfoChange = sinon.stub()
88+
onError = sinon.stub()
89+
onGitLogChange = sinon.stub()
90+
91+
projectRoot = '/root'
92+
93+
// @ts-ignore
94+
stubbedSimpleGit.log.onFirstCall()
95+
// @ts-expect-error
96+
.callsFake(() => {
97+
firstGitLogCall.resolve()
98+
99+
return { all: firstHashes }
100+
})
101+
.onSecondCall()
102+
// @ts-expect-error
103+
.callsFake(() => {
104+
secondGitLogCall.resolve()
105+
106+
return { all: secondHashes }
107+
})
108+
109+
// #verifyGitRepo
110+
111+
// constructor verifies the repo in open mode via #refreshAllGitData, but does not wait for it :womp:
112+
const revparseP = pDefer<void>()
113+
114+
// SimpleGit returns a chainable, but we only care about the promise
115+
// @ts-expect-error
116+
stubbedSimpleGit.revparse.callsFake(() => {
117+
revparseP.resolve()
118+
119+
return Promise.resolve(projectRoot)
120+
})
121+
122+
// wait for revparse to be called, so we can be assured that GitDataSource has initialized
123+
// up to this point
124+
125+
// #loadAndWatchCurrentBranch
126+
127+
// next in initialization, it loads the current branch
128+
const branchP = pDefer<void>()
129+
130+
// again, ignoring type warning re: chaining
131+
// @ts-expect-error
132+
stubbedSimpleGit.branch.callsFake(() => {
133+
branchP.resolve()
134+
135+
return Promise.resolve({ current: branchName })
136+
})
137+
138+
const onBranchChangeP = pDefer<void>()
139+
140+
onBranchChange.callsFake(() => onBranchChangeP.resolve())
141+
142+
gds = new gitDataSourceImport.GitDataSource({
143+
isRunMode: false,
144+
projectRoot,
145+
onBranchChange,
146+
onGitInfoChange,
147+
onError,
148+
onGitLogChange,
149+
})
150+
151+
await revparseP.promise
152+
await branchP.promise
153+
await onBranchChangeP.promise
154+
expect(onBranchChange).to.be.calledWith(branchName)
155+
})
156+
157+
describe('.get currentHashes', () => {
158+
describe('after first load', () => {
159+
beforeEach(async () => {
160+
await firstGitLogCall.promise
161+
})
162+
163+
it('returns the current hashes', () => {
164+
expect(gds.currentHashes).to.have.same.members(firstHashesReturnValue)
165+
})
166+
})
167+
168+
describe('after sixty seconds, when there are additional hashes', () => {
169+
it('returns the current hashes', async () => {
170+
await fakeTimers.tickAsync(60001)
171+
await secondGitLogCall.promise
172+
expect(gds.currentHashes).to.have.same.members(secondHashesReturnValue)
173+
})
174+
})
175+
})
176+
})
177+
})
178+
})

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13383,7 +13383,7 @@ [email protected]:
1338313383
dependencies:
1338413384
ms "^2.1.1"
1338513385

13386-
debug@4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@^4.3.6, debug@~4.3.1:
13386+
debug@4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@^4.3.5, debug@^4.3.6, debug@~4.3.1:
1338713387
version "4.3.7"
1338813388
resolved "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52"
1338913389
integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==
@@ -28069,14 +28069,14 @@ simple-get@^4.0.0:
2806928069
once "^1.3.1"
2807028070
simple-concat "^1.0.0"
2807128071

28072-
simple-git@3.16.0:
28073-
version "3.16.0"
28074-
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.16.0.tgz#421773e24680f5716999cc4a1d60127b4b6a9dec"
28075-
integrity sha512-zuWYsOLEhbJRWVxpjdiXl6eyAyGo/KzVW+KFhhw9MqEEJttcq+32jTWSGyxTdf9e/YCohxRE+9xpWFj9FdiJNw==
28072+
simple-git@3.25.0:
28073+
version "3.25.0"
28074+
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.25.0.tgz#3666e76d6831f0583dc380645945b97e0ac4aab6"
28075+
integrity sha512-KIY5sBnzc4yEcJXW7Tdv4viEz8KyG+nU0hay+DWZasvdFOYKeUZ6Xc25LUHHjw0tinPT7O1eY6pzX7pRT1K8rw==
2807628076
dependencies:
2807728077
"@kwsites/file-exists" "^1.1.1"
2807828078
"@kwsites/promise-deferred" "^1.1.1"
28079-
debug "^4.3.4"
28079+
debug "^4.3.5"
2808028080

2808128081
simple-swizzle@^0.2.2:
2808228082
version "0.2.2"

0 commit comments

Comments
 (0)