From 92c0a1128a070cd658298971a63948a02e03baaa Mon Sep 17 00:00:00 2001 From: voluntas Date: Thu, 26 Dec 2024 11:03:07 +0900 Subject: [PATCH] =?UTF-8?q?apiUrl=20=E3=82=92=E5=A4=96=E3=81=8B=E3=82=89?= =?UTF-8?q?=E6=B8=A1=E3=81=99=E3=82=88=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- e2e-tests/data_channel_signaling_only/main.mts | 15 ++++++++++----- e2e-tests/tests/type_close.spec.ts | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/e2e-tests/data_channel_signaling_only/main.mts b/e2e-tests/data_channel_signaling_only/main.mts index 26f4c907..62e76a1a 100644 --- a/e2e-tests/data_channel_signaling_only/main.mts +++ b/e2e-tests/data_channel_signaling_only/main.mts @@ -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') @@ -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 の生成 @@ -140,11 +146,10 @@ class SoraClient { // E2E テスト側で実行した方が良い気がする async apiDisconnect(): Promise { - 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', diff --git a/e2e-tests/tests/type_close.spec.ts b/e2e-tests/tests/type_close.spec.ts index 3d3b5ce4..0afb5012 100644 --- a/e2e-tests/tests/type_close.spec.ts +++ b/e2e-tests/tests/type_close.spec.ts @@ -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()