Add menu entry and update tests

This commit is contained in:
Veronica Berglyd Olsen
2024-03-12 18:12:47 +01:00
parent 44721fc797
commit 1bd82954c2
7 changed files with 76 additions and 16 deletions
+13
View File
@@ -502,6 +502,19 @@ def testCoreIndex_ScanText(mockGUI, fncPath, mockRnd):
assert index._itemIndex[tHandle]["T0001"].paraCount == 1 # type: ignore
assert index._itemIndex[tHandle]["T0001"].synopsis == "" # type: ignore
assert index.scanText(tHandle, (
"###! Hard Scene\n\n"
"We're no longer following Jane, but John!\n\n"
))
assert index._itemIndex[cHandle]["T0001"].references == {} # type: ignore
assert index._itemIndex[tHandle]["T0001"].level == "H3" # type: ignore
assert index._itemIndex[tHandle]["T0001"].line == 1 # type: ignore
assert index._itemIndex[tHandle]["T0001"].title == "Hard Scene" # type: ignore
assert index._itemIndex[tHandle]["T0001"].charCount == 51 # type: ignore
assert index._itemIndex[tHandle]["T0001"].wordCount == 9 # type: ignore
assert index._itemIndex[tHandle]["T0001"].paraCount == 1 # type: ignore
assert index._itemIndex[tHandle]["T0001"].synopsis == "" # type: ignore
# Page wo/Title
# =============
+15 -1
View File
@@ -1134,13 +1134,20 @@ def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, projPath, ipsumText
assert nwGUI.docEditor.getText() == "Title\n\n"
assert nwGUI.docEditor.getCursorPosition() == 2
# Strip Unnumbered CHapter
# Strip Unnumbered Chapter
nwGUI.docEditor.replaceText("##! Title\n\n")
nwGUI.docEditor.setCursorPosition(5)
assert nwGUI.docEditor._formatBlock(nwDocAction.BLOCK_TXT) is True
assert nwGUI.docEditor.getText() == "Title\n\n"
assert nwGUI.docEditor.getCursorPosition() == 1
# Strip Hard Scene
nwGUI.docEditor.replaceText("###! Title\n\n")
nwGUI.docEditor.setCursorPosition(6)
assert nwGUI.docEditor._formatBlock(nwDocAction.BLOCK_TXT) is True
assert nwGUI.docEditor.getText() == "Title\n\n"
assert nwGUI.docEditor.getCursorPosition() == 1
# Strip Text
nwGUI.docEditor.replaceText("Generic text\n\n")
nwGUI.docEditor.setCursorPosition(5)
@@ -1302,6 +1309,13 @@ def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, projPath, ipsumText
assert nwGUI.docEditor.getText() == "##! Some text\n\n"
assert nwGUI.docEditor.getCursorPosition() == 9
# Hard Scene
nwGUI.docEditor.replaceText("Some text\n\n")
nwGUI.docEditor.setCursorPosition(5)
assert nwGUI.docEditor._formatBlock(nwDocAction.BLOCK_HSC) is True
assert nwGUI.docEditor.getText() == "###! Some text\n\n"
assert nwGUI.docEditor.getCursorPosition() == 10
# Left Indent
nwGUI.docEditor.replaceText("Some text\n\n")
nwGUI.docEditor.setCursorPosition(5)
+5
View File
@@ -126,6 +126,11 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
fmtStr = "##! Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:105] == fmtStr
# Hard Scene
nwGUI.mainMenu.aFmtHardSc.activate(QAction.Trigger)
fmtStr = "###! Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:106] == fmtStr
# Clear Format
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText
@@ -327,12 +327,14 @@ def testBuildSettings_Headings(qtbot: QtBot, nwGUI: GuiMain):
chTitle = f"Chapter: {nwHeadFmt.TITLE}"
unTitle = f"Interlude: {nwHeadFmt.TITLE}"
scTitle = f"Scene: {nwHeadFmt.TITLE}"
shTitle = f"Hard Scene: {nwHeadFmt.TITLE}"
sxTitle = f"Section: {nwHeadFmt.TITLE}"
build.setValue("headings.fmtTitle", ttTitle)
build.setValue("headings.fmtChapter", chTitle)
build.setValue("headings.fmtUnnumbered", unTitle)
build.setValue("headings.fmtScene", scTitle)
build.setValue("headings.fmtHardScene", shTitle)
build.setValue("headings.fmtSection", sxTitle)
build.setValue("headings.hideScene", False)
build.setValue("headings.hideSection", False)
@@ -351,6 +353,7 @@ def testBuildSettings_Headings(qtbot: QtBot, nwGUI: GuiMain):
assert headTab.fmtChapter.text() == chTitle
assert headTab.fmtUnnumbered.text() == unTitle
assert headTab.fmtScene.text() == scTitle
assert headTab.fmtHScene.text() == shTitle
assert headTab.fmtSection.text() == sxTitle
assert headTab.swtScene.isChecked() is False
assert headTab.swtSection.isChecked() is False
@@ -396,6 +399,14 @@ def testBuildSettings_Headings(qtbot: QtBot, nwGUI: GuiMain):
headTab.btnApply.click()
assert headTab.editTextBox.isEnabled() is False
# Hard Scene
headTab.btnHScene.click()
assert headTab._editing == headTab.EDIT_HSCENE
assert headTab.editTextBox.isEnabled() is True
assert headTab.editTextBox.toPlainText() == shTitle
headTab.btnApply.click()
assert headTab.editTextBox.isEnabled() is False
# Section
headTab.btnSection.click()
assert headTab._editing == headTab.EDIT_SECTION
@@ -455,6 +466,11 @@ def testBuildSettings_Headings(qtbot: QtBot, nwGUI: GuiMain):
headTab.btnApply.click()
assert build.getStr("headings.fmtScene") == nwHeadFmt.TITLE
headTab.btnHScene.click()
headTab.editTextBox.setPlainText(nwHeadFmt.TITLE)
headTab.btnApply.click()
assert build.getStr("headings.fmtHardScene") == nwHeadFmt.TITLE
headTab.btnSection.click()
headTab.editTextBox.setPlainText(nwHeadFmt.TITLE)
headTab.btnApply.click()