Repository navigation
test: Add a browser contract test service that uses the HTTP SSE client #360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
651ba8b
test: Add a browser contract test service that uses the HTTP SSE client
joker23 acaf479
test: fixing test entity to match browser sdk behavior when dealing w…
joker23 1928277
refactor: Select the HTTP SSE client with useHttpStreamingOnWeb
joker23 7ba19ca
fix: Keep the browser contract test adapter alive on bad input and cl…
joker23 b15b019
chore: Remove the adapter unit test from the browser contract test se…
joker23 ef9d9ff
fix: Report the browser contract test adapter as not ready after Chro…
joker23 90b83c1
refactor: Select the HTTP SSE client in the browser contract service …
joker23 ceb7512
fix: Use serviceEndpoints from the harness in the browser contract te…
joker23 0793d1a
test: Suppress the tags tests that expect version-only application in…
joker23 69cc986
fix: Honor the event flush interval in the browser contract service
joker23 d3abe27
chore: add more suppressions
joker23 44f46bc
chore: Use slash tags for the browser contract test jobs
joker23 11a7cf0
test: Enable diagnostics in the browser contract service only when th…
joker23 3cf5c33
chore: Pin the harness version and branch for the browser FDv1 contra…
joker23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| Contract test service that runs the Flutter SDK in a browser. | ||
|
|
||
| The SDK streams with the HTTP-based SSE client (`eventSource: SSEClient.http`), | ||
| not with the browser native `EventSource`. The native client cannot send a request | ||
| body or report an HTTP error. So this service is the only contract test run | ||
| that covers `usePost` and HTTP error handling for streaming on web. | ||
|
|
||
| # How it works | ||
|
|
||
| The contract test harness speaks REST. A browser cannot listen for HTTP | ||
| requests. So the service has two parts: | ||
|
|
||
| - `bin/adapter.dart` runs on the Dart VM. It serves the REST API for the | ||
| harness, serves the web build, starts headless Chrome, and relays each | ||
| request to the browser over a websocket. | ||
| - `lib/main.dart` is a Flutter web app. It runs in the browser, connects to | ||
| the adapter, and runs each request with the SDK. | ||
|
|
||
| The browser tells the adapter which capabilities it has when it connects. | ||
| `client-use-post` and `client-event-source-http-errors` need the HTTP-based | ||
| SSE client. | ||
|
|
||
| # Running it | ||
|
|
||
| You need Chrome. The `--chrome` option sets the path to Chrome. Without the | ||
| option, the adapter uses the `CHROME_EXECUTABLE` variable. Otherwise it uses | ||
| the Chrome app on macOS, and `google-chrome` from your `PATH` on other | ||
| platforms. | ||
|
|
||
| ``` | ||
| $ cd apps/flutter_web_contract_test_service/ | ||
| $ flutter build web --release --base-href /app/ -t lib/main.dart | ||
| $ dart run bin/adapter.dart | ||
| Adapter listening on port 8080 | ||
| Browser connected | ||
| ``` | ||
|
|
||
| Leave the adapter running, and run the | ||
| [sdk-test-harness](https://github.com/launchdarkly/sdk-test-harness) in a | ||
| second terminal: | ||
|
|
||
| ``` | ||
| $ cd apps/flutter_web_contract_test_service/ | ||
| $ curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/main/downloader/run.sh \ | ||
| | VERSION=v2 PARAMS="-url http://localhost:8080 -debug -status-timeout 100 -stop-service-at-end -skip-from testharness-suppressions.txt" sh | ||
| ``` | ||
|
|
||
| This runs the FDv1 tests. To run the FDv2 tests, use `v3` in the URL, set | ||
| `VERSION=v3`, and skip from `testharness-suppressions-fdv2.txt`. The | ||
| `-stop-service-at-end` option stops the adapter when the harness finishes, so | ||
| start the adapter again before the next run. | ||
|
|
||
| From the repository root, `melos run client-web-contract-tests` (FDv1) and | ||
| `melos run client-web-contract-tests-fdv2` (FDv2) build the web app, start the | ||
| adapter, and run the harness. | ||
|
|
||
| `testharness-suppressions.txt` (FDv1) and `testharness-suppressions-fdv2.txt` | ||
| (FDv2) list the harness tests that this service skips. They start from the | ||
| lists of the JS browser SDK runs that use the fetch-based event source, and | ||
| each file states where it differs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include: ../../common_analysis.yaml |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.