/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.adullact.iparapheur.it;

/**
 *
 * @author vbarousse
 */
public class SecretariatTest extends ParapheurIntegrationTestCase {

    public void testEnvoiSecretariat() {
        selenium.open(CONTEXT_PATH + "/faces/jsp/parapheur/login.jsp");
        selenium.type("loginForm:user-name", "SampleUser");
        selenium.type("loginForm:user-password", "secret");
        selenium.click("loginForm:submit");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Constituer un nouveau dossier");
        selenium.waitForPageToLoad("30000");
        selenium.type("infos:name", "test-secretariat");
        selenium.fireEvent("infos:name", "keyup");
        selenium.type("infos:_idJsp21", "annotation-publique");
        selenium.click("infos:next-button-infos");
        selenium.waitForPageToLoad("30000");
        selenium.type("alfFileInput", getTempFile().getAbsolutePath());
        selenium.click("//input[@value='Valider']");
        selenium.waitForPageToLoad("30000");
        selenium.click("add-content-upload-end:next-button");
        selenium.waitForPageToLoad("30000");
        selenium.click("ajout_circuit:select_soustypesmetier-button");
        selenium.waitForPageToLoad("30000");
        selenium.click("ajout_circuit:next-button-circuit");
        selenium.waitForPageToLoad("30000");
        selenium.click("person-props:_idJsp23");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Dossiers à transmettre");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=test-secretariat");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Envoyer au secrétariat");
        selenium.waitForPageToLoad("30000");
        selenium.type("dialog:dialog-body:textArea2", "annotation-privée");
        selenium.click("dialog:finish-button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Dossiers à relire - annoter");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isTextPresent("test-secretariat"));
        selenium.click("logout");
        selenium.waitForPageToLoad("30000");
        selenium.type("loginForm:user-name", "SampleSecretaire");
        selenium.type("loginForm:user-password", "secret");
        selenium.click("loginForm:submit");
        selenium.waitForPageToLoad("30000");
        selenium.click("_idJsp7");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Dossiers à relire - annoter");
        selenium.waitForPageToLoad("30000");
        selenium.click("_idJsp14");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Options du dossier");
        selenium.click("link=Visualiser les annotations");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isTextPresent("annotation-privée"));
        selenium.click("browse-annotations:btnClose");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Envoyer à mon patron");
        selenium.waitForPageToLoad("30000");
        selenium.type("dialog:dialog-body:textArea2", "annotation-privée-modifiée");
        selenium.click("dialog:finish-button");
        selenium.waitForPageToLoad("30000");
        selenium.click("logout");
        selenium.waitForPageToLoad("30000");
        selenium.type("loginForm:user-name", "SampleUser");
        selenium.type("loginForm:user-password", "secret");
        selenium.click("loginForm:submit");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Dossiers à transmettre");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=test-secretariat");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Options du dossier");
        selenium.click("link=Visualiser les annotations");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isTextPresent("annotation-privée-modifiée"));
    }

    public void testNewDossier() {
        selenium.open(CONTEXT_PATH + "/faces/jsp/parapheur/login.jsp");
        selenium.type("loginForm:user-name", "SampleSecretaire");
        selenium.type("loginForm:user-password", "secret");
        selenium.click("loginForm:submit");
        selenium.waitForPageToLoad("30000");
        selenium.click("_idJsp7");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Constituer un nouveau dossier");
        selenium.waitForPageToLoad("30000");
        selenium.type("infos:name", "test-secretaire-nouveau-dossier");
        selenium.fireEvent("infos:name", "keyup");
        selenium.click("infos:next-button-infos");
        selenium.waitForPageToLoad("30000");
        selenium.type("alfFileInput", getTempFile().getAbsolutePath());
        selenium.click("//input[@value='Valider']");
        selenium.waitForPageToLoad("30000");
        selenium.click("add-content-upload-end:next-button");
        selenium.waitForPageToLoad("30000");
        selenium.click("ajout_circuit:select_soustypesmetier-button");
        selenium.waitForPageToLoad("30000");
        selenium.click("ajout_circuit:next-button-circuit");
        selenium.waitForPageToLoad("30000");
        selenium.click("person-props:_idJsp23");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Dossiers à relire - annoter");
        selenium.waitForPageToLoad("30000");
        selenium.click("_idJsp14");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Envoyer à mon patron");
        selenium.waitForPageToLoad("30000");
        selenium.click("dialog:finish-button");
        selenium.waitForPageToLoad("30000");
        selenium.click("logout");
        selenium.waitForPageToLoad("30000");
        selenium.type("loginForm:user-name", "SampleUser");
        selenium.type("loginForm:user-password", "secret");
        selenium.click("loginForm:submit");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Dossiers à transmettre");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isTextPresent("test-secretaire-nouveau-dossier"));
    }
}
