Skip to content

Commit

Permalink
Save 2 seconds by clicking redirect link directly in a test
Browse files Browse the repository at this point in the history
It can be done because this has been fixed in 8fe4a22.

And fix the redirection not working properly if the link is clicked.
Fixed by explicitly setting `window.href`.
  • Loading branch information
cbliard committed Sep 6, 2024
1 parent d4d6d59 commit 4a66d91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class JobStatusPollingController extends Controller<HTMLElement>

interval:ReturnType<typeof setInterval>;
userInteraction:boolean = false;
redirectHref:string;

connect() {
this.interval = setInterval(() => this.frameTarget.reload(), 2000);
Expand Down Expand Up @@ -42,9 +43,11 @@ export default class JobStatusPollingController extends Controller<HTMLElement>

redirectClick(_:Event) {
this.userInteraction = true;
window.location.href = this.redirectHref;
}

redirectTargetConnected(element:HTMLLinkElement) {
this.redirectHref = element.href;
setTimeout(() => {
this.userInteraction = true;
window.location.href = element.href;
Expand Down
5 changes: 2 additions & 3 deletions spec/features/work_packages/bulk/move_work_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@
#
# The following lines wait for this job status dialog to be discarded.
expect(page).to have_text "Successful update."
# Clicking the link directly would save 2 seconds, but there is a bug
# which redirects back. Sleep 2 seconds instead until it's fixed
sleep 2 # TODO replace with: click_on(I18n.t("job_status_dialog.redirect_link"))
# Clicking the link directly to save the 2 seconds of auto-click
click_on(I18n.t("job_status_dialog.redirect_link"))

expect(page).to have_current_path "/projects/#{project2.identifier}/work_packages/#{work_package.id}/activity"
page.find_by_id("projects-menu", text: "Target")
Expand Down

0 comments on commit 4a66d91

Please sign in to comment.