import helpers.GetAccountProperties;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;

public class TestSafeway {

  Map<String, String> props = new GetAccountProperties().getProps();
  String email = props.get("email");
  String password = props.get("password");
  String firstName = props.get("firstName");
  String lastName = props.get("lastName");
  String phone = props.get("phone");

  public TestSafeway() throws IOException {
  }

  private static String getOS() {
    return System.getProperty("os.name");
  }

  @Test
  public void testSafewayLogin() {
    if (getOS().startsWith("Mac OS")) {
      System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver");
    }

    WebDriver driver = new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
    driver.get("https://www.safeway.com");

    HomePage homePage = new HomePage(driver);
    homePage.openRightNav();

    RightNavBar rightNavBar = new RightNavBar(driver);
    rightNavBar.openLogin();

    LoginPage loginPage = new LoginPage(driver);
    loginPage.login(email, password);

    homePage.openRightNav();
    rightNavBar.openAccountSettings();

    AccountSettingsPage accountSettingsPage = new AccountSettingsPage(driver);
    accountSettingsPage.confirmLogin(firstName, lastName, email, phone);

  }

}
