Skip to content

Commit de3f076

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 9b1be94 + 35dc47d commit de3f076

File tree

1 file changed

+89
-5
lines changed

1 file changed

+89
-5
lines changed

tests/browser/scripts/README.md

Lines changed: 89 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,101 @@ _Small utilities in TypeScript._
33
See top level `/scripts` directory for Bash and Python scripts.
44
Also see `/ci` directory for yet more scripts.
55

6-
## start_browser.ts
6+
# 📘 Running the Playwright Scripts (`start_browser.ts` & `add_snyk_target.ts`)
77

8-
Starts a Chrome browser that listens on port 9222 for CDP (Chrome DevTools Protocol) connections.
9-
This can be then used to automate the browser from Playwright (in the other scripts here).
8+
This guide explains how to set up your environment and run the two TypeScript scripts located in:
109

11-
## add_snyk_target.ts
10+
`tests/browser/scripts/`
11+
- `start_browser.ts` — launches a Chrome instance with remote debugging enabled
12+
- `add_snyk_target.ts` — connects to that browser and automates Snyk actions
13+
14+
----------
15+
16+
# 1️⃣ Prerequisites
17+
18+
Install **Node.js + npm**:
19+
20+
`brew install node`
21+
22+
(Or download from [https://nodejs.org](https://nodejs.org))
23+
24+
----------
25+
26+
# 2️⃣ Install TypeScript & ts-node
27+
28+
`npm install -g typescript ts-node`
29+
30+
----------
31+
32+
# 3️⃣ Initialize the project (creates package.json **and** package-lock.json)
33+
34+
From the repo root:
35+
36+
`npm init -y`
37+
38+
This generates:
39+
40+
- `package.json` — declares dependencies and scripts
41+
- `package-lock.json`_locks_ exact dependency versions for reproducible installs
42+
43+
----------
44+
45+
# 4️⃣ Install Playwright dependencies
46+
47+
Playwright **must** be installed locally so the scripts can import it:
48+
49+
`npm install playwright`
50+
51+
This updates:
52+
53+
- `node_modules/` with the dependency
54+
- `package.json` with `"playwright": "..."`
55+
- `package-lock.json` with the exact resolved version
56+
57+
Then install browser binaries:
58+
59+
`npx playwright install`
60+
61+
----------
62+
63+
# 5️⃣ Running the scripts
64+
65+
## 🔵 Step 1 — Start the browser
66+
67+
`npx ts-node --esm tests/browser/scripts/start_browser.ts`
68+
69+
This will:
70+
71+
- Start Chrome with debugging on port **9222**
72+
- Open a browser window
73+
- Keep the process running
74+
75+
----------
76+
77+
## 🟣 Step 2 — Run the Snyk automation script
1278

1379
_[https://redhat-internal.slack.com/archives/C06FYLF5DQ9/p1731003424810809]_
1480

1581
Adds a Snyk security scan target to [https://app.snyk.io/org/red-hat-openshift-data-science-rhods].
16-
Useful for adding Pipfiles in new release branches for dependency scanning through the Snyk UI.
82+
Useful for adding Pipfiles in new release branches for dependency scanning through the Snyk UI. (pylock.toml files are not supported by Snyk)
83+
1784
The UI allows adding only one Pipfile at a time, so this script can be used to add multiple in a loop.
1885

1986
Requires the browser server in `start_browser.ts` to be running.
87+
88+
In a new terminal:
89+
90+
`npx ts-node --esm tests/browser/scripts/add_snyk_target.ts`
91+
92+
### ⚠️ Log into Snyk
93+
94+
Use the browser window to log in:
95+
96+
[https://app.snyk.io](https://app.snyk.io)
97+
98+
This script will:
99+
100+
- Connect to the running browser
101+
- Detect a visible page
102+
- Navigate to Snyk’s Add Repository workflow
103+
- Add all configured pipfiles/targets

0 commit comments

Comments
 (0)