mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
use new playwright locators
This commit is contained in:
@@ -5,7 +5,9 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import com.commafeed.CommaFeedDropwizardAppExtension;
|
||||
import com.microsoft.playwright.Locator;
|
||||
import com.microsoft.playwright.Page;
|
||||
import com.microsoft.playwright.assertions.PlaywrightAssertions;
|
||||
import com.microsoft.playwright.options.AriaRole;
|
||||
|
||||
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
|
||||
|
||||
@@ -17,10 +19,10 @@ class AuthentificationIT extends PlaywrightTestBase {
|
||||
@Test
|
||||
void loginFail() {
|
||||
page.navigate(getLoginPageUrl());
|
||||
page.locator("[placeholder='User Name or E-mail']").fill("admin");
|
||||
page.locator("[placeholder='Password']").fill("wrong_password");
|
||||
page.locator("button:has-text('Log in')").click();
|
||||
PlaywrightAssertions.assertThat(page.locator("div[role='alert']")).containsText("wrong username or password");
|
||||
page.getByPlaceholder("User Name or E-mail").fill("admin");
|
||||
page.getByPlaceholder("Password").fill("wrong_password");
|
||||
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Log in")).click();
|
||||
PlaywrightAssertions.assertThat(page.getByRole(AriaRole.ALERT)).containsText("wrong username or password");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -33,13 +35,13 @@ class AuthentificationIT extends PlaywrightTestBase {
|
||||
@Test
|
||||
void registerFailPasswordTooSimple() {
|
||||
page.navigate(getLoginPageUrl());
|
||||
page.locator("text=Sign up!").click();
|
||||
page.locator("[placeholder='User Name']").fill("user");
|
||||
page.locator("[placeholder='E-mail address']").fill("user@domain.com");
|
||||
page.locator("[placeholder='Password']").fill("pass");
|
||||
page.locator("button:has-text('Sign up')").click();
|
||||
page.getByText("Sign up!").click();
|
||||
page.getByPlaceholder("User Name").fill("user");
|
||||
page.getByPlaceholder("E-mail address").fill("user@domain.com");
|
||||
page.getByPlaceholder("Password").fill("pass");
|
||||
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign up")).click();
|
||||
|
||||
Locator alert = page.locator("div[role='alert']");
|
||||
Locator alert = page.getByRole(AriaRole.ALERT);
|
||||
PlaywrightAssertions.assertThat(alert).containsText("Password must be 8 or more characters in length.");
|
||||
PlaywrightAssertions.assertThat(alert).containsText("Password must contain 1 or more uppercase characters.");
|
||||
PlaywrightAssertions.assertThat(alert).containsText("Password must contain 1 or more digit characters.");
|
||||
@@ -49,11 +51,11 @@ class AuthentificationIT extends PlaywrightTestBase {
|
||||
@Test
|
||||
void registerSuccess() {
|
||||
page.navigate(getLoginPageUrl());
|
||||
page.locator("text=Sign up!").click();
|
||||
page.locator("[placeholder='User Name']").fill("user");
|
||||
page.locator("[placeholder='E-mail address']").fill("user@domain.com");
|
||||
page.locator("[placeholder='Password']").fill("MyPassword1!");
|
||||
page.locator("button:has-text('Sign up')").click();
|
||||
page.getByText("Sign up!").click();
|
||||
page.getByPlaceholder("User Name").fill("user");
|
||||
page.getByPlaceholder("E-mail address").fill("user@domain.com");
|
||||
page.getByPlaceholder("Password").fill("MyPassword1!");
|
||||
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign up")).click();
|
||||
PlaywrightAssertions.assertThat(page).hasURL("http://localhost:" + EXT.getLocalPort() + "/#/app/category/all");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user