package cz.moneta.test.dsl.oauth2.web;

import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.oauth2.web.ApproveAccessToAccountPage.MONETA_LOGO_IMG;

@Wait(MONETA_LOGO_IMG)
public interface ApproveAccessToAccountPage extends WebFlow<Oauth2WebTransitions> {

    String MONETA_LOGO_IMG = "//img[@alt='MONETA logo']";
    String YES_APPROVE_ACCESS_BUTTON = "//button[@testid='button']/span[contains(text(),'Chci pokračovat') or contains(text(), 'Continue')]";
    String ID_INPUT = "//input[@name='id']";
    String PASSWORD_INPUT = "//input[@name='password']";
    String SUBMIT_MOBIL_KEY_SEND_BUTTON = "//button[@type='submit']/span[contains(text(),'Odeslat mobilní klíč') or contains(text(), 'Send mobile key')]";
    String SUBMIT_APPROVE_ACCESS_BUTTON = "//button[@type='submit']/span[contains(text(),'Udělit přístup') or contains(text(), 'Grant access')]";
    String SMS_KEY_INPUT = "//input[@name='smsKey']";

    @Click(value = YES_APPROVE_ACCESS_BUTTON, andWait = @Wait(ID_INPUT))
    ApproveAccessToAccountPage clickYesApproveButton();

    @TypeInto(ID_INPUT)
    ApproveAccessToAccountPage fillIdInput(String id);

    @TypeInto(PASSWORD_INPUT)
    ApproveAccessToAccountPage fillPasswordInput(String password);

    @TypeInto(SMS_KEY_INPUT)
    ApproveAccessToAccountPage fillSmsKey(String smsKey);

    @Click(value = SUBMIT_MOBIL_KEY_SEND_BUTTON, andWait = @Wait(SUBMIT_APPROVE_ACCESS_BUTTON))
    ApproveAccessToAccountPage clickSendMobileKey();

    @Click(SUBMIT_APPROVE_ACCESS_BUTTON)
    @Page(ThirdPartyApplicationPageWithToken.class)
    ThirdPartyApplicationPageWithToken clickApproveAccessButton();
}
