You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR will:
- add contract test implementation to Electron
- add contract test runs into electron GHA workflow
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Medium risk due to new CI jobs and scheduled runs that spin up
Electron/Xvfb and execute the shared contract-test harness, which can
introduce flakiness and longer runtimes. Changes are mostly test-only
but add new dependencies and AWS-secret retrieval for e2e example runs.
>
> **Overview**
> Adds **Electron SDK contract testing** by introducing a new
`packages/sdk/electron/contract-tests/entity` Electron app that exposes
the SDK test-harness REST protocol (create client, run commands, delete
client, shutdown) and maps harness config into `LDOptions` (endpoints,
events, TLS, hooks, etc.).
>
> Updates the Electron GitHub Actions workflow to run nightly, build and
launch the contract-test entity headlessly via Xvfb/Playwright, wait for
port `8000`, and then run the `launchdarkly/gh-actions` contract tests
(with `suppressions.txt`). Also adds a new `run-example` CI job that
builds the Electron example and runs Playwright e2e using AWS-sourced
test keys.
>
> Extends the Electron example with a Playwright-based smoke test, adds
`build`/`test` scripts and Playwright deps, and tweaks `.gitignore` to
capture `test-results/`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
814d2b5. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: semgrep-code-launchdarkly[bot] <167133144+semgrep-code-launchdarkly[bot]@users.noreply.github.com>
This directory contains the contract test implementation for the LaunchDarkly Electron SDK using the [SDK Test Harness](https://github.com/launchdarkly/sdk-test-harness).
4
+
5
+
## Architecture
6
+
7
+
The Electron contract tests use a single component:
8
+
9
+
**Entity** (`entity/`): An Electron application that:
10
+
11
+
- Runs an Express server in the **main process** on port 8000
12
+
- Exposes a REST API that the test harness calls directly (no separate adapter)
13
+
- Creates and manages Electron SDK clients via `ClientFactory` in response to harness commands
14
+
- Implements the contract test protocol: create client (POST /), run commands (POST /clients/:id), delete client (DELETE /clients/:id), shutdown (DELETE /)
15
+
16
+
The test harness sends HTTP requests to the entity’s REST API. The entity runs the Electron SDK in the main process and responds with evaluation results and other command outputs.
17
+
18
+
## Running Locally
19
+
20
+
### Prerequisites
21
+
22
+
- Node.js 18 or later
23
+
- Yarn
24
+
- Electron-supported platform (macOS, Windows, or Linux). For headless/CI, a virtual display (e.g. xvfb on Linux) may be required.
25
+
26
+
### Quick start
27
+
28
+
1.**Install dependencies** from the repository root:
29
+
```bash
30
+
yarn
31
+
```
32
+
33
+
2.**Build the entity** so the Electron app has a built main process. From the repository root:
34
+
```bash
35
+
yarn workspaces foreach -pR --topological-dev --from @internal/electron-contract-tests-entity run build
36
+
```
37
+
38
+
3.**Start the contract test entity** (the Electron app with the REST server on port 8000). From the repository root:
39
+
```bash
40
+
yarn workspace @internal/electron-contract-tests-entity run start
41
+
```
42
+
Or from `entity/`:
43
+
```bash
44
+
yarn start
45
+
```
46
+
The app window may open; the server runs in the main process. Keep it running while you run the harness.
47
+
48
+
For a headless run (e.g. CI), use the open-electron script instead:
49
+
```bash
50
+
yarn workspace @internal/electron-contract-tests-entity run open-electron
51
+
```
52
+
This launches the built app via Playwright’s Electron API and keeps it running until you press Ctrl+C.
53
+
54
+
4.**Run the SDK test harness** against the entity. The entity’s REST API is at:
55
+
-**Base URL:**http://localhost:8000
56
+
57
+
Example with a local clone of the test harness:
58
+
```bash
59
+
go run . --url http://localhost:8000
60
+
```
61
+
62
+
If you have a suppressions file (e.g. for known differences), pass it with `-skip-from`:
63
+
```bash
64
+
go run . --url http://localhost:8000 -skip-from path-to-js-core/packages/sdk/electron/contract-tests/suppressions.txt
65
+
```
66
+
67
+
More details on the harness: https://github.com/launchdarkly/sdk-test-harness
0 commit comments