Create stories for layout testing (#2722)

* Inject services with useContext

* Extract service for video settings

* Create mock factories for services

* Create test data for chat history

* Add story to visualize different layouts

* Fix renaming mistake

* Add landscape and portrait viewports

* Add landscape stories

---------

Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
Michael David Kuckuk
2023-02-27 01:54:28 +01:00
committed by GitHub
parent f0f9c2ced1
commit b38df2fbe3
14 changed files with 428 additions and 25 deletions

View File

@@ -1,16 +1,22 @@
import { createContext } from 'react';
import { ChatMessage } from '../interfaces/chat-message.model';
import { getUnauthedData } from '../utils/apis';
const ENDPOINT = `/api/chat`;
const URL_CHAT_REGISTRATION = `/api/chat/register`;
interface UserRegistrationResponse {
export interface UserRegistrationResponse {
id: string;
accessToken: string;
displayName: string;
displayColor: number;
}
export interface ChatStaticService {
getChatHistory(accessToken: string): Promise<ChatMessage[]>;
registerUser(username: string): Promise<UserRegistrationResponse>;
}
class ChatService {
public static async getChatHistory(accessToken: string): Promise<ChatMessage[]> {
const response = await getUnauthedData(`${ENDPOINT}?accessToken=${accessToken}`);
@@ -31,4 +37,4 @@ class ChatService {
}
}
export default ChatService;
export const ChatServiceContext = createContext<ChatStaticService>(ChatService);