Skip to content

Commit 3e54bc0

Browse files
authored
Merge pull request #54 from lightpanda-io/integration_github
add github integration test
2 parents 7037c8c + 39e0f46 commit 3e54bc0

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

integration/github.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2023-2025 Lightpanda (Selecy SAS)
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
'use scrict'
15+
16+
import puppeteer from 'puppeteer-core';
17+
18+
const browserAddress = process.env.BROWSER_ADDRESS ? process.env.BROWSER_ADDRESS : 'ws://127.0.0.1:9222';
19+
const baseURL = process.env.URL ? process.env.URL : 'http://127.0.0.1:1234'
20+
21+
// use browserWSEndpoint to pass the Lightpanda's CDP server address.
22+
const browser = await puppeteer.connect({
23+
browserWSEndpoint: browserAddress,
24+
});
25+
26+
// The rest of your script remains the same.
27+
const context = await browser.createBrowserContext();
28+
const page = await context.newPage();
29+
30+
await page.goto('https://github.com/lightpanda-io/browser', {waitUtil: 'networkidle0'});
31+
32+
await page.waitForFunction(() => {
33+
return document.getElementById('folders-and-files') != null;
34+
}, {timeout: 1000});
35+
36+
const files = await page.evaluate(() => {
37+
return Array.from(document.querySelectorAll('[id^="folder-row"] div.react-directory-filename-cell')).map(row => {
38+
return row.textContent;
39+
});
40+
});
41+
42+
await page.close();
43+
await context.close();
44+
await browser.disconnect();
45+
console.log(files);
46+
47+
for (expected of ['.github', 'src', 'build.zig', 'README.md', '.gitignore', 'LICENSING.md']) {
48+
if (!files.includes(expected)) {
49+
console.log(`Failed to find expected ${expected} entry in: `, files);
50+
}
51+
}

integration/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer) error {
9999
for _, t := range []Test{
100100
{Bin: "node", Args: []string{"integration/duckduckgo.js"}},
101101
{Bin: "node", Args: []string{"integration/algolia.js"}},
102+
{Bin: "node", Args: []string{"integration/github.js"}},
102103
} {
103104
if *verbose {
104105
t.Stderr = stderr

0 commit comments

Comments
 (0)