/// <reference types="cypress" />
context('The login page', () => {

    describe.skip('Test the login page', () => {

        it('Access the webpage', function() {
            cy.visit('/login');
            cy.get('#email').should("have.attr", "type", "email");
            cy.get('#password').should("have.attr", "type", "password");
            //cy.get('#password').type(mdp);
        });
        
        it('Log a malformed email', function() {
            cy.visit('/login');
            cy.get('#email').type("not an email");
            cy.get('#password').type("somepasseword {enter}");
            cy.url().should('include', 'login?');
        });

        it('Log an unexisting user', function() {
            cy.visit('/login');
            cy.get('#email').type("toto@yopmail.com");
            cy.get('#password').type("somepasseword {enter}");
            cy.get('#error-message').should("have.class", "alert alert-danger").should("be.visible");
        });
        
    });

    /* describe("It send an SMS", function() {
        it('Log the candidate user', function(){
            cy.visit('/');
            cy.get('#email').type("candidature-qa@example.org");
            cy.get('#password').type("kHwWawhH5ADNuFb");
            cy.get('#continueButton').click();
            
            cy.mailosaurGetMessage(serverId, {
                sentTo: smsNumber
            }).as('sms'); 

            cy.wait(10000).then(() => {
                cy.get('#validateButton').click();
            });


        });
    });
    */
});

context("The inbox page", function() {
    describe("It check the inbox content", function() {
        before(() => {
            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();
            });
        });

        it("It load the inbox page of a valid user", ()=> {
            cy.visit("/request");
            cy.get("#dashboard-dropzone tr:first-child td").eq(1).click();
            cy.get("#sending-button").click();
        });

        it("It checks for messages in the inbox", () => {
            
        });

        it("Open the message for data that has been injected previously", () => {

        });

    });
});