Procházet zdrojové kódy

Merge pull request #3588 from overleaf/msm-fix-outline-chat-stories

Fixed Chat and Outline stories

GitOrigin-RevId: ff0b0d8c733e7f3fc9a355ecc81c628d15497059
Eric Mc Sween před 5 roky
rodič
revize
94e65f16a8

+ 5 - 5
services/web/frontend/stories/chat.stories.js

@@ -7,11 +7,10 @@ import {
   stubUIConfig,
   stubMathJax
 } from '../../test/frontend/features/chat/components/stubs'
+import { setupContext } from './fixtures/context'
 
 const ONE_MINUTE = 60 * 1000
 
-window.project_id = '1234'
-
 const user = {
   id: 'fake_user',
   first_name: 'mortimer',
@@ -45,8 +44,9 @@ function generateMessages(count) {
 stubUIConfig()
 stubMathJax()
 stubChatStore({ user })
+setupContext()
 
-export const Conversation = args => <ChatPane {...args} />
+export const Conversation = args => <ChatPane {...args} chatIsOpen />
 Conversation.parameters = {
   setupMocks: () => {
     fetchMock.restore()
@@ -55,7 +55,7 @@ Conversation.parameters = {
   }
 }
 
-export const NoMessages = args => <ChatPane {...args} />
+export const NoMessages = args => <ChatPane {...args} chatIsOpen />
 NoMessages.parameters = {
   setupMocks: () => {
     fetchMock.restore()
@@ -63,7 +63,7 @@ NoMessages.parameters = {
   }
 }
 
-export const Loading = args => <ChatPane {...args} />
+export const Loading = args => <ChatPane {...args} chatIsOpen />
 Loading.parameters = {
   setupMocks: () => {
     fetchMock.restore()

+ 17 - 0
services/web/frontend/stories/fixtures/context.js

@@ -0,0 +1,17 @@
+import sinon from 'sinon'
+
+export function setupContext() {
+  window.project_id = '1234'
+  let $scope = {}
+  if (window._ide) {
+    $scope = { ...window._ide.$scope, project: {} }
+  }
+  window._ide = {
+    ...window._ide,
+    $scope,
+    socket: {
+      on: sinon.stub(),
+      removeListener: sinon.stub()
+    }
+  }
+}

+ 2 - 1
services/web/frontend/stories/outline.stories.js

@@ -2,8 +2,9 @@ import React from 'react'
 
 import OutlinePane from '../js/features/outline/components/outline-pane'
 import { ContextRoot } from '../js/shared/context/root-context'
+import { setupContext } from './fixtures/context'
 
-window.project_id = '1234'
+setupContext()
 
 export const Basic = args => <OutlinePane {...args} />
 Basic.args = {