UNPKG

systelab-components-wdio-test

Version:
30 lines (29 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TauriDriverRemote = void 0; const http_status_js_1 = require("../server/http-status.js"); class TauriDriverRemote { static async start(remoteHost) { await this.executeEndpoint(remoteHost, 'POST', 'start'); } static async stop(remoteHost) { await this.executeEndpoint(remoteHost, 'POST', 'stop'); } static async executeEndpoint(remoteHost, method, route) { const hostname = remoteHost.name; const port = remoteHost.port; const apiPrefix = remoteHost.apiPrefix; const baseURL = `http://${hostname}:${port}/${apiPrefix}`; const endpointURL = `${baseURL}/${route}`; const response = await fetch(endpointURL, { method, headers: { 'content-type': 'application/json' }, }); if (response.status === http_status_js_1.HttpStatus.INTERNAL_SERVER_ERROR) { const errorMessage = response.body.error; throw new Error('Error: ' + errorMessage); } return response; } } exports.TauriDriverRemote = TauriDriverRemote;