Skip to content

Commit

Permalink
Build basic auth login test
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Jul 19, 2024
1 parent 560f525 commit acddc14
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.tmail.robots;

import com.microsoft.playwright.Page;
import com.tmail.base.CoreRobot;

public class BasicAuthLoginRobot extends CoreRobot {

public BasicAuthLoginRobot(Page page) {
super(page);
}

public void enterUsername(String username) {
page.locator("#email").fill(username);
}

public void enterPassword(String password) {
page.locator("input[aria-label='password']").click();
page.waitForTimeout(1000);
page.locator("input[aria-label='password']").fill(password);
}

public void clickLogin() {
page.getByText("Sign in").last().click();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.microsoft.playwright.Page;
import com.tmail.base.CoreRobot;

public class LoginRobot extends CoreRobot {
public class OidcLoginRobot extends CoreRobot {

public LoginRobot(Page page) {
public OidcLoginRobot(Page page) {
super(page);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.tmail.scenarios;

import com.microsoft.playwright.Page;
import com.tmail.base.BaseScenario;
import com.tmail.robots.BasicAuthLoginRobot;
import com.tmail.robots.HomeRobot;
import com.tmail.robots.MailboxDashboardRobot;

public class BasicAuthLoginScenario extends BaseScenario {
String testUrl;
String username;
String password;

public BasicAuthLoginScenario(String testUrl, String username, String password) {
this.testUrl = testUrl;
this.username = username;
this.password = password;
}

@Override
public void execute(Page page) {
HomeRobot homeRobot = new HomeRobot(page);
BasicAuthLoginRobot loginRobot = new BasicAuthLoginRobot(page);
MailboxDashboardRobot mailboxDashboardRobot = new MailboxDashboardRobot(page);

homeRobot.navigateToTestSite(testUrl);

loginRobot.enterUsername(username);
loginRobot.enterPassword(password);
loginRobot.clickLogin();

mailboxDashboardRobot.waitUntilExactLabelIsVisible("Compose");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void execute(Page page) {
MailboxDashboardRobot mailboxDashboardRobot = new MailboxDashboardRobot(page);
ComposerRobot composerRobot = new ComposerRobot(page);

LoginScenario loginUseCase = new LoginScenario(testUrl, username, password);
OidcLoginScenario loginUseCase = new OidcLoginScenario(testUrl, username, password);
loginUseCase.execute(page);

mailboxDashboardRobot.openComposer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import com.microsoft.playwright.Page;
import com.tmail.base.BaseScenario;
import com.tmail.robots.HomeRobot;
import com.tmail.robots.LoginRobot;
import com.tmail.robots.MailboxDashboardRobot;
import com.tmail.robots.OidcLoginRobot;

public class LoginScenario extends BaseScenario {
public class OidcLoginScenario extends BaseScenario {
String testUrl;
String username;
String password;

public LoginScenario(String testUrl, String username, String password) {
public OidcLoginScenario(String testUrl, String username, String password) {
this.testUrl = testUrl;
this.username = username;
this.password = password;
Expand All @@ -20,7 +20,7 @@ public LoginScenario(String testUrl, String username, String password) {
@Override
public void execute(Page page) {
HomeRobot homeRobot = new HomeRobot(page);
LoginRobot loginRobot = new LoginRobot(page);
OidcLoginRobot loginRobot = new OidcLoginRobot(page);
MailboxDashboardRobot mailboxDashboardRobot = new MailboxDashboardRobot(page);

homeRobot.navigateToTestSite(testUrl);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.tmail.preprod.basic_auth.login;

import com.tmail.base.TestBase;
import com.tmail.scenarios.BasicAuthLoginScenario;

public class BasicAuthLoginTest extends TestBase {
BasicAuthLoginTest() {
scenario = new BasicAuthLoginScenario(
properties.getProperty("app.basicAuthUrl"),
properties.getProperty("user.name"),
properties.getProperty("user.password"));
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.tmail.preprod.oidc.login;

import com.tmail.base.TestBase;
import com.tmail.scenarios.LoginScenario;
import com.tmail.scenarios.OidcLoginScenario;

public class LoginTest extends TestBase {
public class OidcLoginTest extends TestBase {

LoginTest() {
scenario = new LoginScenario(
OidcLoginTest() {
scenario = new OidcLoginScenario(
properties.getProperty("app.hostUrl"),
properties.getProperty("user.name"),
properties.getProperty("user.password"));
Expand Down

0 comments on commit acddc14

Please sign in to comment.