Skip to content

Commit

Permalink
Avoid premature navigation when clicking the admin cog
Browse files Browse the repository at this point in the history
To reproduce this here, we would need to slow down the browser network.
We'd need Selenium 4 for that.
So for now, it's a fix without a test, sorry!
  • Loading branch information
dagguh committed Jun 18, 2024
1 parent b2e60ef commit 0e5512a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Dropping a requirement of a major version of a dependency is a new contract.
## [Unreleased]
[Unreleased]: https://github.com/atlassian/jira-actions/compare/release-3.28.0...master

### Fixed
- Avoid premature navigation when clicking the administration cog.

## [3.28.0] - 2024-06-17
[3.28.0]: https://github.com/atlassian/jira-actions/compare/release-3.27.0...release-3.28.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.atlassian.performance.tools.jiraactions.api
import com.atlassian.performance.tools.jiraactions.administration.JiraAdministrationMenu
import com.atlassian.performance.tools.jiraactions.api.page.*
import org.openqa.selenium.By
import org.openqa.selenium.JavascriptExecutor
import org.openqa.selenium.WebDriver
import org.openqa.selenium.support.ui.ExpectedCondition
import java.net.URI
import java.net.URLEncoder

Expand Down Expand Up @@ -108,8 +110,26 @@ data class WebJira(

internal fun administrate(): JiraAdministrationMenu {
NotificationPopUps(driver).waitUntilAuiFlagsAreGone()
driver.findElement(By.id("admin_menu")).click()
val adminCog = By.id("admin_menu")
waitForAdminCog()
driver.findElement(adminCog).click()
val menu = driver.findElement(By.id("system-admin-menu-content"))
return JiraAdministrationMenu(driver, menu)
}

/**
* If we click on the administration cog too fast
* we would navigate to `plugins/servlet/applications/versions-licenses`
* and be asked for websudo password [AdminAccess].
*/
private fun waitForAdminCog() = waitForDomComplete()

private fun waitForDomComplete() {
val js = driver as JavascriptExecutor
val domComplete = ExpectedCondition {
val state = js.executeScript("return document.readyState") as String?
state == "complete"
}
driver.wait(domComplete)
}
}

0 comments on commit 0e5512a

Please sign in to comment.