-
Notifications
You must be signed in to change notification settings - Fork 27
Use Playwright to test demos #106
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
16 commits
Select commit
Hold shift + click to select a range
b60ee3a
test: test react demo with playwright
heeckhau ebb4254
test: test react demos with playwright
heeckhau 0486d85
ci: fix
heeckhau 93175cc
ci: fix
heeckhau f489505
tests
heeckhau 8f14399
test
heeckhau 52206d0
Run tests with playwright
heeckhau aa3df48
removed old testrunner
heeckhau f1b994f
install chromium
heeckhau a76f179
ci fix
heeckhau f224543
renamed workflow
heeckhau 910c1f9
Improved readme
heeckhau 8db0c0f
feat: added readmes for tests
Codetrauma 7e4f4c9
Improved demo readmes
heeckhau 80024f3
test: Use a separate page for each test
heeckhau 7392be7
lint
heeckhau 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Tests demos | ||
on: | ||
pull_request: | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
name: Tests demos | ||
runs-on: ubuntu-latest | ||
services: | ||
notary-server: | ||
image: ghcr.io/tlsnotary/tlsn/notary-server:v0.1.0-alpha.10 | ||
env: | ||
NOTARY_SERVER__TLS__ENABLED: false | ||
ports: | ||
- 7047:7047 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
- name: build tlsn-js | ||
run: npm ci; npm run build | ||
- name: install wstcp | ||
run: cargo install wstcp | ||
- name: Install Chromium (Playwright) | ||
run: npx playwright install --with-deps chromium | ||
- name: Test react demo | ||
working-directory: demo/react-ts-webpack | ||
continue-on-error: true | ||
run: | | ||
set -e | ||
npm i | ||
npm run test | ||
- name: Test interactive verifier demo | ||
continue-on-error: true | ||
run: | | ||
set -e | ||
cd demo/interactive-demo/verifier-rs | ||
cargo build --release | ||
cd ../prover-ts | ||
npm i | ||
npm run test | ||
- name: Test web-to-web p2p demo | ||
working-directory: demo/react-ts-webpack | ||
continue-on-error: true | ||
run: | | ||
set -e | ||
npm run test | ||
- uses: actions/upload-artifact@v4 | ||
if: ${{ !cancelled() }} | ||
with: | ||
name: playwright-report | ||
path: '**/playwright-report/' | ||
retention-days: 30 |
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 |
---|---|---|
@@ -1,38 +1,59 @@ | ||
# Test Rust Prover | ||
|
||
1. Start the verifier: | ||
```bash | ||
cd verifier-rs; cargo run --release | ||
``` | ||
2. Run the prover: | ||
```bash | ||
cd prover-rs; cargo run --release | ||
``` | ||
|
||
# Test Browser Prover | ||
1. Start the verifier: | ||
```bash | ||
cd verifier-rs; cargo run --release | ||
``` | ||
2. Since a web browser doesn't have the ability to make TCP connection, we need to use a websocket proxy server to access <raw.githubusercontent.com>. | ||
```bash | ||
cargo install wstcp | ||
|
||
wstcp --bind-addr 127.0.0.1:55688 raw.githubusercontent.com:443 | ||
``` | ||
3. Run the prover | ||
1. Build tlsn-js | ||
# Interactive Verifier Demo | ||
|
||
This demo shows how to use TLSNotary **without a notary**: a direct proof between a prover and a verifier, where the verifier checks both the TLS session and the revealed data. | ||
|
||
There are two prover implementations: | ||
- **Rust** | ||
- **TypeScript** (browser) | ||
The verifier is implemented in Rust. | ||
|
||
--- | ||
|
||
## Interactive Verifier Demo with Rust Prover | ||
|
||
1. **Start the verifier:** | ||
```bash | ||
cd verifier-rs | ||
cargo run --release | ||
``` | ||
2. **Run the prover:** | ||
```bash | ||
cd prover-rs | ||
cargo run --release | ||
``` | ||
|
||
--- | ||
|
||
## Interactive Verifier Demo with TypeScript Prover (Browser) | ||
|
||
1. **Start the verifier:** | ||
```bash | ||
cd verifier-rs | ||
cargo run --release | ||
``` | ||
2. **Set up a websocket proxy for raw.githubusercontent.com** | ||
Browsers cannot make raw TCP connections, so a websocket proxy is required: | ||
```bash | ||
cargo install wstcp | ||
wstcp --bind-addr 127.0.0.1:55688 raw.githubusercontent.com:443 | ||
``` | ||
3. **Run the prover in the browser:** | ||
1. **Build tlsn-js** | ||
```bash | ||
cd .. | ||
npm i | ||
npm install | ||
npm run build | ||
npm link | ||
``` | ||
2. Build demo prover-ts | ||
2. **Build and start the TypeScript prover demo** | ||
```bash | ||
cd prover-ts | ||
npm i | ||
npm link | ||
npm install | ||
npm run dev | ||
``` | ||
3. Open <http://localhost:3456/> and click **Start Prover** | ||
3. **Open the demo in your browser:** | ||
Go to [http://localhost:8080/](http://localhost:8080/) and click **Start Prover**. | ||
|
||
--- | ||
|
||
**Tip:** | ||
If you encounter issues, make sure all dependencies are installed and the websocket proxy is running before starting the browser demo. |
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 |
---|---|---|
@@ -1 +1,8 @@ | ||
package-lock.json | ||
|
||
# Playwright | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
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,90 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// import dotenv from 'dotenv'; | ||
// import path from 'path'; | ||
// dotenv.config({ path: path.resolve(__dirname, '.env') }); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: 'http://localhost:8080', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
// { | ||
// name: 'firefox', | ||
// use: { ...devices['Desktop Firefox'] }, | ||
// }, | ||
|
||
// { | ||
// name: 'webkit', | ||
// use: { ...devices['Desktop Safari'] }, | ||
// }, | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { ...devices['Pixel 5'] }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { ...devices['iPhone 12'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
webServer: [ | ||
{ | ||
command: 'npm run start', | ||
url: 'http://localhost:8080', | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
{ | ||
command: 'wstcp --bind-addr 127.0.0.1:55688 raw.githubusercontent.com:443', | ||
reuseExistingServer: true, | ||
}, | ||
{ | ||
command: 'cargo run --release', | ||
cwd: '../verifier-rs', | ||
reuseExistingServer: true, | ||
} | ||
] | ||
}); |
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,16 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('has title', async ({ page }) => { | ||
await page.goto('/'); | ||
await expect(page).toHaveTitle(/TLSNotary/) | ||
}); | ||
|
||
test('run demo', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
// Click the get started link. | ||
await page.getByRole('button', { name: 'Start Prover' }).click(); | ||
|
||
await expect(page.getByTestId('proof-data')).toContainText('Unredacted data successfully revealed to Verifier', { timeout: 60000 }); | ||
|
||
}); |
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 |
---|---|---|
@@ -1 +1,8 @@ | ||
package-lock.json | ||
|
||
# Playwright | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
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.