package cz.moneta.test.dsl.ufo.ufoframework.tasks;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.common.authentication.UfoLoginPage;
import cz.moneta.test.dsl.ufo.ufoframework.pages.HLP901_S001_MainMenuPage;
import cz.moneta.test.harness.support.auth.Credentials;

import java.util.function.Function;

public class LoginTasks {

    private final Harness harness;

    public LoginTasks(Harness harness) {
        this.harness = harness;
    }

    public Function<UfoLoginPage, HLP901_S001_MainMenuPage> withCredentials(Credentials credentials) {
        return start -> start
                .typeUserNameAndPasswordAndClickLogin(credentials.getUsername(), credentials.getPassword())
                .onApplicationSelectPage()
                .selectUfoFunctionalTestsAndContinue();
    }

    public Function<UfoLoginPage, HLP901_S001_MainMenuPage> withCredentialsAndSelectFirstOM(Credentials credentials) {
        return start -> start
                .typeUserNameAndPasswordAndClickLogin(credentials.getUsername(), credentials.getPassword())
                .onApplicationSelectPage()
                .selectFirstOmIfPresent()
                .selectUfoFunctionalTestsAndContinue();
    }
}
