Skip to content

Commit 3f8339d

Browse files
authored
Switch browser integration tests from jest-puppeteer to Playwright (#2920)
The graphql-ws tests didn't even use a browser, so those just drop the preset and run as plain Jest. Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
1 parent 1f9c66a commit 3f8339d

11 files changed

Lines changed: 1531 additions & 19820 deletions

File tree

.github/workflows/it.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ jobs:
6969
- run: sh vertx-web-graphql/start-graphiql-tests-server.sh
7070
- run: npm install
7171
working-directory: vertx-web-graphql/tests/graphiql
72+
- name: Install Playwright browser
73+
run: npx playwright install --with-deps chromium
74+
working-directory: vertx-web-graphql/tests/graphiql
7275
- run: npm run test
7376
working-directory: vertx-web-graphql/tests/graphiql
7477
- uses: actions/upload-artifact@v4
@@ -102,6 +105,9 @@ jobs:
102105
- run: sh vertx-web/start-sockjs-write-handler-tests-server.sh
103106
- run: npm install
104107
working-directory: vertx-web/tests/sockjs
108+
- name: Install Playwright browser
109+
run: npx playwright install --with-deps chromium
110+
working-directory: vertx-web/tests/sockjs
105111
- run: npm run test
106112
working-directory: vertx-web/tests/sockjs
107113
- uses: actions/upload-artifact@v4
Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
1-
const GRAPHIQL_URL = 'http://localhost:8080/graphiql/?query=' + encodeURIComponent('{ hello }')
1+
import { test, expect } from '@playwright/test'
22

3-
// Monaco editor renders non-breaking spaces (U+00A0) instead of regular spaces
4-
function normalizeSpaces(text) {
5-
return text.replace(/ /g, ' ')
6-
}
3+
test('execute query and verify response', async ({ page }) => {
4+
await page.goto('/graphiql/?query=' + encodeURIComponent('{ hello }'), { waitUntil: 'networkidle' })
5+
await page.waitForSelector('.graphiql-container', { timeout: 10000 })
76

8-
test('execute query and verify response', async () => {
9-
await page.goto(GRAPHIQL_URL, {waitUntil: 'networkidle0'})
10-
await page.waitForSelector('.graphiql-container', {timeout: 10000})
7+
await page.locator('.graphiql-execute-button').click()
118

12-
const executeButton = await page.waitForSelector('.graphiql-execute-button', {timeout: 5000})
13-
await executeButton.click()
14-
15-
const deadline = Date.now() + 10000
16-
let content = ''
17-
while (Date.now() < deadline) {
18-
content = normalizeSpaces(await page.evaluate(() => {
19-
const el = document.querySelector('.graphiql-response')
20-
return el ? el.textContent : ''
21-
}))
22-
if (content.includes('Hello World!')) break
23-
await new Promise(r => setTimeout(r, 500))
24-
}
25-
26-
expect(content).toContain('"hello"')
27-
expect(content).toContain('Hello World!')
28-
}, 30000)
9+
await expect(page.locator('.graphiql-response')).toContainText('"hello"')
10+
await expect(page.locator('.graphiql-response')).toContainText('Hello World!')
11+
})

0 commit comments

Comments
 (0)