Skip to content

Commit

Permalink
apiUrl を外から渡すようにする
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Dec 26, 2024
1 parent 66a72f2 commit 92c0a11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions e2e-tests/data_channel_signaling_only/main.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ document.addEventListener('DOMContentLoaded', async () => {
const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || ''
const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || ''
const secretKey = import.meta.env.VITE_TEST_SECRET_KEY
const apiUrl = import.meta.env.VITE_TEST_API_URL

const client = new SoraClient(signalingUrl, channelIdPrefix, channelIdSuffix, secretKey)
const client = new SoraClient(signalingUrl, channelIdPrefix, channelIdSuffix, secretKey, apiUrl)

// SDK バージョンの表示
const sdkVersionElement = document.querySelector('#sdk-version')
Expand Down Expand Up @@ -71,12 +72,17 @@ class SoraClient {
private sora: SoraConnection
private connection: ConnectionPublisher

private apiUrl: string

constructor(
signalingUrl: string,
channelIdPrefix: string,
channelIdSuffix: string,
secretKey: string,
apiUrl: string,
) {
this.apiUrl = apiUrl

this.sora = Sora.connection(signalingUrl, this.debug)

// channel_id の生成
Expand Down Expand Up @@ -140,11 +146,10 @@ class SoraClient {

// E2E テスト側で実行した方が良い気がする
async apiDisconnect(): Promise<void> {
const apiUrl = import.meta.env.VITE_TEST_API_URL
if (apiUrl === '') {
console.error('VITE_TEST_API_URL is not set')
if (!this.apiUrl) {
throw new Error('VITE_TEST_API_URL is not set')
}
const response = await fetch(apiUrl, {
const response = await fetch(this.apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/tests/type_close.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect, test } from '@playwright/test'

// Sora API を利用するので要注意
test('data_channel_signaling_only type:close pages', async ({ browser }) => {
// 新しいページを2つ作成
const dataChannelSignalingOnly = await browser.newPage()
Expand Down

0 comments on commit 92c0a11

Please sign in to comment.