Skip to content

Commit

Permalink
Merge pull request #8970 from rundeck/RSE-1043-improve-test-click-on-…
Browse files Browse the repository at this point in the history
…gutter-and-refresh-should-highlight-correct-line

RSE-1043 Improve test "click on gutter and refresh should highlight correct line"
  • Loading branch information
Jesus-Osuna-M committed Mar 4, 2024
2 parents a4909a7 + f50d1f6 commit 28673e4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,45 +48,34 @@ class LogViewerOutputSpec extends SeleniumBase{

def "click on gutter and refresh should highlight correct line"() {

setup:
given:
def loginPage = page LoginPage
def sideBar = page SideBarPage
def jobListPage = page JobsListPage
def jobCreatePage = page JobCreatePage
def projectHomePage = page HomePage
def jobShowPage = page JobShowPage

when:
when: "We run the job to have multiple lines in log output"
loginPage.go()
loginPage.login(TEST_USER, TEST_PASS)
projectHomePage.validatePage()
projectHomePage.goProjectHome(longOutPutProjectName)
sideBar.goTo(NavLinkTypes.JOBS)
jobListPage.getCreateJobLink().click()
jobCreatePage.getJobNameField().sendKeys("loop job")
jobCreatePage.getTab(JobTab.WORKFLOW).click()
jobCreatePage.getStepByType(StepName.COMMAND, StepType.NODE).click()
jobCreatePage.waitForStepToBeShown(By.name("pluginConfig.adhocRemoteString"))
jobCreatePage.el(By.name("pluginConfig.adhocRemoteString")).sendKeys("for i in {1..6}; do echo NUMBER \$i; sleep 0.5; done")
jobCreatePage.getSaveStepButton().click()
jobCreatePage.waitForSavedStep(0)
jobCreatePage.getCreateButton().click()
jobShowPage.goToJob("f44481c4-159d-4176-869b-e4a9bd898fe4")
jobShowPage.getRunJobBtn().click()
jobShowPage.getLogOutputBtn().click()
jobShowPage.waitForLogOutput(By.xpath("//span[contains(text(),'NUMBER ')]"),3,5)
def lineToClick = jobShowPage.el(By.xpath("//span[contains(text(),'NUMBER 1')]/ancestor::div[contains(@class, 'execution-log__line')]/div[@class='execution-log__gutter']"))

jobShowPage.waitForLogOutput(By.xpath("//span[contains(text(),'test output ')]"),9,5)
def lineToClick = jobShowPage.el(By.xpath("//span[contains(text(),'test output 5')]/ancestor::div[contains(@class, 'execution-log__line')]/div[@class='execution-log__gutter']"))
lineToClick.click();
jobShowPage.waitForUrlToContain("#outputL1")
def checkAfterClick = jobShowPage.waitForUrlToContain("#outputL5")
driver.navigate().refresh();
// def href = commandPage.runningButtonLink().getAttribute("href")
// jobShowPage.driver.get href + "#outputL1"

jobShowPage.waitForLogOutput(By.xpath("//span[contains(text(),'NUMBER ')]"),3,5)
def checkAfterRefresh = jobShowPage.waitForUrlToContain("#outputL5")
def selectedLine = jobShowPage.waitForElementVisible(By.xpath("//div[contains(@class, 'execution-log__line--selected')]")).isDisplayed()

then:
def selectedLine = jobShowPage.waitForElementVisible(By.xpath("//div[contains(@class, 'execution-log__line--selected')]"))

assert selectedLine != null : "Expected at least one element with the specified class to be present"
verifyAll {
checkAfterClick
checkAfterRefresh
selectedLine
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ abstract class BasePage {
.until(ExpectedConditions.presenceOfElementLocated(locator))
}

void waitForUrlToContain(String text) {
boolean waitForUrlToContain(String text) {
new WebDriverWait(context.driver, Duration.ofSeconds(30))
.until(ExpectedConditions.urlContains(text))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<joblist>
<job>
<defaultTab>nodes</defaultTab>
<description></description>
<executionEnabled>true</executionEnabled>
<id>f44481c4-159d-4176-869b-e4a9bd898fe4</id>
<loglevel>INFO</loglevel>
<name>output job</name>
<nodeFilterEditable>false</nodeFilterEditable>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<schedules />
<sequence keepgoing='false' strategy='node-first'>
<command>
<script><![CDATA[#!/bin/bash
for (( i=1; i<=10; i++ ))
do
echo "test output $i"
done]]></script>
<scriptargs />
</command>
</sequence>
<uuid>f44481c4-159d-4176-869b-e4a9bd898fe4</uuid>
</job>
</joblist>

0 comments on commit 28673e4

Please sign in to comment.