overleaf/services/web/frontend/stories/fixtures/context.js
Alf Eaton 41c034b5fc [web] Add advanced references search to CodeMirror 6 (#5939)
GitOrigin-RevId: 5731ec63565fc1b9c048e89bca21eb3303624133
2021-12-13 09:03:59 +00:00

61 lines
1.3 KiB
JavaScript

import sinon from 'sinon'
export function setupContext() {
window.project_id = '1234'
window.user = {
id: 'fake_user',
allowedFreeTrial: true,
}
let $scope = {}
if (window._ide) {
$scope = {
...window._ide.$scope,
user: window.user,
project: {
features: {},
},
$watch: () => {},
$applyAsync: () => {},
$broadcast: () => {},
ui: {
chatOpen: true,
pdfLayout: 'flat',
},
settings: {
pdfViewer: 'js',
},
toggleHistory: () => {},
rootFolder: { type: 'folder', children: [] },
}
}
window._ide = {
...window._ide,
$scope,
socket: {
on: sinon.stub(),
removeListener: sinon.stub(),
},
fileTreeManager: {
findEntityById: () => null,
findEntityByPath: () => null,
getEntityPath: () => null,
getRootDocDirname: () => undefined,
},
editorManager: {
getCurrentDocId: () => 'foo',
openDoc: (id, options) => {
console.log('open doc', id, options)
},
},
metadataManager: {
metadata: {
state: {
documents: {},
},
},
},
}
window.ExposedSettings = window.ExposedSettings || {}
window.ExposedSettings.appName = 'Overleaf'
window.gitBridgePublicBaseUrl = 'https://git.stories.com'
}