/* global Given, When, Then */
import { Given, When, Then, And, Before } from "cypress-cucumber-preprocessor/steps";

describe("Send a document", () => {

    Given("I am connected to my mailbox", () => {
        cy.visit('/');
        cy.get('#email').type("candidature-qa@example.org");
        cy.get('#password').type("kHwWawhH5ADNuFb");
        cy.get('#continueButton').click();
        cy.wait(20000).then(() => {
            cy.get('#validateButton').click();
        });
        cy.visit("/request");

    })

    And("I have a document ready to send", () => {
        cy.get("#dashboard-dropzone tr:first-child td").eq(1).click();
    });

    When("I send the mail", () => {
        cy.get("#sending-button").click();
    });

    Then("The mail is sent", () => {
        //?
    });

});

describe("Connect to the mailbox", () => {

    Given("I log with my credentials", () => {
        cy.visit('/');
        cy.get('#email').type("candidature-qa@example.org");
        cy.get('#password').type("kHwWawhH5ADNuFb");
        cy.get('#continueButton').click();
    });

    And("I receive a code by SMS", () => {
        cy.get("#challenge_mfa_form_candidate_otp").should("be.visible");
    });

    When("I put the code", () => {
        cy.wait(20000).then(() => {
            cy.get('#validateButton').click();
        });
    });

    Then("I am connected", () => {
        cy.get("#account-menu div[title]").should((elm) => {
            expect(elm).to.contain("candidature-qa@example.org")
        });
    });

})
