This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic tests for html file upload. Adds a very basic list of source strings from the editor page and verifies the text.
- Loading branch information
1 parent
74eee0b
commit afbf5cc
Showing
4 changed files
with
165 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
functional-test/src/test/java/org/zanata/feature/document/HTMLDocumentTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the | ||
* @author tags. See the copyright.txt file in the distribution for a full | ||
* listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this software; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF | ||
* site: http://www.fsf.org. | ||
*/ | ||
package org.zanata.feature.document; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.zanata.feature.DetailedTest; | ||
import org.zanata.page.projects.ProjectSourceDocumentsPage; | ||
import org.zanata.page.webtrans.EditorPage; | ||
import org.zanata.util.CleanDocumentStorageRule; | ||
import org.zanata.util.SampleProjectRule; | ||
import org.zanata.util.TestFileGenerator; | ||
import org.zanata.workflow.BasicWorkFlow; | ||
import org.zanata.workflow.LoginWorkFlow; | ||
|
||
import java.io.File; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.zanata.util.FunctionalTestHelper.assumeFalse; | ||
|
||
/** | ||
* @author Damian Jansen <a | ||
* href="mailto:djansen@redhat.com">djansen@redhat.com</a> | ||
*/ | ||
@Category(DetailedTest.class) | ||
public class HTMLDocumentTypeTest { | ||
@Rule | ||
public SampleProjectRule sampleProjectRule = new SampleProjectRule(); | ||
|
||
@Rule | ||
public CleanDocumentStorageRule documentStorageRule = | ||
new CleanDocumentStorageRule(); | ||
|
||
private TestFileGenerator testFileGenerator = new TestFileGenerator(); | ||
private String documentStorageDirectory; | ||
|
||
@Before | ||
public void before() { | ||
new BasicWorkFlow().goToHome().deleteCookiesAndRefresh(); | ||
documentStorageDirectory = | ||
CleanDocumentStorageRule.getDocumentStoragePath() | ||
.concat(File.separator).concat("documents") | ||
.concat(File.separator); | ||
assumeFalse("", new File(documentStorageDirectory).exists()); | ||
} | ||
|
||
@Test | ||
public void uploadHTMLFile() { | ||
File htmlfile = | ||
testFileGenerator.generateTestFileWithContent( | ||
"testhtmlfile", ".html", | ||
"<html><title>Test content</title><br>This is <b>Bold</b> text</html>"); | ||
String testFileName = htmlfile.getName(); | ||
String successfullyUploaded = | ||
"Document file " + testFileName + " uploaded."; | ||
ProjectSourceDocumentsPage projectSourceDocumentsPage = | ||
new LoginWorkFlow().signIn("admin", "admin").goToProjects() | ||
.goToProject("about fedora").goToVersion("master") | ||
.goToSourceDocuments().pressUploadFileButton() | ||
.enterFilePath(htmlfile.getAbsolutePath()) | ||
.submitUpload(); | ||
assertThat("Document uploaded notification shows", | ||
projectSourceDocumentsPage.getNotificationMessage(), | ||
Matchers.equalTo(successfullyUploaded)); | ||
assertThat("Document shows in table", | ||
projectSourceDocumentsPage.sourceDocumentsContains(htmlfile | ||
.getName())); | ||
|
||
EditorPage editorPage = projectSourceDocumentsPage.goToProjects() | ||
.goToProject("about fedora").goToVersion("master") | ||
.translate("pl").clickDocumentLink("", testFileName); | ||
|
||
assertThat("The first translation source is correct", | ||
editorPage.getTranslationSourceTexts().get(0), | ||
Matchers.equalTo("Test content")); | ||
assertThat("The second translation source content is correct", | ||
editorPage.getTranslationSourceContents().get(1), | ||
Matchers.equalTo("This<span class=\"cm-space\"> </span>is"+ | ||
"<span class=\"cm-space\"> </span><span class=\""+ | ||
"cm-tag\"><g2></span>Bold<span class=\"cm-tag\""+ | ||
"></g2></span><span class=\"cm-space\"> "+ | ||
"</span>text")); | ||
|
||
|
||
} | ||
} |