From ceadd52d1ade7b7a20bf37e7b759acb5654bc412 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 18 May 2025 22:37:15 +0200 Subject: [PATCH] Update tests --- sample/content/636b6aa9b697b.nwd | 5 ++- sample/nwProject.nwx | 6 +-- tests/test_core/test_core_indexdata.py | 9 ++++ tests/test_gui/test_gui_doceditor.py | 60 +++++++++++++++++++++++++- 4 files changed, 74 insertions(+), 6 deletions(-) diff --git a/sample/content/636b6aa9b697b.nwd b/sample/content/636b6aa9b697b.nwd index 5fd4bb76..e3d4bfde 100644 --- a/sample/content/636b6aa9b697b.nwd +++ b/sample/content/636b6aa9b697b.nwd @@ -1,8 +1,8 @@ %%~name: Making a Scene %%~path: 6a2d6d5f4f401/636b6aa9b697b %%~kind: NOVEL/DOCUMENT -%%~hash: c057a5e9309b0e764c367b0fe9ab0607e3308622 -%%~date: Unknown/2025-04-08 20:10:33 +%%~hash: 1f3d98a6a27b4f9a7f2239fcd78f9e2263cd3b97 +%%~date: Unknown/2025-05-18 22:36:59 ### Making a Scene @pov: Jane @@ -11,6 +11,7 @@ @mention: Space %Story.Resolution: You can describe the scene structure with story comments. +%Note.Consistency: You can also make notes about things like consistency of the story. A scene is defined by a level three heading, like the one at the top of this page. The scene will be assigned to the chapter preceding it in the project tree. The scene document can be sorted after the chapter document, or as a child of the chapter. Both result in the same output in the end, so it is a matter of preference. diff --git a/sample/nwProject.nwx b/sample/nwProject.nwx index d20ba88e..b6fa62e7 100644 --- a/sample/nwProject.nwx +++ b/sample/nwProject.nwx @@ -1,6 +1,6 @@ - - + + Sample Project Jane Smith @@ -58,7 +58,7 @@ Chapter One - + Making a Scene diff --git a/tests/test_core/test_core_indexdata.py b/tests/test_core/test_core_indexdata.py index 9e1080f8..5bf45c8a 100644 --- a/tests/test_core/test_core_indexdata.py +++ b/tests/test_core/test_core_indexdata.py @@ -224,6 +224,14 @@ def testCoreIndexData_IndexHeading(): "story.crisis": "It exploded!", } + # Set Note Comment + head.setComment(nwComment.NOTE.name, "consitency", "Only explode once") + assert head.comments == { + "summary": "In the beginning ...", + "story.crisis": "It exploded!", + "note.consitency": "Only explode once", + } + # Set Tag head.setTag("Stuff") assert head.tag == "stuff" # Case insensitive @@ -240,6 +248,7 @@ def testCoreIndexData_IndexHeading(): "refs": {"stuff": "@object"}, "summary": "In the beginning ...", "story.crisis": "It exploded!", + "note.consitency": "Only explode once", } # Unpack KeyError diff --git a/tests/test_gui/test_gui_doceditor.py b/tests/test_gui/test_gui_doceditor.py index b198a71a..5bda2d82 100644 --- a/tests/test_gui/test_gui_doceditor.py +++ b/tests/test_gui/test_gui_doceditor.py @@ -1877,10 +1877,68 @@ def testGuiEditor_Completer(qtbot, nwGUI, projPath, mockRnd): qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY) qtbot.keyClick(completer, Qt.Key.Key_Return, delay=KEY_DELAY) qtbot.keyClick(completer, Qt.Key.Key_Escape, delay=KEY_DELAY) + qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY) assert docEditor.getText() == ( "### Scene One\n\n" "@char: Jane\n" - "@focus: John" + "@focus: John\n" + ) + + # Send keypresses to the completer object for a comment + qtbot.keyClick(docEditor, "%", delay=KEY_DELAY) + assert len(completer.actions()) == 4 + qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY) + qtbot.keyClick(completer, Qt.Key.Key_Return, delay=KEY_DELAY) + qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY) + assert docEditor.getText() == ( + "### Scene One\n\n" + "@char: Jane\n" + "@focus: John\n" + "%Synopsis: \n" + ) + + # Auto-complete story comment + SHARED.project.index._itemIndex._cache.story.add("Resolution") + qtbot.keyClick(docEditor, "%", delay=KEY_DELAY) + assert len(completer.actions()) == 4 + qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY) + qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY) + qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY) + qtbot.keyClick(completer, Qt.Key.Key_Return, delay=KEY_DELAY) + qtbot.keyClick(completer, ".", delay=KEY_DELAY) + assert len(completer.actions()) == 1 + qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY) + qtbot.keyClick(completer, Qt.Key.Key_Return, delay=KEY_DELAY) + qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY) + assert docEditor.getText() == ( + "### Scene One\n\n" + "@char: Jane\n" + "@focus: John\n" + "%Synopsis: \n" + "%Story.Resolution: \n" + ) + + # Auto-complete note comment + SHARED.project.index._itemIndex._cache.note.add("Consistency") + qtbot.keyClick(docEditor, "%", delay=KEY_DELAY) + assert len(completer.actions()) == 4 + qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY) + qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY) + qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY) + qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY) + qtbot.keyClick(completer, Qt.Key.Key_Return, delay=KEY_DELAY) + qtbot.keyClick(completer, ".", delay=KEY_DELAY) + assert len(completer.actions()) == 1 + qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY) + qtbot.keyClick(completer, Qt.Key.Key_Return, delay=KEY_DELAY) + qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY) + assert docEditor.getText() == ( + "### Scene One\n\n" + "@char: Jane\n" + "@focus: John\n" + "%Synopsis: \n" + "%Story.Resolution: \n" + "%Note.Consistency: \n" ) # qtbot.stop()