context.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import sinon from 'sinon'
  2. export function setupContext() {
  3. window.project_id = '1234'
  4. window.user = {
  5. id: 'fake_user',
  6. allowedFreeTrial: true,
  7. }
  8. let $scope = {}
  9. if (window._ide) {
  10. $scope = {
  11. ...window._ide.$scope,
  12. user: window.user,
  13. project: {},
  14. $watch: () => {},
  15. $applyAsync: () => {},
  16. ui: {
  17. chatOpen: true,
  18. pdfLayout: 'flat',
  19. },
  20. settings: {
  21. pdfViewer: 'js',
  22. },
  23. toggleHistory: () => {},
  24. }
  25. }
  26. window._ide = {
  27. ...window._ide,
  28. $scope,
  29. socket: {
  30. on: sinon.stub(),
  31. removeListener: sinon.stub(),
  32. },
  33. fileTreeManager: {
  34. findEntityById: () => null,
  35. findEntityByPath: () => null,
  36. getEntityPath: () => null,
  37. getRootDocDirname: () => undefined,
  38. },
  39. editorManager: {
  40. getCurrentDocId: () => 'foo',
  41. openDoc: (id, options) => {
  42. console.log('open doc', id, options)
  43. },
  44. },
  45. }
  46. window.ExposedSettings = window.ExposedSettings || {}
  47. window.ExposedSettings.appName = 'Overleaf'
  48. window.gitBridgePublicBaseUrl = 'https://git.stories.com'
  49. }