sandboxed-compiles.spec.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { ensureUserExists, login } from './helpers/login'
  2. import { createProject } from './helpers/project'
  3. import { startWith } from './helpers/config'
  4. import { throttledRecompile } from './helpers/compile'
  5. describe('SandboxedCompiles', function () {
  6. ensureUserExists({ email: 'user@example.com' })
  7. const enabledVars = {
  8. DOCKER_RUNNER: 'true',
  9. SANDBOXED_COMPILES: 'true',
  10. SANDBOXED_COMPILES_SIBLING_CONTAINERS: 'true',
  11. ALL_TEX_LIVE_DOCKER_IMAGE_NAMES: '2023,2022',
  12. }
  13. describe('enabled in Server Pro', () => {
  14. startWith({
  15. pro: true,
  16. vars: enabledVars,
  17. })
  18. beforeEach(function () {
  19. login('user@example.com')
  20. })
  21. it('should offer TexLive images and switch the compiler', () => {
  22. cy.visit('/project')
  23. createProject('sandboxed')
  24. const recompile = throttledRecompile()
  25. // check produced PDF
  26. cy.get('.pdf-viewer').should('contain.text', 'sandboxed')
  27. cy.get('[aria-label="View logs"]').click()
  28. cy.findByText(/This is pdfTeX, Version .+ \(TeX Live 2023\) /)
  29. cy.get('header').findByText('Menu').click()
  30. cy.findByText('TeX Live version')
  31. .parent()
  32. .findByText('2023')
  33. .parent()
  34. .select('2022')
  35. // close editor menu
  36. cy.get('#left-menu-modal').click()
  37. // Trigger compile with other TexLive version
  38. recompile()
  39. cy.get('[aria-label="View logs"]').click()
  40. cy.findByText(/This is pdfTeX, Version .+ \(TeX Live 2022\) /)
  41. })
  42. })
  43. function checkUsesDefaultCompiler() {
  44. beforeEach(function () {
  45. login('user@example.com')
  46. })
  47. it('should not offer TexLive images and use default compiler', () => {
  48. cy.visit('/project')
  49. createProject('sandboxed')
  50. // check produced PDF
  51. cy.get('.pdf-viewer').should('contain.text', 'sandboxed')
  52. cy.get('[aria-label="View logs"]').click()
  53. cy.findByText(/This is pdfTeX, Version .+ \(TeX Live 2024\) /)
  54. cy.get('header').findByText('Menu').click()
  55. cy.findByText('Word Count') // wait for lazy loading
  56. cy.findByText('TeX Live version').should('not.exist')
  57. })
  58. }
  59. describe('disabled in Server Pro', () => {
  60. startWith({ pro: true })
  61. checkUsesDefaultCompiler()
  62. })
  63. describe.skip('unavailable in CE', () => {
  64. startWith({ pro: false, vars: enabledVars })
  65. checkUsesDefaultCompiler()
  66. })
  67. })