Add [NEW PAGE] page and [VSPACE] to Insert menu (#848)
* Add menu entries for inserting new page and vspace codes * Update tests
This commit is contained in:
committed by
GitHub
parent
97aebc5b84
commit
1bf584f9bf
@@ -31,6 +31,8 @@ sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pa
|
||||
|
||||
import nw # noqa: E402
|
||||
|
||||
from PyQt5.QtWidgets import QMessageBox # noqa: E402
|
||||
|
||||
from nw.config import Config # noqa: E402
|
||||
|
||||
|
||||
@@ -153,6 +155,7 @@ def mockGUI(monkeypatch, tmpConf):
|
||||
def nwGUI(qtbot, monkeypatch, fncDir, fncConf):
|
||||
"""Create an instance of the novelWriter GUI.
|
||||
"""
|
||||
monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
|
||||
monkeypatch.setattr("nw.CONFIG", fncConf)
|
||||
nwGUI = nw.main(["--testmode", "--config=%s" % fncDir, "--data=%s" % fncDir])
|
||||
qtbot.addWidget(nwGUI)
|
||||
|
||||
@@ -81,6 +81,8 @@ def testBaseError_Handler(qtbot, monkeypatch, fncDir, tmpDir):
|
||||
checks that the error handler handles potential exceptions. The test
|
||||
will fail if excpetions are not handled.
|
||||
"""
|
||||
monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
|
||||
|
||||
qApp.closeAllWindows()
|
||||
nwGUI = nw.main(["--testmode", "--config=%s" % fncDir, "--data=%s" % tmpDir])
|
||||
qtbot.addWidget(nwGUI)
|
||||
|
||||
@@ -45,6 +45,7 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
|
||||
"""Test the load project wizard.
|
||||
"""
|
||||
# Block message box
|
||||
monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
|
||||
monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
|
||||
monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
|
||||
|
||||
|
||||
@@ -464,7 +464,8 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
|
||||
"""Test the Insert menu.
|
||||
"""
|
||||
# Block message box
|
||||
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes)
|
||||
monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
|
||||
monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
|
||||
|
||||
nwGUI.theProject.projTree.setSeed(42)
|
||||
assert nwGUI.newProject({"projPath": fncProj})
|
||||
@@ -641,6 +642,24 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
|
||||
|
||||
nwGUI.docEditor.clear()
|
||||
|
||||
##
|
||||
# Insert Break or Space
|
||||
##
|
||||
|
||||
nwGUI.docEditor.setText("### Stuff\n")
|
||||
nwGUI.mainMenu.aInsNewPage.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText() == "[NEW PAGE]\n### Stuff\n"
|
||||
|
||||
nwGUI.docEditor.setText("### Stuff\n")
|
||||
nwGUI.mainMenu.aInsVSpaceS.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText() == "[VSPACE]\n### Stuff\n"
|
||||
|
||||
nwGUI.docEditor.setText("### Stuff\n")
|
||||
nwGUI.mainMenu.aInsVSpaceM.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText() == "[VSPACE:2]\n### Stuff\n"
|
||||
|
||||
nwGUI.docEditor.clear()
|
||||
|
||||
##
|
||||
# Insert text from file
|
||||
##
|
||||
|
||||
@@ -36,6 +36,7 @@ def testGuiTheme_Main(qtbot, monkeypatch, nwMinimal, tmpDir):
|
||||
"""
|
||||
# Block message box
|
||||
monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
|
||||
monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
|
||||
|
||||
nwGUI = nw.main(["--testmode", "--config=%s" % nwMinimal, "--data=%s" % tmpDir, nwMinimal])
|
||||
qtbot.addWidget(nwGUI)
|
||||
|
||||
Reference in New Issue
Block a user