mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
a555f0d309
* Added project name, pdf toggle and share project buttons to navigation toolbar * Added PropTypes check to `useChatContext()` * React context updates for project name/rename, pdf view and share moda * Hide PDF button when pdfLayout != 'flat' GitOrigin-RevId: 3f4a1b072259df7148d3417cd22116702bdd79ac
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
import React from 'react'
|
|
import { render } from '@testing-library/react'
|
|
import { ApplicationProvider } from '../../../frontend/js/shared/context/application-context'
|
|
import { EditorProvider } from '../../../frontend/js/shared/context/editor-context'
|
|
import sinon from 'sinon'
|
|
import { ChatProvider } from '../../../frontend/js/features/chat/context/chat-context'
|
|
import { LayoutProvider } from '../../../frontend/js/shared/context/layout-context'
|
|
|
|
export function renderWithEditorContext(
|
|
children,
|
|
{ user = { id: '123abd' }, projectId = 'project123' } = {}
|
|
) {
|
|
window.user = user || window.user
|
|
window.ExposedSettings.appName = 'test'
|
|
window.project_id = projectId != null ? projectId : window.project_id
|
|
window._ide = {
|
|
$scope: {
|
|
project: {
|
|
owner: {
|
|
_id: '124abd'
|
|
}
|
|
},
|
|
ui: {
|
|
chatOpen: true,
|
|
pdfLayout: 'flat'
|
|
},
|
|
$watch: () => {}
|
|
},
|
|
socket: {
|
|
on: sinon.stub(),
|
|
removeListener: sinon.stub()
|
|
}
|
|
}
|
|
return render(
|
|
<ApplicationProvider>
|
|
<EditorProvider ide={window._ide} settings={{}}>
|
|
<LayoutProvider $scope={window._ide.$scope}>{children}</LayoutProvider>
|
|
</EditorProvider>
|
|
</ApplicationProvider>
|
|
)
|
|
}
|
|
|
|
export function renderWithChatContext(children, { user, projectId } = {}) {
|
|
return renderWithEditorContext(<ChatProvider>{children}</ChatProvider>, {
|
|
user,
|
|
projectId
|
|
})
|
|
}
|
|
|
|
export function cleanUpContext() {
|
|
delete window.user
|
|
delete window.project_id
|
|
delete window._ide
|
|
}
|