From 75508378c8a8d5cbcefd340d2afd1b92db809f7f Mon Sep 17 00:00:00 2001 From: Konstantin Hudyakov Date: Tue, 18 Jan 2022 19:34:08 +0300 Subject: [PATCH] [IFT] Add test script to Modal commit enabled warning It will fix UI tests if for some reason modal commit dialog is enabled by default. IJ-CR-19745 GitOrigin-RevId: 2a71ab9387367fa8d0ca239439f3f1193ee4a898 --- .../src/git4idea/ift/GitLessonsUtil.kt | 6 +++++ .../src/training/dsl/LessonUtil.kt | 22 ++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/plugins/git-features-trainer/src/git4idea/ift/GitLessonsUtil.kt b/plugins/git-features-trainer/src/git4idea/ift/GitLessonsUtil.kt index 8a512692e199..5e8e16a8833a 100644 --- a/plugins/git-features-trainer/src/git4idea/ift/GitLessonsUtil.kt +++ b/plugins/git-features-trainer/src/git4idea/ift/GitLessonsUtil.kt @@ -212,6 +212,12 @@ object GitLessonsUtil { + " " + GitLessonsBundle.message("git.click.to.change.settings", callbackId)) { !VcsApplicationSettings.getInstance().COMMIT_FROM_LOCAL_CHANGES } + test { + if (!VcsApplicationSettings.getInstance().COMMIT_FROM_LOCAL_CHANGES) { + Thread.sleep(1000) // need to wait until LessonMessagePane become updated after restart and warning will be showed + clickLessonMessagePaneLink(" click ") + } + } } } diff --git a/plugins/ide-features-trainer/src/training/dsl/LessonUtil.kt b/plugins/ide-features-trainer/src/training/dsl/LessonUtil.kt index 744b400783b9..086f8597d953 100644 --- a/plugins/ide-features-trainer/src/training/dsl/LessonUtil.kt +++ b/plugins/ide-features-trainer/src/training/dsl/LessonUtil.kt @@ -368,14 +368,20 @@ fun TaskContext.proceedLink(additionalAbove: Int = 0) { } addStep(gotIt) test { - ideFrame { - val linkText = "Click to proceed" - val lessonMessagePane = findComponentWithTimeout(defaultTimeout) { _: LessonMessagePane -> true } - val offset = lessonMessagePane.text.indexOf(linkText) - if (offset == -1) error("Not found '$linkText' in the LessonMessagePane") - val rect = lessonMessagePane.modelToView2D(offset + linkText.length / 2) - robot.click(lessonMessagePane, Point(rect.centerX.toInt(), rect.centerY.toInt())) - } + clickLessonMessagePaneLink("Click to proceed") + } +} + +/** + * Will click on the first occurrence of [linkText] in the [LessonMessagePane] + */ +fun TaskTestContext.clickLessonMessagePaneLink(linkText: String) { + ideFrame { + val lessonMessagePane = findComponentWithTimeout(defaultTimeout) { _: LessonMessagePane -> true } + val offset = lessonMessagePane.text.indexOf(linkText) + if (offset == -1) error("Not found '$linkText' in the LessonMessagePane") + val rect = lessonMessagePane.modelToView2D(offset + linkText.length / 2) + robot.click(lessonMessagePane, Point(rect.centerX.toInt(), rect.centerY.toInt())) } }