2021-01-21 12:22:28 +00:00
|
|
|
import sinon from 'sinon'
|
|
|
|
|
|
|
|
export function setupContext() {
|
|
|
|
window.project_id = '1234'
|
2021-02-17 10:05:33 +00:00
|
|
|
window.user = {
|
2021-04-27 07:52:58 +00:00
|
|
|
id: 'fake_user',
|
2021-04-30 20:20:16 +00:00
|
|
|
allowedFreeTrial: true,
|
2021-02-17 10:05:33 +00:00
|
|
|
}
|
2021-01-21 12:22:28 +00:00
|
|
|
let $scope = {}
|
|
|
|
if (window._ide) {
|
2021-03-04 14:22:58 +00:00
|
|
|
$scope = {
|
|
|
|
...window._ide.$scope,
|
2021-06-25 08:14:07 +00:00
|
|
|
user: window.user,
|
2021-12-10 10:20:24 +00:00
|
|
|
project: {
|
|
|
|
features: {},
|
2022-01-10 15:46:46 +00:00
|
|
|
rootFolder: [
|
|
|
|
{
|
|
|
|
_id: 'root-folder-id',
|
|
|
|
name: 'rootFolder',
|
|
|
|
docs: [],
|
|
|
|
folders: [],
|
|
|
|
fileRefs: [],
|
|
|
|
},
|
|
|
|
],
|
2021-12-10 10:20:24 +00:00
|
|
|
},
|
2021-03-04 14:22:58 +00:00
|
|
|
$watch: () => {},
|
2021-09-30 11:29:25 +00:00
|
|
|
$applyAsync: () => {},
|
2021-11-22 11:24:03 +00:00
|
|
|
$broadcast: () => {},
|
2021-03-04 14:22:58 +00:00
|
|
|
ui: {
|
2021-04-27 07:52:58 +00:00
|
|
|
chatOpen: true,
|
2021-04-28 08:46:39 +00:00
|
|
|
pdfLayout: 'flat',
|
2021-04-27 07:52:58 +00:00
|
|
|
},
|
2021-10-21 10:31:51 +00:00
|
|
|
settings: {
|
|
|
|
pdfViewer: 'js',
|
|
|
|
},
|
2021-05-31 08:25:32 +00:00
|
|
|
toggleHistory: () => {},
|
2021-03-04 14:22:58 +00:00
|
|
|
}
|
2021-01-21 12:22:28 +00:00
|
|
|
}
|
|
|
|
window._ide = {
|
|
|
|
...window._ide,
|
|
|
|
$scope,
|
|
|
|
socket: {
|
|
|
|
on: sinon.stub(),
|
2021-04-27 07:52:58 +00:00
|
|
|
removeListener: sinon.stub(),
|
|
|
|
},
|
2021-09-30 11:29:25 +00:00
|
|
|
fileTreeManager: {
|
2021-10-21 10:31:51 +00:00
|
|
|
findEntityById: () => null,
|
2021-09-30 11:29:25 +00:00
|
|
|
findEntityByPath: () => null,
|
2021-10-21 10:31:51 +00:00
|
|
|
getEntityPath: () => null,
|
2021-09-30 11:29:25 +00:00
|
|
|
getRootDocDirname: () => undefined,
|
|
|
|
},
|
2021-10-21 10:31:51 +00:00
|
|
|
editorManager: {
|
|
|
|
getCurrentDocId: () => 'foo',
|
|
|
|
openDoc: (id, options) => {
|
|
|
|
console.log('open doc', id, options)
|
|
|
|
},
|
|
|
|
},
|
2021-11-22 11:24:03 +00:00
|
|
|
metadataManager: {
|
|
|
|
metadata: {
|
|
|
|
state: {
|
|
|
|
documents: {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-01-21 12:22:28 +00:00
|
|
|
}
|
2021-03-31 15:46:43 +00:00
|
|
|
window.ExposedSettings = window.ExposedSettings || {}
|
2021-04-28 08:46:39 +00:00
|
|
|
window.ExposedSettings.appName = 'Overleaf'
|
|
|
|
window.gitBridgePublicBaseUrl = 'https://git.stories.com'
|
2021-01-21 12:22:28 +00:00
|
|
|
}
|