Skip to content

Commit ed60f63

Browse files
committed
fix(browsers): ensuring acknowledgement is only necessary for browserstack
- short and quick selenium runs can send all xhr requests before the acknowledger can get lined up to listen for them. This was the case with jquery-mousewheel, which has been added in the tests.
1 parent e52e26f commit ed60f63

File tree

7 files changed

+67
-23
lines changed

7 files changed

+67
-23
lines changed
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: jQuery Mousewheel
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
env:
10+
NODE_VERSION: 22.x
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ubuntu-latest
15+
name: Test jQuery Mousewheel Integration
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
with:
20+
submodules: recursive
21+
22+
- name: Use Node.js ${{ env.NODE_VERSION }}
23+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
27+
- name: Cache
28+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
29+
with:
30+
path: ~/.npm
31+
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
32+
restore-keys: |
33+
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-
34+
35+
- name: Install dependencies
36+
run: npm install
37+
38+
- name: Run jQuery Mousewheel tests
39+
working-directory: test/jquery-mousewheel
40+
run: npm it

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "test/jquery-ui"]
88
path = test/jquery-ui
99
url = [email protected]:jquery/jquery-ui.git
10+
[submodule "test/jquery-mousewheel"]
11+
path = test/jquery-mousewheel
12+
url = [email protected]:jquery/jquery-mousewheel.git

browsers.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ export async function createBrowserWorker( url, browser, options, restarts = 0 )
103103
worker.browser = browser;
104104
worker.restarts = restarts;
105105
worker.options = options;
106-
touchBrowser( browser );
107106
workers[ fullBrowser ] = worker;
108107

109-
// Wait for the worker to show up in the list
110-
// before returning it.
111-
return ensureAcknowledged( worker );
108+
// Wait for at least one response
109+
// from the worker before continuing
110+
await ensureAcknowledged( worker );
111+
return worker;
112112
}
113113

114114
export function touchBrowser( browser ) {

createTestServer.js

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export async function createTestServer( {
159159
".txt": "text/plain",
160160
".log": "text/plain"
161161
};
162+
162163
use( async( req, res, next ) => {
163164

164165
// Allow serving anything but node_modules,

run.js

+13-17
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ export async function run( {
8080
quiet: true, // Quiet server logs during test runs
8181
testUrls,
8282
report: async( message ) => {
83+
const reportId = message.id;
84+
const report = reports[ reportId ];
85+
8386
switch ( message.type ) {
87+
case "ack":
88+
touchBrowser( report.browser );
89+
break;
8490
case "testEnd": {
85-
const reportId = message.id;
86-
const report = reports[ reportId ];
8791
touchBrowser( report.browser );
8892
const errorMessage = reportTest( message.data, report );
8993
pendingErrors[ reportId ] ??= Object.create( null );
@@ -107,17 +111,13 @@ export async function run( {
107111
break;
108112
}
109113
case "error": {
110-
const reportId = message.id;
111-
const report = reports[ reportId ];
112114
touchBrowser( report.browser );
113115
const errorMessage = reportError( message.data );
114116
pendingErrors[ reportId ] ??= Object.create( null );
115117
pendingErrors[ reportId ][ message.data.message ] = errorMessage;
116118
break;
117119
}
118120
case "runEnd": {
119-
const reportId = message.id;
120-
const report = reports[ reportId ];
121121
touchBrowser( report.browser );
122122
const { failed, total } = reportEnd( message.data, reports[ reportId ] );
123123
report.total = total;
@@ -144,11 +144,6 @@ export async function run( {
144144
// Run the next test
145145
return getNextBrowserTest( reportId );
146146
}
147-
case "ack": {
148-
const report = reports[ message.id ];
149-
touchBrowser( report.browser );
150-
break;
151-
}
152147
default:
153148
console.warn( "Received unknown message type:", message.type );
154149
}
@@ -340,16 +335,16 @@ export async function run( {
340335
}
341336
} finally {
342337
console.log();
343-
if ( errorMessages.length === 0 ) {
338+
const numErrors = errorMessages.length;
339+
if ( numErrors === 0 ) {
344340
let stop = false;
345341
for ( const report of Object.values( reports ) ) {
346342
if ( !report.total ) {
347343
stop = true;
348344
console.error(
349345
chalk.red(
350-
`No tests were run with URL "${ report.url }" in ${
351-
report.fullBrowser
352-
} (${ report.id })`
346+
`No tests were run with URL "${ report.url }" ` +
347+
`in ${ report.fullBrowser } (${ report.id })`
353348
)
354349
);
355350
}
@@ -363,8 +358,9 @@ export async function run( {
363358
gracefulExit( 0 );
364359
}
365360
} else {
366-
const len = errorMessages.length;
367-
console.error( chalk.red( `${ len } test${ len > 1 ? "s" : "" } failed.` ) );
361+
console.error(
362+
chalk.red( `${ numErrors } test${ numErrors > 1 ? "s" : "" } failed.` )
363+
);
368364
console.log(
369365
errorMessages.map( ( error, i ) => `\n${ i + 1 }. ${ error }` ).join( "\n" )
370366
);

selenium/createDriver.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ export default async function createDriver( { browserName, headless, url, verbos
8888
// Increase script timeout to 10min
8989
await driver.manage().setTimeouts( { script: DRIVER_SCRIPT_TIMEOUT } );
9090

91-
// Set the first URL for the browser
92-
await driver.get( url );
91+
// Set the first URL for the browser,
92+
// but don't wait for the page to load
93+
// so the worker is set up in time
94+
// for the ack request.
95+
driver.get( url );
9396

9497
return driver;
9598
}

test/jquery-mousewheel

Submodule jquery-mousewheel added at 8ee3ae1

0 commit comments

Comments
 (0)