Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.jenkins.plugins.pipelinegraphview;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;

import com.microsoft.playwright.Locator;
import com.microsoft.playwright.Locator.WaitForOptions;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.junit.UsePlaywright;
import com.microsoft.playwright.options.AriaRole;
import com.microsoft.playwright.options.WaitForSelectorState;
import hudson.model.Result;
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
Expand Down Expand Up @@ -37,17 +35,15 @@ void cancelButtonCancelsBuild(Page p, JenkinsConfiguredWithCodeRule j) throws Ex
.goToBuild()
.goToPipelineOverview();

assertTrue(p.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Cancel"))
.isVisible());
Locator cancelLocator = p.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Cancel"));
assertThat(cancelLocator).isVisible();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't seem to be any waiting here, (except the one wait for hidden that is removed), could you explain this a bit? the isVisible and isHidden checks you've added won't wait for them to be true as far as I can tell?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I remember in the docs, the assertions retry/wait automatically. I'll double check tomorrow though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, Time to retry the assertion for in milliseconds. Defaults to 5000.


op.cancel();

SemaphoreStep.success("wait/1", null);
j.assertBuildStatus(Result.ABORTED, j.waitForCompletion(run));

Locator cancelLocator = p.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Cancel"));
cancelLocator.waitFor(new WaitForOptions().setState(WaitForSelectorState.HIDDEN));
assertTrue(cancelLocator.isHidden());
assertThat(cancelLocator).isHidden();
}

@Test
Expand All @@ -63,14 +59,12 @@ void cancelButtonDisappears(Page p, JenkinsConfiguredWithCodeRule j) throws Exce
.goToBuild()
.goToPipelineOverview();

assertTrue(p.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Cancel"))
.isVisible());
Locator cancelLocator = p.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Cancel"));
assertThat(cancelLocator).isVisible();

SemaphoreStep.success("wait/1", null);
j.assertBuildStatus(Result.SUCCESS, j.waitForCompletion(run));

Locator cancelLocator = p.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Cancel"));
cancelLocator.waitFor(new WaitForOptions().setState(WaitForSelectorState.HIDDEN));
assertTrue(cancelLocator.isHidden());
assertThat(cancelLocator).isHidden();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ public PipelineOverviewPage configure() {
}

public PipelineOverviewPage cancel() {
page.click("#pgv-cancel");
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Yes"))
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Cancel"))
.click();
Locator dialog = page.getByRole(AriaRole.DIALOG);
dialog.getByText("Yes").click();
assertThat(dialog).isHidden();
return this;
}

Expand Down