editor-left-menu.spec.tsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. import EditorLeftMenu from '../../../../frontend/js/features/editor-left-menu/components/editor-left-menu'
  2. import {
  3. AllowedImageName,
  4. MainDocument,
  5. OverallThemeMeta,
  6. SpellCheckLanguage,
  7. } from '../../../../types/project-settings'
  8. import { EditorProviders } from '../../helpers/editor-providers'
  9. import { mockScope } from './scope'
  10. describe('<EditorLeftMenu />', function () {
  11. beforeEach(function () {
  12. cy.viewport(800, 800)
  13. cy.interceptCompile()
  14. })
  15. describe('for non-anonymous users', function () {
  16. const overallThemes: OverallThemeMeta[] = [
  17. {
  18. name: 'Overall Theme 1',
  19. val: '',
  20. path: 'https://overleaf.com/overalltheme-1.css',
  21. },
  22. {
  23. name: 'Overall Theme 2',
  24. val: 'light-',
  25. path: 'https://overleaf.com/overalltheme-2.css',
  26. },
  27. ]
  28. const allowedImageNames: AllowedImageName[] = [
  29. {
  30. imageDesc: 'Image 1',
  31. imageName: 'img-1',
  32. },
  33. {
  34. imageDesc: 'Image 2',
  35. imageName: 'img-2',
  36. },
  37. ]
  38. beforeEach(function () {
  39. window.metaAttributesCache.set('ol-overallThemes', overallThemes)
  40. window.metaAttributesCache.set('ol-allowedImageNames', allowedImageNames)
  41. window.metaAttributesCache.set('ol-anonymous', false)
  42. window.metaAttributesCache.set('ol-showSupport', true)
  43. window.metaAttributesCache.set('ol-user', {
  44. email: 'sherlock@holmes.co.uk',
  45. first_name: 'Sherlock',
  46. last_name: 'Holmes',
  47. })
  48. })
  49. it('render full menu', function () {
  50. const scope = mockScope({
  51. ui: {
  52. leftMenuShown: true,
  53. },
  54. })
  55. cy.mount(
  56. <EditorProviders scope={scope}>
  57. <EditorLeftMenu />
  58. </EditorProviders>
  59. )
  60. // Download Menu
  61. cy.findByRole('heading', { name: 'Download' })
  62. cy.findByRole('link', { name: 'Source' })
  63. cy.findByRole('link', { name: 'PDF' })
  64. // Actions Menu
  65. cy.findByRole('heading', { name: 'Actions' })
  66. cy.findByRole('button', { name: 'Copy Project' })
  67. cy.findByRole('button', { name: 'Word Count' })
  68. // Sync Menu
  69. cy.findByRole('heading', { name: 'Sync' })
  70. cy.findByRole('button', { name: 'Dropbox' })
  71. cy.findByRole('button', { name: 'Git' })
  72. cy.findByRole('button', { name: 'GitHub' })
  73. // Settings Menu
  74. cy.findByRole('heading', { name: 'Settings' })
  75. cy.findByLabelText('Compiler')
  76. cy.findByLabelText('TeX Live version')
  77. cy.findByLabelText('Main document')
  78. cy.findByLabelText('Spell check')
  79. cy.findByLabelText('Auto-complete')
  80. cy.findByLabelText('Auto-close Brackets')
  81. cy.findByLabelText('Code check')
  82. cy.findByLabelText('Editor theme')
  83. cy.findByLabelText('Overall theme')
  84. cy.findByLabelText('Keybindings')
  85. cy.findByLabelText('Font Size')
  86. cy.findByLabelText('Font Family')
  87. cy.findByLabelText('Line Height')
  88. cy.findByLabelText('PDF Viewer')
  89. // Help Menu
  90. cy.findByRole('heading', { name: 'Help' })
  91. cy.findByRole('button', { name: 'Show Hotkeys' })
  92. cy.findByRole('link', { name: 'Documentation' })
  93. cy.findByRole('button', { name: 'Contact Us' })
  94. })
  95. describe('download menu', function () {
  96. it('have a correct source & pdf download url', function () {
  97. const scope = mockScope({
  98. ui: {
  99. leftMenuShown: true,
  100. },
  101. })
  102. cy.mount(
  103. <EditorProviders scope={scope}>
  104. <EditorLeftMenu />
  105. </EditorProviders>
  106. )
  107. cy.findByRole('link', { name: 'Source' }).should(
  108. 'have.attr',
  109. 'href',
  110. '/project/project123/download/zip'
  111. )
  112. cy.findByRole('link', { name: 'PDF' })
  113. .should('have.attr', 'href')
  114. .and('match', /\/download\/project\/project123\/build/)
  115. })
  116. })
  117. describe('actions menu', function () {
  118. it('shows copy project modal correctly', function () {
  119. cy.intercept('POST', '/project/*/clone', {
  120. body: {
  121. project_id: 'new_project_id',
  122. },
  123. })
  124. const scope = mockScope({
  125. ui: {
  126. leftMenuShown: true,
  127. },
  128. })
  129. cy.mount(
  130. <EditorProviders scope={scope}>
  131. <EditorLeftMenu />
  132. </EditorProviders>
  133. )
  134. cy.findByRole('button', { name: 'Copy Project' }).click()
  135. cy.findByRole('heading', { name: 'Copy Project' })
  136. // try closing & re-opening the modal with different methods
  137. cy.findByRole('button', { name: 'Close' }).click()
  138. cy.findByRole('button', { name: 'Copy Project' }).click()
  139. cy.findByRole('button', { name: 'Cancel' }).click()
  140. cy.findByRole('button', { name: 'Copy Project' }).click()
  141. cy.findByLabelText('New Name').focus()
  142. cy.findByLabelText('New Name').clear()
  143. cy.findByLabelText('New Name').type('Project Renamed')
  144. cy.get('#clone-project-form-name[value="Project Renamed"')
  145. })
  146. it('shows word count modal correctly', function () {
  147. cy.intercept('GET', '/project/*/wordcount*', {
  148. texcount: {
  149. encode: 'ascii',
  150. textWords: 781,
  151. headWords: 66,
  152. outside: 11,
  153. headers: 41,
  154. elements: 2,
  155. mathInline: 6,
  156. mathDisplay: 1,
  157. errors: 0,
  158. },
  159. }).as('wordCount')
  160. const scope = mockScope({
  161. ui: {
  162. leftMenuShown: true,
  163. },
  164. })
  165. cy.mount(
  166. <EditorProviders scope={scope}>
  167. <EditorLeftMenu />
  168. </EditorProviders>
  169. )
  170. cy.findByRole('button', { name: 'Word Count' }).click()
  171. cy.wait('@wordCount')
  172. cy.findByText('Total Words:')
  173. cy.findByText('781')
  174. cy.findByText('Headers:')
  175. cy.findByText('41')
  176. cy.findByText('Math Inline:')
  177. cy.findByText('6')
  178. cy.findByText('Math Display:')
  179. cy.findByText('1')
  180. })
  181. })
  182. describe('sync menu', function () {
  183. it('shows dropbox modal correctly', function () {
  184. cy.intercept('GET', '/dropbox/status', {
  185. registered: true,
  186. })
  187. const scope = mockScope({
  188. ui: {
  189. leftMenuShown: true,
  190. },
  191. project: {
  192. members: [],
  193. owner: {
  194. _id: '123',
  195. },
  196. },
  197. user: {
  198. features: {
  199. dropbox: false,
  200. },
  201. },
  202. })
  203. cy.mount(
  204. <EditorProviders scope={scope}>
  205. <EditorLeftMenu />
  206. </EditorProviders>
  207. )
  208. cy.findByRole('button', { name: 'Dropbox' }).click()
  209. cy.findByText('Dropbox Sync')
  210. })
  211. it('shows git modal correctly', function () {
  212. const scope = mockScope({
  213. ui: {
  214. leftMenuShown: true,
  215. },
  216. })
  217. cy.mount(
  218. <EditorProviders scope={scope}>
  219. <EditorLeftMenu />
  220. </EditorProviders>
  221. )
  222. cy.findByRole('button', { name: 'Git' }).click()
  223. cy.findByText('Clone with Git')
  224. cy.findByText(/your project using the link displayed below/)
  225. })
  226. it('shows github modal correctly', function () {
  227. cy.intercept('GET', '/user/github-sync/status', {
  228. available: false,
  229. enabled: false,
  230. }).as('user-status')
  231. cy.intercept('GET', '/project/*/github-sync/status', {
  232. enabled: false,
  233. }).as('project-status')
  234. const scope = mockScope({
  235. ui: {
  236. leftMenuShown: true,
  237. },
  238. })
  239. cy.mount(
  240. <EditorProviders scope={scope}>
  241. <EditorLeftMenu />
  242. </EditorProviders>
  243. )
  244. cy.wait('@compile')
  245. cy.findByRole('button', { name: 'GitHub' }).click()
  246. cy.findByText('GitHub Sync')
  247. cy.wait(['@user-status', '@project-status'])
  248. cy.findByText('Push to GitHub, pull to Overleaf')
  249. })
  250. })
  251. describe('settings menu', function () {
  252. it('shows compiler menu correctly', function () {
  253. const scope = mockScope({
  254. ui: {
  255. leftMenuShown: true,
  256. },
  257. })
  258. cy.mount(
  259. <EditorProviders scope={scope}>
  260. <EditorLeftMenu />
  261. </EditorProviders>
  262. )
  263. cy.get<HTMLOptionElement>('#settings-menu-compiler option').then(
  264. options => {
  265. const values = [...options].map(o => o.value)
  266. expect(values).to.deep.eq([
  267. 'pdflatex',
  268. 'latex',
  269. 'xelatex',
  270. 'lualatex',
  271. ])
  272. const texts = [...options].map(o => o.text)
  273. expect(texts).to.deep.eq([
  274. 'pdfLaTeX',
  275. 'LaTeX',
  276. 'XeLaTeX',
  277. 'LuaLaTeX',
  278. ])
  279. }
  280. )
  281. })
  282. it('shows texlive version menu correctly', function () {
  283. const scope = mockScope({
  284. ui: {
  285. leftMenuShown: true,
  286. },
  287. })
  288. cy.mount(
  289. <EditorProviders scope={scope}>
  290. <EditorLeftMenu />
  291. </EditorProviders>
  292. )
  293. cy.get<HTMLOptionElement>('#settings-menu-imageName option').then(
  294. options => {
  295. const values = [...options].map(o => o.value)
  296. expect(values).to.deep.eq(['img-1', 'img-2'])
  297. const texts = [...options].map(o => o.text)
  298. expect(texts).to.deep.eq(['Image 1', 'Image 2'])
  299. }
  300. )
  301. })
  302. it('shows document menu correctly', function () {
  303. const docs: MainDocument[] = [
  304. {
  305. path: 'main.tex',
  306. doc: {
  307. name: 'main.tex',
  308. id: 'id1',
  309. type: 'doc',
  310. selected: false,
  311. } as MainDocument['doc'],
  312. },
  313. {
  314. path: 'folder/main2.tex',
  315. doc: {
  316. name: 'main2.tex',
  317. id: 'id2',
  318. type: 'doc',
  319. selected: false,
  320. } as MainDocument['doc'],
  321. },
  322. ]
  323. const scope = mockScope({
  324. ui: {
  325. leftMenuShown: true,
  326. },
  327. docs,
  328. })
  329. cy.mount(
  330. <EditorProviders scope={scope}>
  331. <EditorLeftMenu />
  332. </EditorProviders>
  333. )
  334. cy.get<HTMLOptionElement>('#settings-menu-rootDocId option').then(
  335. options => {
  336. const values = [...options].map(o => o.value)
  337. expect(values).to.deep.eq(docs.map(doc => doc.doc.id))
  338. const texts = [...options].map(o => o.text)
  339. expect(texts).to.deep.eq(docs.map(doc => doc.path))
  340. }
  341. )
  342. })
  343. it('shows spellcheck menu correctly', function () {
  344. const languages: SpellCheckLanguage[] = [
  345. {
  346. name: 'Lang 1',
  347. code: 'lang-1',
  348. },
  349. {
  350. name: 'Lang 2',
  351. code: 'lang-2',
  352. },
  353. ]
  354. window.metaAttributesCache.set('ol-languages', languages)
  355. const scope = mockScope({
  356. ui: {
  357. leftMenuShown: true,
  358. },
  359. })
  360. cy.mount(
  361. <EditorProviders scope={scope}>
  362. <EditorLeftMenu />
  363. </EditorProviders>
  364. )
  365. cy.get<HTMLOptionElement>(
  366. '#settings-menu-spellCheckLanguage option'
  367. ).then(options => {
  368. const values = [...options].map(o => o.value)
  369. expect(values).to.deep.eq(['', 'lang-1', 'lang-2'])
  370. const texts = [...options].map(o => o.text)
  371. expect(texts).to.deep.eq(['Off', 'Lang 1', 'Lang 2'])
  372. })
  373. })
  374. it('shows dictionary modal correctly', function () {
  375. const scope = mockScope({
  376. ui: {
  377. leftMenuShown: true,
  378. },
  379. })
  380. cy.mount(
  381. <EditorProviders scope={scope}>
  382. <EditorLeftMenu />
  383. </EditorProviders>
  384. )
  385. cy.get('label[for="dictionary"] ~ button').click()
  386. cy.findByText('Edit Dictionary')
  387. cy.findByText('Your custom dictionary is empty.')
  388. })
  389. it('shows auto-complete menu correctly', function () {
  390. const scope = mockScope({
  391. ui: {
  392. leftMenuShown: true,
  393. },
  394. })
  395. cy.mount(
  396. <EditorProviders scope={scope}>
  397. <EditorLeftMenu />
  398. </EditorProviders>
  399. )
  400. cy.get<HTMLOptionElement>('#settings-menu-autoComplete option').then(
  401. options => {
  402. const values = [...options].map(o => o.value)
  403. expect(values).to.deep.eq(['true', 'false'])
  404. const texts = [...options].map(o => o.text)
  405. expect(texts).to.deep.eq(['On', 'Off'])
  406. }
  407. )
  408. })
  409. it('shows auto-close brackets menu correctly', function () {
  410. const scope = mockScope({
  411. ui: {
  412. leftMenuShown: true,
  413. },
  414. })
  415. cy.mount(
  416. <EditorProviders scope={scope}>
  417. <EditorLeftMenu />
  418. </EditorProviders>
  419. )
  420. cy.get<HTMLOptionElement>(
  421. '#settings-menu-autoPairDelimiters option'
  422. ).then(options => {
  423. const values = [...options].map(o => o.value)
  424. expect(values).to.deep.eq(['true', 'false'])
  425. const texts = [...options].map(o => o.text)
  426. expect(texts).to.deep.eq(['On', 'Off'])
  427. })
  428. })
  429. it('shows code check menu correctly', function () {
  430. const scope = mockScope({
  431. ui: {
  432. leftMenuShown: true,
  433. },
  434. })
  435. cy.mount(
  436. <EditorProviders scope={scope}>
  437. <EditorLeftMenu />
  438. </EditorProviders>
  439. )
  440. cy.get<HTMLOptionElement>(
  441. '#settings-menu-syntaxValidation option'
  442. ).then(options => {
  443. const values = [...options].map(o => o.value)
  444. expect(values).to.deep.eq(['true', 'false'])
  445. const texts = [...options].map(o => o.text)
  446. expect(texts).to.deep.eq(['On', 'Off'])
  447. })
  448. })
  449. it('shows editor theme menu correctly', function () {
  450. const editorThemes = ['editortheme-1', 'editortheme-2', 'editortheme-3']
  451. const legacyEditorThemes = [
  452. 'legacytheme-1',
  453. 'legacytheme-2',
  454. 'legacytheme-3',
  455. ]
  456. window.metaAttributesCache.set('ol-editorThemes', editorThemes)
  457. window.metaAttributesCache.set(
  458. 'ol-legacyEditorThemes',
  459. legacyEditorThemes
  460. )
  461. const scope = mockScope({
  462. ui: {
  463. leftMenuShown: true,
  464. },
  465. })
  466. cy.mount(
  467. <EditorProviders scope={scope}>
  468. <EditorLeftMenu />
  469. </EditorProviders>
  470. )
  471. cy.get<HTMLOptionElement>('#settings-menu-editorTheme option').then(
  472. options => {
  473. const values = [...options].map(o => o.value)
  474. expect(values).to.deep.eq([
  475. 'editortheme-1',
  476. 'editortheme-2',
  477. 'editortheme-3',
  478. '-',
  479. 'legacytheme-1',
  480. 'legacytheme-2',
  481. 'legacytheme-3',
  482. ])
  483. const texts = [...options].map(o => o.text)
  484. expect(texts).to.deep.eq([
  485. 'editortheme-1',
  486. 'editortheme-2',
  487. 'editortheme-3',
  488. '—————————————————',
  489. 'legacytheme-1 (Legacy)',
  490. 'legacytheme-2 (Legacy)',
  491. 'legacytheme-3 (Legacy)',
  492. ])
  493. }
  494. )
  495. })
  496. it('shows overall theme menu correctly', function () {
  497. const scope = mockScope({
  498. ui: {
  499. leftMenuShown: true,
  500. },
  501. })
  502. cy.mount(
  503. <EditorProviders scope={scope}>
  504. <EditorLeftMenu />
  505. </EditorProviders>
  506. )
  507. cy.get<HTMLOptionElement>('#settings-menu-overallTheme option').then(
  508. options => {
  509. const values = [...options].map(o => o.value)
  510. expect(values).to.deep.eq(['', 'light-'])
  511. const texts = [...options].map(o => o.text)
  512. expect(texts).to.deep.eq(['Overall Theme 1', 'Overall Theme 2'])
  513. }
  514. )
  515. })
  516. it('shows keybindings menu correctly', function () {
  517. const scope = mockScope({
  518. ui: {
  519. leftMenuShown: true,
  520. },
  521. })
  522. cy.mount(
  523. <EditorProviders scope={scope}>
  524. <EditorLeftMenu />
  525. </EditorProviders>
  526. )
  527. cy.get<HTMLOptionElement>('#settings-menu-mode option').then(
  528. options => {
  529. const values = [...options].map(o => o.value)
  530. expect(values).to.deep.eq(['default', 'vim', 'emacs'])
  531. const texts = [...options].map(o => o.text)
  532. expect(texts).to.deep.eq(['None', 'Vim', 'Emacs'])
  533. }
  534. )
  535. })
  536. it('shows font size menu correctly', function () {
  537. const scope = mockScope({
  538. ui: {
  539. leftMenuShown: true,
  540. },
  541. })
  542. cy.mount(
  543. <EditorProviders scope={scope}>
  544. <EditorLeftMenu />
  545. </EditorProviders>
  546. )
  547. cy.get<HTMLOptionElement>('#settings-menu-fontSize option').then(
  548. options => {
  549. const values = [...options].map(o => o.value)
  550. expect(values).to.deep.eq([
  551. '10',
  552. '11',
  553. '12',
  554. '13',
  555. '14',
  556. '16',
  557. '18',
  558. '20',
  559. '22',
  560. '24',
  561. ])
  562. const texts = [...options].map(o => o.text)
  563. expect(texts).to.deep.eq([
  564. '10px',
  565. '11px',
  566. '12px',
  567. '13px',
  568. '14px',
  569. '16px',
  570. '18px',
  571. '20px',
  572. '22px',
  573. '24px',
  574. ])
  575. }
  576. )
  577. })
  578. it('shows font family menu correctly', function () {
  579. const scope = mockScope({
  580. ui: {
  581. leftMenuShown: true,
  582. },
  583. })
  584. cy.mount(
  585. <EditorProviders scope={scope}>
  586. <EditorLeftMenu />
  587. </EditorProviders>
  588. )
  589. cy.get<HTMLOptionElement>('#settings-menu-fontFamily option').then(
  590. options => {
  591. const values = [...options].map(o => o.value)
  592. expect(values).to.deep.eq(['monaco', 'lucida'])
  593. const texts = [...options].map(o => o.text)
  594. expect(texts).to.deep.eq([
  595. 'Monaco / Menlo / Consolas',
  596. 'Lucida / Source Code Pro',
  597. ])
  598. }
  599. )
  600. })
  601. it('shows line height menu correctly', function () {
  602. const scope = mockScope({
  603. ui: {
  604. leftMenuShown: true,
  605. },
  606. })
  607. cy.mount(
  608. <EditorProviders scope={scope}>
  609. <EditorLeftMenu />
  610. </EditorProviders>
  611. )
  612. cy.get<HTMLOptionElement>('#settings-menu-lineHeight option').then(
  613. options => {
  614. const values = [...options].map(o => o.value)
  615. expect(values).to.deep.eq(['compact', 'normal', 'wide'])
  616. const texts = [...options].map(o => o.text)
  617. expect(texts).to.deep.eq(['Compact', 'Normal', 'Wide'])
  618. }
  619. )
  620. })
  621. it('shows pdf viewer menu correctly', function () {
  622. const scope = mockScope({
  623. ui: {
  624. leftMenuShown: true,
  625. },
  626. })
  627. cy.mount(
  628. <EditorProviders scope={scope}>
  629. <EditorLeftMenu />
  630. </EditorProviders>
  631. )
  632. cy.get<HTMLOptionElement>('#settings-menu-pdfViewer option').then(
  633. options => {
  634. const values = [...options].map(o => o.value)
  635. expect(values).to.deep.eq(['pdfjs', 'native'])
  636. const texts = [...options].map(o => o.text)
  637. expect(texts).to.deep.eq(['Overleaf', 'Browser'])
  638. }
  639. )
  640. })
  641. })
  642. describe('help menu', function () {
  643. it('shows hotkeys modal correctly', function () {
  644. const scope = mockScope({
  645. ui: {
  646. leftMenuShown: true,
  647. },
  648. })
  649. cy.mount(
  650. <EditorProviders scope={scope}>
  651. <EditorLeftMenu />
  652. </EditorProviders>
  653. )
  654. cy.findByRole('button', { name: 'Show Hotkeys' }).click()
  655. cy.findByText('Hotkeys (Source editor)')
  656. })
  657. it('shows correct url for documentation', function () {
  658. const scope = mockScope({
  659. ui: {
  660. leftMenuShown: true,
  661. },
  662. })
  663. cy.mount(
  664. <EditorProviders scope={scope}>
  665. <EditorLeftMenu />
  666. </EditorProviders>
  667. )
  668. cy.findByRole('link', { name: 'Documentation' }).should(
  669. 'have.attr',
  670. 'href',
  671. '/learn'
  672. )
  673. })
  674. it('shows correct contact us modal', function () {
  675. const scope = mockScope({
  676. ui: {
  677. leftMenuShown: true,
  678. },
  679. })
  680. cy.mount(
  681. <EditorProviders scope={scope}>
  682. <EditorLeftMenu />
  683. </EditorProviders>
  684. )
  685. cy.findByRole('button', { name: 'Contact Us' }).click()
  686. cy.findByText('Affected project URL (Optional)')
  687. })
  688. })
  689. })
  690. describe('for anonymous users', function () {
  691. it('render minimal menu', function () {
  692. const scope = mockScope({
  693. ui: {
  694. leftMenuShown: true,
  695. },
  696. })
  697. window.metaAttributesCache.set('ol-anonymous', true)
  698. cy.mount(
  699. <EditorProviders scope={scope}>
  700. <EditorLeftMenu />
  701. </EditorProviders>
  702. )
  703. // Download Menu
  704. cy.findByRole('heading', { name: 'Download' })
  705. cy.findByRole('link', { name: 'Source' })
  706. cy.findByRole('link', { name: 'PDF' })
  707. // Actions Menu
  708. cy.findByRole('heading', { name: 'Actions' }).should('not.exist')
  709. cy.findByRole('button', { name: 'Copy Project' }).should('not.exist')
  710. cy.findByRole('button', { name: 'Word Count' }).should('not.exist')
  711. // Sync Menu
  712. cy.findByRole('heading', { name: 'Sync' }).should('not.exist')
  713. cy.findByRole('button', { name: 'Dropbox' }).should('not.exist')
  714. cy.findByRole('button', { name: 'Git' }).should('not.exist')
  715. cy.findByRole('button', { name: 'GitHub' }).should('not.exist')
  716. // Settings Menu
  717. cy.findByRole('heading', { name: 'Settings' }).should('not.exist')
  718. cy.findByLabelText('Compiler').should('not.exist')
  719. cy.findByLabelText('TeX Live version').should('not.exist')
  720. cy.findByLabelText('Main document').should('not.exist')
  721. cy.findByLabelText('Spell check').should('not.exist')
  722. cy.findByLabelText('Auto-complete').should('not.exist')
  723. cy.findByLabelText('Auto-close Brackets').should('not.exist')
  724. cy.findByLabelText('Code check').should('not.exist')
  725. cy.findByLabelText('Editor theme').should('not.exist')
  726. cy.findByLabelText('Overall theme').should('not.exist')
  727. cy.findByLabelText('Keybindings').should('not.exist')
  728. cy.findByLabelText('Font Size').should('not.exist')
  729. cy.findByLabelText('Font Family').should('not.exist')
  730. cy.findByLabelText('Line Height').should('not.exist')
  731. cy.findByLabelText('PDF Viewer').should('not.exist')
  732. // Help Menu
  733. cy.findByRole('heading', { name: 'Help' })
  734. cy.findByRole('button', { name: 'Show Hotkeys' })
  735. cy.findByRole('button', { name: 'Documentation' }).should('not.exist')
  736. cy.findByRole('link', { name: 'Contact Us' }).should('not.exist')
  737. })
  738. })
  739. })