Fixing test case

This commit is contained in:
Bala Lakshmi Narayanasami
2022-07-20 02:02:14 +05:30
parent 3e0694b8d2
commit e3e05e832a

View File

@@ -21,7 +21,7 @@ import {
ContainerConnectionInfo, ContainerConnectionInfo,
IPhoenixConnectionInfoResult, IPhoenixConnectionInfoResult,
IProvisionData, IProvisionData,
IResponse, IResponse
} from "../Contracts/DataModels"; } from "../Contracts/DataModels";
import * as ViewModels from "../Contracts/ViewModels"; import * as ViewModels from "../Contracts/ViewModels";
import { GitHubOAuthService } from "../GitHub/GitHubOAuthService"; import { GitHubOAuthService } from "../GitHub/GitHubOAuthService";
@@ -468,26 +468,35 @@ export default class Explorer {
} }
private async generateConversationToken() { private async generateConversationToken() {
if (!userContext.databaseAccount || !userContext.databaseAccount.id) {
console.error("Database account undefined");
return;
}
const url = `${configContext.JUNO_ENDPOINT}/api/chatbot/bot${userContext.databaseAccount.id}/conversationToken`; const url = `${configContext.JUNO_ENDPOINT}/api/chatbot/bot${userContext.databaseAccount.id}/conversationToken`;
const authorizationHeader = getAuthorizationHeader(); const authorizationHeader = getAuthorizationHeader();
const response = await fetch(url, { try {
method: "GET", const response = await fetch(url, {
headers: { method: "GET",
[Constants.HttpHeaders.authorization]: authorizationHeader.token, headers: {
Accept: "application/json", [Constants.HttpHeaders.authorization]: authorizationHeader.token,
[Constants.HttpHeaders.contentType]: "application/json", Accept: "application/json",
}, [Constants.HttpHeaders.contentType]: "application/json",
}); },
});
if (!response.ok) { if (!response.ok) {
throw new Error(await response.json()); throw new Error(await response.json());
} }
const tokenResponse: { conversationId: string; token: string; expires_in: number } = await response.json(); const tokenResponse: { conversationId: string; token: string; expires_in: number } = await response.json();
this.conversationToken(tokenResponse?.token); this.conversationToken(tokenResponse?.token);
if (tokenResponse?.expires_in) { if (tokenResponse?.expires_in) {
setTimeout(() => this.generateConversationToken(), (tokenResponse?.expires_in - 1000) * 1000); setTimeout(() => this.generateConversationToken(), (tokenResponse?.expires_in - 1000) * 1000);
}
} catch (error) {
console.error("Error fetching conversation token");
console.error(error);
} }
} }