Skip to content

Commit

Permalink
Merge pull request #581 from shiguredo/feature/e2e-tests
Browse files Browse the repository at this point in the history
Feature/e2e tests
  • Loading branch information
voluntas authored Dec 25, 2024
2 parents cb8b81a + da4af90 commit 504acbb
Show file tree
Hide file tree
Showing 57 changed files with 22 additions and 30 deletions.
10 changes: 5 additions & 5 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# サンプルやテストに利用する Sora の Signaling URL を指定してください
VITE_SORA_SIGNALING_URL=wss://sora.example.com/signaling
# サンプルやテストに利用する Sora の ChannelID のプレフィックスを指定してください
VITE_SORA_CHANNEL_ID_PREFIX=sora-js-sdk-examples__
# サンプルやテストに利用する Sora の ChannelID を指定してください
VITE_SORA_CHANNEL_ID=sora-js-sdk
# サンプルやテストに利用するアクセストークンを指定してください、不要であれば空欄で大丈夫です
VITE_ACCESS_TOKEN=access_token


# サンプルやテストに利用する Sora の API URL を指定ください、不要であれば空欄で大丈夫です
VITE_SORA_API_URL=https://sora.example.com/api
# サンプルやテストに利用する Sora の WHIP のエンドポイント URL を指定してください
# サンプルやテストに利用する Sora の WHIP のエンドポイント URL を指定してください、不要であれば空欄で大丈夫です
VITE_SORA_WHIP_ENDPOINT_URL=https://sora.example.com/whip
# サンプルやテストに利用する Sora の WHEP のエンドポイント URL を指定してください
VITE_SORA_WHEP_ENDPOINT_URL=https://sora.example.com/whep
# サンプルやテストに利用する Sora の WHEP のエンドポイント URL を指定してください、不要であれば空欄で大丈夫です
VITE_SORA_WHEP_ENDPOINT_URL=https://sora.example.com/whep
2 changes: 1 addition & 1 deletion .github/workflows/npm-pkg-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- run: pnpm --version
- run: pnpm install
- run: pnpm add -E sora-js-sdk@${{ matrix.sdk_version }}
working-directory: ./examples
working-directory: ./e2e-tests
# pnpm run build しない
- run: pnpm exec playwright install ${{ matrix.browser }} --with-deps
- run: pnpm exec playwright test --project=${{ matrix.browser }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
- @voluntas
- [ADD] .markdownlint.yaml ファイルを追加する
- @voluntas
- [CHANGE] examples を e2e-tests に変更する
- @voluntas
- [CHANGE] tsconfig.json の moduleResolution を Bundler に変更する
- @voluntas
- [CHANGE] tsconfig.json の target と module を ES2022 に変更する
Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ pnpm add sora-js-sdk
> - Firefox 113 以降
> - Safari 16.4 以降
## サンプル集

```bash
# .env.local を作成して適切な値を設定してください
$ cp .env.template .env.local
$ pnpm install
$ pnpm run build
$ pnpm run dev
```

## E2E (End to End) テスト

Playwright を利用した E2E テストを実行できます。
Expand Down
8 changes: 5 additions & 3 deletions examples/README.md → e2e-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sora JavaScript SDK サンプル
# Sora JavaScript SDK E2E テスト

## 使い方

Expand All @@ -9,12 +9,14 @@ $ cd sora-js-sdk
$ cp .env.template .env.local
$ pnpm install
$ pnpm build
$ pnpm dev
$ pnpm e2e-test
```

## WHIP/WHEP

SDK では対応していない WHIP/WHEP のサンプルを用意しています。
SDK では対応していないブラウザレベルでの WHIP/WHEP の E2E テストを用意しています。

このサンプルは Chrome / Edge でのみ動作します。

WHIP/WHEP を利用するには whip/whep が有効になっており、
whip_turn/whep_turn も有効になっている必要があります。
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions examples/sendrecv/main.mts → e2e-tests/sendrecv/main.mts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ class SoraClient {
videoCodecType: VideoCodecType | undefined,
) {
this.sora = Sora.connection(signalingUrl, this.debug)

this.channelId = `${channelIdPrefix}${channelName}${channelIdSuffix}`

this.metadata = { access_token: accessToken }
this.options = {}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions examples/vite.config.mjs → e2e-tests/vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export default defineConfig({
sendonly_audio: resolve(__dirname, 'sendonly_audio/index.html'),
messaging: resolve(__dirname, 'messaging/index.html'),
data_channel_signaling_only: resolve(__dirname, 'data_channel_signaling_only/index.html'),
whip: resolve(__dirname, 'whip/index.html'),
whep: resolve(__dirname, 'whep/index.html'),
},
},
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"build": "vite build",
"watch": "vite build --watch",
"dev": "vite --config examples/vite.config.mjs",
"dev": "vite --config e2e-tests/vite.config.mjs",
"e2e-test": "pnpm build && playwright test --project=chromium",
"lint": "biome lint",
"fmt": "biome format --write",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig, devices } from '@playwright/test'
// pnpm exec playwright test --ui

export default defineConfig({
testDir: 'tests/playwright',
testDir: 'e2e-tests/tests',
// fullyParallel: true,
reporter: 'html',
use: {
Expand Down
6 changes: 0 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/vitest/utils.test.ts → tests/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from 'vitest'
import type { AudioCodecType, DataChannelDirection, VideoCodecType } from '../../src/types'
import { createSignalingMessage } from '../../src/utils'
import type { AudioCodecType, DataChannelDirection, VideoCodecType } from '../src/types'
import { createSignalingMessage } from '../src/utils'

const channelId = '7N3fsMHob'
const metadata = 'PG9A6RXgYqiqWKOVO'
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default mergeConfig(
defineConfig({
test: {
environment: 'jsdom',
include: ['tests/vitest/**/*.ts'],
include: ['tests/**/*.ts'],
},
}),
)

0 comments on commit 504acbb

Please sign in to comment.