mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
64 lines
2.8 KiB
Java
64 lines
2.8 KiB
Java
|
|
package com.commafeed.e2e;
|
||
|
|
|
||
|
|
import org.junit.jupiter.api.Test;
|
||
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||
|
|
|
||
|
|
import com.commafeed.CommaFeedApplication;
|
||
|
|
import com.commafeed.CommaFeedConfiguration;
|
||
|
|
import com.microsoft.playwright.Locator;
|
||
|
|
import com.microsoft.playwright.assertions.PlaywrightAssertions;
|
||
|
|
|
||
|
|
import io.dropwizard.testing.ResourceHelpers;
|
||
|
|
import io.dropwizard.testing.junit5.DropwizardAppExtension;
|
||
|
|
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
|
||
|
|
|
||
|
|
@ExtendWith(DropwizardExtensionsSupport.class)
|
||
|
|
class AuthentificationIT extends PlaywrightTestBase {
|
||
|
|
|
||
|
|
private static final DropwizardAppExtension<CommaFeedConfiguration> EXT = new DropwizardAppExtension<CommaFeedConfiguration>(
|
||
|
|
CommaFeedApplication.class, ResourceHelpers.resourceFilePath("config.test.yml"));
|
||
|
|
|
||
|
|
@Test
|
||
|
|
void loginFail() {
|
||
|
|
page.navigate("http://localhost:" + EXT.getLocalPort());
|
||
|
|
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");
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
void loginSuccess() {
|
||
|
|
page.navigate("http://localhost:" + EXT.getLocalPort());
|
||
|
|
PlaywrightTestUtils.login(page);
|
||
|
|
PlaywrightAssertions.assertThat(page).hasURL("http://localhost:" + EXT.getLocalPort() + "/#/app/category/all");
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
void registerFailPasswordTooSimple() {
|
||
|
|
page.navigate("http://localhost:" + EXT.getLocalPort());
|
||
|
|
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();
|
||
|
|
|
||
|
|
Locator alert = page.locator("div[role='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.");
|
||
|
|
PlaywrightAssertions.assertThat(alert).containsText("Password must contain 1 or more special characters.");
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
void registerSuccess() {
|
||
|
|
page.navigate("http://localhost:" + EXT.getLocalPort());
|
||
|
|
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();
|
||
|
|
PlaywrightAssertions.assertThat(page).hasURL("http://localhost:" + EXT.getLocalPort() + "/#/app/category/all");
|
||
|
|
}
|
||
|
|
}
|