context.js 860 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. toggleHistory: () => {},
  21. }
  22. }
  23. window._ide = {
  24. ...window._ide,
  25. $scope,
  26. socket: {
  27. on: sinon.stub(),
  28. removeListener: sinon.stub(),
  29. },
  30. fileTreeManager: {
  31. findEntityByPath: () => null,
  32. getRootDocDirname: () => undefined,
  33. },
  34. }
  35. window.ExposedSettings = window.ExposedSettings || {}
  36. window.ExposedSettings.appName = 'Overleaf'
  37. window.gitBridgePublicBaseUrl = 'https://git.stories.com'
  38. }