Skip to content

Commit 0dcde88

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 0dcde88

File tree

7 files changed

+67
-21
lines changed

7 files changed

+67
-21
lines changed
Lines changed: 40 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "test/jquery-ui"]
88
path = test/jquery-ui
99
url = git@github.com:jquery/jquery-ui.git
10+
[submodule "test/jquery-mousewheel"]
11+
path = test/jquery-mousewheel
12+
url = git@github.com:jquery/jquery-mousewheel.git

browsers.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,16 @@ export async function createBrowserWorker( url, browser, options, restarts = 0 )
103103
worker.browser = browser;
104104
worker.restarts = restarts;
105105
worker.options = options;
106-
touchBrowser( browser );
106+
107107
workers[ fullBrowser ] = worker;
108+
touchBrowser( browser );
108109

109-
// Wait for the worker to show up in the list
110-
// before returning it.
111-
return ensureAcknowledged( worker );
110+
// Wait for at least one response
111+
// from the worker before continuing
112+
if ( browserstack ) {
113+
await ensureAcknowledged( worker );
114+
}
115+
return worker;
112116
}
113117

114118
export function touchBrowser( browser ) {

createTestServer.js

Lines changed: 1 addition & 0 deletions
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

Lines changed: 13 additions & 17 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default async function createDriver( { browserName, headless, url, verbos
2323

2424
const chromeOptions = new Chrome.Options();
2525
chromeOptions.addArguments( "--enable-chrome-browser-cloud-management" );
26+
chromeOptions.addArguments( "--no-sandbox" );
2627

2728
// Alter the chrome binary path if
2829
// the CHROME_BIN environment variable is set

test/jquery-mousewheel

Submodule jquery-mousewheel added at 8ee3ae1

0 commit comments

Comments
 (0)