package cz.moneta.test.regression.backoffice.exevido.web.mailroom;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.credentials.Keys;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;

import static cz.moneta.test.dsl.util.task.ufo.cb.CommercialTasks.JIRA_COMMENT_STORE_KEY;

@TestScenario(name = "Download ZFO")
public class DownloadZFO {

    private String messageZfoId;

    @BeforeAll
    protected void setUp(Harness harness) {
        messageZfoId = harness.getConfig("commercial.exevido.message-zfo-id");
    }

    @TestCase(name = "Download ZFO")
    @JiraTestCase(id = "BOC-T9015")
    public void downloadZFO(Harness harness, @Key(Keys.exevido.mailroom) Credentials credentials) {
        harness.withExevido()
                .openLoginPage()
                .then(harness.tasks().exevidoTasks().login().withCredentialsToMss(credentials))
                .clickAllIncomingMessages()
                .searchByMessageId(messageZfoId)
                .clickIncomingMessageRow(30)
                .clickMoreInformation()
                .downloadZfoDeliveryReceipt()
                .downloadZfo();
    }

    @AfterEach
    protected void tearDown(Harness harness) {
        harness.store(JIRA_COMMENT_STORE_KEY,
                "\nMessage ID: " + messageZfoId);
    }
}