From da1d4aba6d8e7af00e982e0b0d33ab5ea5296deb Mon Sep 17 00:00:00 2001 From: Mathias Jakobsen Date: Wed, 4 Jan 2023 11:14:13 +0000 Subject: [PATCH] Merge pull request #10975 from overleaf/mf-settings-editor-new-tests Add new tests for editor left menu (compiler & dictionary menu) GitOrigin-RevId: 1b21fcc51a85901bce4f7b50e557146881df4c3d --- .../settings/settings-compiler.test.tsx | 29 +++++++++++++++++++ .../settings/settings-dictionary.test.tsx | 24 +++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 services/web/test/frontend/features/editor-left-menu/components/settings/settings-compiler.test.tsx create mode 100644 services/web/test/frontend/features/editor-left-menu/components/settings/settings-dictionary.test.tsx diff --git a/services/web/test/frontend/features/editor-left-menu/components/settings/settings-compiler.test.tsx b/services/web/test/frontend/features/editor-left-menu/components/settings/settings-compiler.test.tsx new file mode 100644 index 0000000000..459297d8ed --- /dev/null +++ b/services/web/test/frontend/features/editor-left-menu/components/settings/settings-compiler.test.tsx @@ -0,0 +1,29 @@ +import { screen, within } from '@testing-library/dom' +import { expect } from 'chai' +import fetchMock from 'fetch-mock' +import SettingsCompiler from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-compiler' +import { renderWithEditorContext } from '../../../../helpers/render-with-context' + +describe('', function () { + afterEach(function () { + fetchMock.reset() + }) + + it('shows correct menu', async function () { + renderWithEditorContext() + + const select = screen.getByLabelText('Compiler') + + const optionPdfLaTeX = within(select).getByText('pdfLaTeX') + expect(optionPdfLaTeX.getAttribute('value')).to.equal('pdflatex') + + const optionLaTeX = within(select).getByText('LaTeX') + expect(optionLaTeX.getAttribute('value')).to.equal('latex') + + const optionXeLaTeX = within(select).getByText('XeLaTeX') + expect(optionXeLaTeX.getAttribute('value')).to.equal('xelatex') + + const optionLuaLaTeX = within(select).getByText('LuaLaTeX') + expect(optionLuaLaTeX.getAttribute('value')).to.equal('lualatex') + }) +}) diff --git a/services/web/test/frontend/features/editor-left-menu/components/settings/settings-dictionary.test.tsx b/services/web/test/frontend/features/editor-left-menu/components/settings/settings-dictionary.test.tsx new file mode 100644 index 0000000000..db2642397a --- /dev/null +++ b/services/web/test/frontend/features/editor-left-menu/components/settings/settings-dictionary.test.tsx @@ -0,0 +1,24 @@ +import { fireEvent, screen, within } from '@testing-library/dom' +import { expect } from 'chai' +import SettingsDictionary from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-dictionary' +import { renderWithEditorContext } from '../../../../helpers/render-with-context' + +describe('', function () { + it('open dictionary modal', function () { + renderWithEditorContext() + + screen.getByText('Dictionary') + + const button = screen.getByRole('button', { name: 'Edit' }) + fireEvent.click(button) + + const modal = screen.getAllByRole('dialog')[0] + + within(modal).getByRole('heading', { name: 'Edit Dictionary' }) + within(modal).getByText('Your custom dictionary is empty.') + + const doneButton = within(modal).getByRole('button', { name: 'Done' }) + fireEvent.click(doneButton) + expect(screen.queryByRole('dialog')).to.be.null + }) +})