From 486907caa3190756da4b2aeab8da78a49d5d45c6 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Tue, 5 Nov 2024 19:01:55 +0100 Subject: [PATCH] tests: test for #558 added --- src/test/kotlin/features/glue/ActionsSteps.kt | 10 ++++++ src/test/kotlin/features/glue/FilesSteps.kt | 9 +++++ .../indent_on_new_line_typing.feature | 35 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/test/resources/features/formatter/indent_on_new_line_typing.feature diff --git a/src/test/kotlin/features/glue/ActionsSteps.kt b/src/test/kotlin/features/glue/ActionsSteps.kt index 1c26009d..2c297eeb 100644 --- a/src/test/kotlin/features/glue/ActionsSteps.kt +++ b/src/test/kotlin/features/glue/ActionsSteps.kt @@ -52,6 +52,16 @@ import kotlin.test.* class ActionsSteps { + @When("^I type multiline text '(.+)' at the caret position$") + fun iTypeTextAtCaret(text: String) { + val application = ApplicationManager.getApplication() + application.invokeAndWait({ + SnakemakeWorld.fixture().type( + text.replace("\\n\\r", "\n").replace("\\n", "\n") + ) + }, ModalityState.nonModal()) + } + @When("^I expect inspection (error|warning|info|TYPO|weak warning) on <([^>]+)> with message$") fun iExpectInspectionOn(level: String, signature: String, message: String) { iExpectInspectionOnIn(level, signature, signature, message) diff --git a/src/test/kotlin/features/glue/FilesSteps.kt b/src/test/kotlin/features/glue/FilesSteps.kt index 1b6b10d0..650ebcf2 100644 --- a/src/test/kotlin/features/glue/FilesSteps.kt +++ b/src/test/kotlin/features/glue/FilesSteps.kt @@ -35,6 +35,15 @@ class FilesSteps { createAndAddFile(name, text) } + @Given("^I expect text in current file:$") + fun iExpectTextInCurrentFile(text: String) { + ApplicationManager.getApplication().invokeAndWait({ + val actualText = SnakemakeWorld.fixture().editor.document.text + assertEquals(text, actualText) + }) + } + + @Given("snakemake framework api yaml descriptor is$") fun snakemakeFrameworkApiInfoContent(text: String) { ApplicationManager.getApplication().invokeAndWait({ diff --git a/src/test/resources/features/formatter/indent_on_new_line_typing.feature b/src/test/resources/features/formatter/indent_on_new_line_typing.feature new file mode 100644 index 00000000..1f31316e --- /dev/null +++ b/src/test/resources/features/formatter/indent_on_new_line_typing.feature @@ -0,0 +1,35 @@ +Feature: Check indent after newline symbol typing + Scenario: New line in section in the middle of file + Given a snakemake project + Given I open a file "foo.smk" with text + """ + rule foo: + input: "foo/{sample}" + # formatter hack + """ + And I put the caret after "foo/{sample}" + When I type multiline text '\noutput: "boo/{sample}"' at the caret position + Then I expect text in current file: + """ + rule foo: + input: "foo/{sample}" + output: "boo/{sample}" + # formatter hack + """ + + @ignore + Scenario: New line in section in the end of file + Given a snakemake project + Given I open a file "foo.smk" with text + """ + rule foo: + input: "foo/{sample}" + """ + And I put the caret after "foo/{sample}" + When I type multiline text '\noutput: "boo/{sample}"' at the caret position + Then I expect text in current file: + """ + rule foo: + input: "foo/{sample}" + output: "boo/{sample}" + """ \ No newline at end of file