Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch multi-file-upload.
Browse files Browse the repository at this point in the history
Adds multi-file upload dialog to version -> settings -> documents
tab allowing multiple files to be uploaded in a single operation.

Maximum files per upload can be configured in
administration -> server config.

Squashed commit of the following:

commit 607ca73
Author: David Mason <drdmason@gmail.com>
Date:   Fri Aug 8 14:08:33 2014 +1000

    fix grammar and broken link output in multi-file upload

commit 3c1013d
Author: David Mason <drdmason@gmail.com>
Date:   Thu Aug 7 17:51:18 2014 +1000

    use canonical supported file types for project types

commit 23ee9cb
Merge: a6bb99c 9be4de8
Author: David Mason <drdmason@gmail.com>
Date:   Thu Aug 7 17:49:59 2014 +1000

    Merge branch 'master' into multi-file-upload

commit a6bb99c
Author: David Mason <drdmason@gmail.com>
Date:   Thu Aug 7 13:54:20 2014 +1000

    use proper formatting for multi-file-upload.xhtml

commit 9f09886
Author: David Mason <drdmason@gmail.com>
Date:   Thu Aug 7 13:20:14 2014 +1000

    remove unused parts of jQuery File Upload library

commit d339f86
Author: David Mason <drdmason@gmail.com>
Date:   Thu Aug 7 12:59:35 2014 +1000

    remove unused parts of JavaScript Templates library

commit 51870f5
Author: David Mason <drdmason@gmail.com>
Date:   Thu Aug 7 12:55:14 2014 +1000

    remove excess jquery import

commit dadbcab
Author: David Mason <drdmason@gmail.com>
Date:   Thu Aug 7 12:40:01 2014 +1000

    remove unused file

commit b4718fe
Author: David Mason <drdmason@gmail.com>
Date:   Thu Aug 7 12:38:58 2014 +1000

    use Slf4j for logging in MultiFileUploadServlet

commit d79e644
Author: David Mason <drdmason@gmail.com>
Date:   Thu Aug 7 12:36:53 2014 +1000

    use DocumentType constant to compare types

commit 413f333
Author: David Mason <drdmason@gmail.com>
Date:   Thu Aug 7 12:28:30 2014 +1000

    Use static LocaleId field for en-US

commit 3d6ee66
Author: David Mason <drdmason@gmail.com>
Date:   Thu Aug 7 12:23:36 2014 +1000

    indicate where inline templates are processed

commit a7c6f67
Author: David Mason <drdmason@gmail.com>
Date:   Wed Aug 6 14:29:36 2014 +1000

    add server config option for max files per upload

commit 1bc2358
Merge: ed23803 d82b111
Author: David Mason <drdmason@gmail.com>
Date:   Wed Aug 6 12:35:58 2014 +1000

    Merge branch 'master' into multi-file-upload

commit ed23803
Author: David Mason <drdmason@gmail.com>
Date:   Mon Aug 4 11:59:49 2014 +1000

    prevent invalid upload file extensions being seen as valid

commit fa8d238
Author: David Mason <drdmason@gmail.com>
Date:   Mon Aug 4 07:59:14 2014 +1000

    Use translatable strings for multi-file upload script.

    Strings are included in the DOM of the multi-file upload widget so they
    can be translated through the same mechanism as the other UI strings in
    JSF. The script looks up the list of strings in the DOM and populates
    the messages object.

commit c0773c8
Author: Damian Jansen <djansen@redhat.com>
Date:   Fri Aug 1 15:22:33 2014 +1000

    Fix document upload functional tests

commit 152acc6
Author: David Mason <drdmason@gmail.com>
Date:   Thu Jul 31 17:13:21 2014 +1000

    use translatable strings for multi-file-upload template

commit 99d41d6
Merge: 276bc67 7da217e
Author: David Mason <drdmason@gmail.com>
Date:   Thu Jul 31 15:30:12 2014 +1000

    Merge branch 'master' into merge-multi-file-upload

commit 276bc67
Author: David Mason <drdmason@gmail.com>
Date:   Thu Jul 31 14:07:28 2014 +1000

    WIP: using localizable messages in multi file upload

commit 1306648
Author: David Mason <drdmason@gmail.com>
Date:   Thu Jul 31 11:07:21 2014 +1000

    fix compile errors caused by merge conflict resolution

commit 861de99
Merge: 0e66e8f 708a3a9
Author: David Mason <drdmason@gmail.com>
Date:   Wed Jul 30 17:21:12 2014 +1000

    Merge branch 'multi-file-upload-tests' into merge-multi-file-upload

    Conflicts:
    	functional-test/src/test/java/org/zanata/feature/editor/TranslateHTMLTest.java
    	functional-test/src/test/java/org/zanata/feature/editor/TranslateIdmlTest.java
    	functional-test/src/test/java/org/zanata/feature/editor/TranslateOdsTest.java
    	functional-test/src/test/java/org/zanata/feature/editor/TranslateOpenOfficeTest.java
    	functional-test/src/test/java/org/zanata/feature/editor/TranslateTextTest.java

        Resolved all using --ours option (keeping version from master).
        Intend to manually apply necessary changes in these files in a subsequent commit,
        rather than risk overwriting the newer code.

commit 0e66e8f
Merge: 05e31c2 8b2bd46
Author: David Mason <drdmason@gmail.com>
Date:   Wed Jul 30 16:42:19 2014 +1000

    Merge branch 'multi-file-upload' into merge-multi-file-upload

    Conflicts:
    	zanata-war/src/main/webapp/WEB-INF/layout/version/settings-tab.xhtml
          had conflict where multi-file-upload element was added, same location
          had "messages" changed to "msgs". Kept chunk from multi-file-upload
          but changed "messages" in that chunk to "msgs".

commit 708a3a9
Author: Damian Jansen <djansen@redhat.com>
Date:   Fri Jun 27 13:51:19 2014 +1000

    Multiple file upload test

commit 8b2bd46
Author: David Mason <drdmason@gmail.com>
Date:   Mon Jul 28 12:23:45 2014 +1000

    Use format strings for UI text

    All strings for display are wrapped in i18n function.
    At the moment this only replaces placeholders since I have not provided
    a way to make translated strings available. The simplest approach I can
    think of to make translated strings available would be to output them as
    text in hidden DOM elements of the component, since that would allow
    translations to be handled through the existing page translation workflow.

commit 7370f53
Author: Damian Jansen <djansen@redhat.com>
Date:   Fri Jun 27 00:24:10 2014 +1000

    Fix testing of uploading files

    Also remove a number of unnecessary steps in the upload tests.

commit a65b0d2
Author: David Mason <drdmason@gmail.com>
Date:   Fri Jul 25 11:39:02 2014 +1000

    SQUASH some cleanup

commit dd25056
Author: David Mason <drdmason@gmail.com>
Date:   Thu Jul 24 17:00:29 2014 +1000

    Needs Cleanup: WIP different upload stages being recorded, not used for count display yet

commit e8e0547
Author: David Mason <drdmason@gmail.com>
Date:   Wed Jul 23 15:23:10 2014 +1000

    make custom file parameters collapsed by default for multi-file upload

commit 7b38ddc
Author: David Mason <drdmason@gmail.com>
Date:   Wed Jul 23 14:34:45 2014 +1000

    Add help for custom document parameters field in multi-file upload

commit db43a80
Author: David Mason <drdmason@gmail.com>
Date:   Wed Jul 23 10:54:42 2014 +1000

    hide advanced settings when multi-file-upload starts

commit f629abc
Author: David Mason <drdmason@gmail.com>
Date:   Tue Jul 22 17:33:55 2014 +1000

    update error message for users with multiple concurrent uploads

commit b11d4fd
Author: David Mason <drdmason@gmail.com>
Date:   Tue Jul 22 17:31:43 2014 +1000

    Ensure multi-file-upload dialog always responds to finished uploads

commit 78d45e8
Author: David Mason <drdmason@gmail.com>
Date:   Mon Jul 14 12:37:38 2014 +1000

    Use change in filename emphasis to indicate which files have uploaded.

    This replaces the green circle icon that was indicating upload completion
    previously.

commit caf5606
Author: David Mason <drdmason@gmail.com>
Date:   Mon Jul 14 12:35:59 2014 +1000

    Ensure loader reserves space in multi-file upload dialog.

    This will prevent layout changes for long filenames during upload,
    but only when the .is-reserve-space css class is implemented in the
    assets.

commit 4980b1e
Author: David Mason <drdmason@gmail.com>
Date:   Mon Jul 14 11:41:43 2014 +1000

    Ensure uploading file items display with consistent height.

    During multi-file upload, file items were changing size slightly
    when they finished uploading, due to the loader widget changing the
    height. This is a workaround until the loader widget is updated to
    work better in inline mode - it just adds a hidden loader to the
    uploaded template to force it to the same height.

commit cddd1bd
Author: David Mason <drdmason@gmail.com>
Date:   Mon Jul 14 11:40:04 2014 +1000

    Warn user when closing page during multiple file upload

    This adds a modal dialog when a user is currently uploading source
    files and they attempt to close or navigate away from the page.

commit e39be2a
Author: David Mason <drdmason@gmail.com>
Date:   Fri Jul 11 19:32:21 2014 +1000

    Add confirmation to all operations that cancel an upload.

    Makes sure the event 'hide.zanata.modal' is triggered in all cases that
    close the modal, then add the check to that event.
    Also incidentally fixed some cases in which the modal could be closed
    without refreshing the document list by attaching an event on
    'hide.zanata.modal' to refresh the statistics.

commit b7e6606
Author: David Mason <drdmason@gmail.com>
Date:   Fri Jul 11 14:09:56 2014 +1000

    Prevent file upload progress bar incrementing before files are uploaded.

    This is just a workaround that delays the increment until the next
    progress event, which seems sufficient without a complete overhaul
    of the progress system (which seems to have something really wrong with it).

commit 27e7359
Author: David Mason <drdmason@gmail.com>
Date:   Fri Jul 11 14:09:44 2014 +1000

    clean up leftover comment

commit 5004bd4
Author: David Mason <drdmason@gmail.com>
Date:   Fri Jul 11 13:01:31 2014 +1000

    User throbber instead of progress bar for uploading files.

    Individual file items in multi-file upload dialog show a throbber
    when they are uploading. The overall progress for all the files
    still uses a progress bar.

commit 92d587a
Author: David Mason <drdmason@gmail.com>
Date:   Thu Jul 10 14:08:26 2014 +1000

    ensure file count indicator resets when multi file upload form resets

commit edf2f3d
Author: David Mason <drdmason@gmail.com>
Date:   Thu Jul 10 13:43:01 2014 +1000

    clear errors when retrying upload of multiple files

commit 43822c0
Author: David Mason <drdmason@gmail.com>
Date:   Thu Jul 10 13:42:29 2014 +1000

    Clean up fileupload ui code

commit 2613787
Author: David Mason <drdmason@gmail.com>
Date:   Mon Jul 7 16:02:56 2014 +1000

    SPLIT: check logged in and not already uploading before initiating upload

        Upload button now changes to "Try Again" if user is not logged in or has an upload
        going in another tab/window/computer.

        Still needs to display errors upon failure, and the code is messy,
        but it works so I'm making a commit in case I break it.

    Squashed commits:

    SQUASH clean up code for GET on MultiFileUploadServlet

    SQUASH clean up code for POST on MultiFileUploadServlet

    Display appropriate error when transaction times out for uploaded file persistence.

    Show appropriate error when concurrent uploads reach the database.

    log id properly for a user who is already uploading

    change error text for timed-out file upload

    SQUASH update error message in MultiFileUploadServlet

commit df239c4
Author: David Mason <drdmason@gmail.com>
Date:   Wed Jul 2 11:42:09 2014 +1000

    Prevent opening of file select dialog when clicking outside the intended click target.

    The dialog was opening when clicking anywhere in a region to the right of and below
    the "browse files" text that is the intended click target. This change limits the
    target to just the "browse files" text.
    Wrapping of the "browse files" text is prevented since the transparent file upload
    button must overlay all of the text for the dialog to open properly (plus it looks
    better with the whole link on the next line than split across lines).

commit 5a0828a
Author: David Mason <drdmason@gmail.com>
Date:   Fri Jun 27 18:17:47 2014 +1000

    Limit file uploads to 100 files at a time.

        This adds a hard-coded limit of 100 files, with the intention to replace the limit with a
        configurable value.

commit 3231d73
Author: David Mason <drdmason@gmail.com>
Date:   Fri Jun 27 15:40:16 2014 +1000

    Remove cancel button from files while upload is in progress.

commit bb694a1
Author: David Mason <drdmason@gmail.com>
Date:   Fri Jun 27 12:58:27 2014 +1000

    Prevent advanced settings being retained after closing upload dialog.

        Prevents both file path and custom upload parameters from remaining
        when the multi-file-upload dialog is closed and re-opened.

commit 0f977a1
Author: David Mason <drdmason@gmail.com>
Date:   Fri Jun 27 12:16:47 2014 +1000

    Make 'browse files' link vertically centred.

commit 749ad6e
Author: David Mason <drdmason@gmail.com>
Date:   Mon Jun 23 12:46:53 2014 +1000

    Update file upload test to work with new component.

commit 4779e62
Author: David Mason <drdmason@gmail.com>
Date:   Mon Jun 23 11:20:00 2014 +1000

    Remove org.json as a used dependency for maven-dependency-plugin

commit 5be8be5
Author: David Mason <drdmason@gmail.com>
Date:   Mon Jun 23 10:34:21 2014 +1000

    Remove source language selector from multi file upload dialog.

      Source language is ignored by the server at the moment, so there is
      no value in having a user select it.

commit f306a8c
Author: David Mason <drdmason@gmail.com>
Date:   Mon Jun 23 10:26:27 2014 +1000

    Use multi-file upload component on settings tab.

commit a1e784e
Merge: 308bfc3 abab959
Author: David Mason <drdmason@gmail.com>
Date:   Thu Jun 19 13:01:26 2014 +1000

    Merge branch 'master' into multi-file-upload

    Conflicts:
    	zanata-war/src/main/webapp-jboss/WEB-INF/web.xml

        A servlet mapping is added at the same position on each branch.
        Merge keeps both mappings.

commit 308bfc3
Author: David Mason <dr.d.mason@gmail.com>
Date:   Tue May 20 09:55:02 2014 +1000

    WIP: getting json libraries working properly

commit 361cc8c
Author: David Mason <dr.d.mason@gmail.com>
Date:   Thu May 1 10:54:14 2014 +1000

    show intelligible error when uploading multiple files after session timeout

commit aad0700
Author: David Mason <dr.d.mason@gmail.com>
Date:   Thu May 1 10:52:13 2014 +1000

    improve inline file upload error style

commit a2cec76
Author: David Mason <dr.d.mason@gmail.com>
Date:   Wed Apr 30 15:55:57 2014 +1000

    show uploaded documents when multi-file-upload dialog is closed

commit dbad9ba
Author: David Mason <dr.d.mason@gmail.com>
Date:   Thu Apr 3 08:42:28 2014 +1000

    SQUASH add style classes to multi file upload widget

commit 93ca756
Author: David Mason <dr.d.mason@gmail.com>
Date:   Thu Apr 3 08:42:00 2014 +1000

    SQUASH hide files panel when no files are shown

commit 7f34125
Author: David Mason <dr.d.mason@gmail.com>
Date:   Wed Apr 2 09:56:08 2014 +1000

    show and hide portions of the form when upload is not supported

commit e757dee
Author: David Mason <dr.d.mason@gmail.com>
Date:   Mon Mar 31 13:58:49 2014 +1000

    ensure that .pot extensions are handled properly in uploaded source files.

commit 0e62035
Author: David Mason <dr.d.mason@gmail.com>
Date:   Fri Mar 28 11:53:02 2014 +1000

    add 'accepted' attribute to multi-file-upload widget

commit 60986fe
Author: David Mason <dr.d.mason@gmail.com>
Date:   Fri Mar 28 11:46:07 2014 +1000

    limit individual file size to 200MB

commit 3abb78b
Author: David Mason <dr.d.mason@gmail.com>
Date:   Fri Mar 28 15:29:17 2014 +1000

    Various display behaviour tweaks to file upload dialog.

        - when there is an error adding a file, just show an error and do not add it
        - show number of queued and uploading files
        - change drop zone style when files are dragged over it
        - reset dialog when it is reopened
        - close dialog when any of the cancel buttons are pressed
        - disable adding more files when upload has started

commit 7b6ca7c
Author: David Mason <dr.d.mason@gmail.com>
Date:   Thu Mar 20 14:24:37 2014 +1000

    prepend modal dialogs to body to prevent automatic cloning

commit 40cbd47
Author: David Mason <dr.d.mason@gmail.com>
Date:   Mon Mar 17 09:44:12 2014 +1000

    limit uploads to accepted file types

commit 8166271
Author: David Mason <dr.d.mason@gmail.com>
Date:   Sun Mar 16 19:11:56 2014 +1000

    create multi file upload widget

commit 19d99e4
Author: David Mason <dr.d.mason@gmail.com>
Date:   Sun Mar 16 21:36:38 2014 +1000

    strip CDATA from template strings

commit d8bcac5
Author: David Mason <dr.d.mason@gmail.com>
Date:   Sun Mar 16 21:43:15 2014 +1000

    modify main script for fileupload to work with multi-file-upload widget

commit 9a25e0b
Author: David Mason <dr.d.mason@gmail.com>
Date:   Sun Mar 16 23:38:44 2014 +1000

    add javascript templates library

commit 5c1271d
Author: David Mason <dr.d.mason@gmail.com>
Date:   Sun Mar 16 19:10:35 2014 +1000

    add jquery file upload library

commit e9fc692
Author: David Mason <dr.d.mason@gmail.com>
Date:   Sun Mar 16 19:06:53 2014 +1000

    add upload servlet for multiple files

commit 083ce60
Author: David Mason <dr.d.mason@gmail.com>
Date:   Mon Mar 17 18:15:40 2014 +1000

    Add method to allow uploads without provided hash
  • Loading branch information
davidmason committed Aug 8, 2014
1 parent 9be4de8 commit 5b76932
Show file tree
Hide file tree
Showing 41 changed files with 5,636 additions and 272 deletions.
Expand Up @@ -81,7 +81,7 @@ public CreateVersionPage selectProjectType(String projectType) {
projectTypeSelection.findElements(By.tagName("li"));
for (WebElement projectTypeLi : projectTypes) {
if (projectTypeLi.findElement(By.xpath(".//div/label")).getText()
.equals(projectType)) {
.startsWith(projectType)) {
projectTypeLi.findElement(By.xpath(".//div")).click();
break;
}
Expand Down
Expand Up @@ -25,6 +25,7 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.ArrayList;
import java.util.List;

/**
Expand Down Expand Up @@ -58,6 +59,15 @@ public boolean sourceDocumentsContains(String document) {
return false;
}

public List<String> getSourceDocumentNames() {
List<String> filenames = new ArrayList<String>();
for (WebElement element : getDocumentsTabDocumentList()) {
filenames.add(element.findElement(By.className("list__title"))
.getText());
}
return filenames;
}

private List<WebElement> getDocumentsTabDocumentList() {
waitForTenSec().until(new Predicate<WebDriver>() {
@Override
Expand Down
@@ -1,12 +1,14 @@
package org.zanata.page.projectversion.versionsettings;

import java.util.ArrayList;
import java.util.List;

import com.google.common.base.Predicate;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.zanata.page.projectversion.VersionBasePage;
import org.zanata.page.projectversion.VersionLanguagesPage;

/**
* @author Damian Jansen <a
Expand All @@ -19,7 +21,7 @@ public VersionDocumentsTab(WebDriver driver) {
}

public VersionDocumentsTab pressUploadFileButton() {
clickLinkAfterAnimation(By.id("button--upload-new-document"));
clickLinkAfterAnimation(By.id("file-upload-component-toggle-button"));
return new VersionDocumentsTab(getDriver());
}

Expand All @@ -30,30 +32,69 @@ public VersionDocumentsTab pressUploadFileButton() {
*/
public boolean canSubmitDocument() {
return getDriver().findElement(
By.id("uploadDocForm:generalDocSubmitUploadButton"))
By.id("file-upload-component-start-upload"))
.isEnabled();
}

public VersionDocumentsTab cancelUpload() {
getDriver().findElement(
By.id("uploadDocForm:generalDocCancelUploadButton")).click();
getDriver()
.findElement(By.id("file-upload-component-cancel-upload"))
.click();
waitForTenSec().until(new Predicate<WebDriver>() {
@Override
public boolean apply( WebDriver input) {
return !getDriver().findElement(By.id("file-upload-component"))
.isDisplayed();
}
});
return new VersionDocumentsTab(getDriver());
}

public VersionDocumentsTab enterFilePath(String filePath) {
getDriver().findElement(By.id("uploadDocForm:generalDocFileUpload"))
// Make the hidden input element slightly not hidden
((JavascriptExecutor)getDriver())
.executeScript("arguments[0].style.visibility = 'visible'; " +
"arguments[0].style.height = '1px'; " +
"arguments[0].style.width = '1px'; " +
"arguments[0].style.opacity = 1",
getDriver().findElement(
By.id("file-upload-component-file-input")));

getDriver().findElement(
By.id("file-upload-component-file-input"))
.sendKeys(filePath);
return new VersionDocumentsTab(getDriver());
}

public VersionLanguagesPage submitUpload() {
public VersionDocumentsTab submitUpload() {
waitForTenSec().until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
return getDriver().findElement(
By.id("file-upload-component-start-upload"))
.isEnabled();
}
});
getDriver().findElement(
By.id("uploadDocForm:generalDocSubmitUploadButton")).click();
return new VersionLanguagesPage(getDriver());
By.id("file-upload-component-start-upload")).click();
return new VersionDocumentsTab(getDriver());
}

public boolean sourceDocumentsContains(String document) {
public VersionDocumentsTab clickUploadDone() {
waitForTenSec().until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
return getDriver()
.findElement(By.id("file-upload-component-done-upload"))
.isEnabled();
}
});
getDriver().findElement(By.id("file-upload-component-done-upload"))
.click();
return new VersionDocumentsTab(getDriver());
}

public boolean sourceDocumentsContains(String document) {
List<WebElement> documentLabelList =
getDriver()
.findElement(By.id("settings-document_form"))
Expand All @@ -67,4 +108,43 @@ public boolean sourceDocumentsContains(String document) {
}
return false;
}

public List<String> getUploadList() {
List<String> filenames = new ArrayList<String>();
for (WebElement element : getUploadListElements()) {
filenames.add(element.findElement(By.className("list__title"))
.getText());
}
return filenames;
}

public VersionDocumentsTab clickRemoveOn(String filename) {
for (WebElement element : getUploadListElements()) {
if (element.findElement(By.className("list__title"))
.getText().equals(filename)) {
element.findElement(By.className("list__item__actions"))
.findElement(By.className("cancel"))
.click();
}
}
return new VersionDocumentsTab(getDriver());
}

private List<WebElement> getUploadListElements() {
return getDriver().findElement(By.className("js-files-panel"))
.findElement(By.tagName("ul"))
.findElements(By.tagName("li"));
}

public String getUploadError() {
waitForTenSec().until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
return getDriver().findElement(By.id("file-upload-component"))
.findElement(By.className("txt--danger")).isDisplayed();
}
});
return getDriver().findElement(By.id("file-upload-component"))
.findElement(By.className("txt--danger")).getText();
}
}
Expand Up @@ -21,6 +21,8 @@
package org.zanata.feature.document;

import lombok.extern.slf4j.Slf4j;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.experimental.categories.Category;
import org.junit.experimental.theories.DataPoint;
Expand All @@ -31,11 +33,13 @@
import org.zanata.feature.testharness.ZanataTestCase;
import org.zanata.page.projectversion.VersionDocumentsPage;
import org.zanata.page.projectversion.VersionLanguagesPage;
import org.zanata.page.projectversion.versionsettings.VersionDocumentsTab;
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.LoginWorkFlow;
import org.zanata.workflow.ProjectWorkFlow;

import java.io.File;

Expand All @@ -49,13 +53,21 @@
@RunWith(Theories.class)
public class DocTypeUploadTest extends ZanataTestCase {

@Rule
public SampleProjectRule sampleProjectRule = new SampleProjectRule();
@ClassRule
public static SampleProjectRule sampleProjectRule = new SampleProjectRule();

@Rule
public CleanDocumentStorageRule documentStorageRule =
@ClassRule
public static CleanDocumentStorageRule documentStorageRule =
new CleanDocumentStorageRule();

@BeforeClass
public static void beforeClass() {
new LoginWorkFlow().signIn("admin", "admin");
new ProjectWorkFlow().createNewProjectVersion(
"about fedora", "doctype-upload", "File")
.logout();
}

private static String testString = "Test text 1";

@DataPoint
Expand Down Expand Up @@ -91,27 +103,18 @@ public class DocTypeUploadTest extends ZanataTestCase {
public void uploadFile(File testFile) throws Exception {
String testFileName = testFile.getName();
log.info("[uploadFile] "+testFileName);
String successfullyUploaded =
"Document " + testFileName + " uploaded.";

VersionLanguagesPage versionLanguagesPage = new LoginWorkFlow()
VersionDocumentsPage versionDocumentsPage = new LoginWorkFlow()
.signIn("admin", "admin")
.goToProjects()
.goToProject("about fedora")
.gotoVersion("master")
.gotoVersion("doctype-upload")
.gotoSettingsTab()
.gotoSettingsDocumentsTab()
.pressUploadFileButton()
.enterFilePath(testFile.getAbsolutePath())
.submitUpload();

versionLanguagesPage.expectNotification(successfullyUploaded);

assertThat(versionLanguagesPage.getNotificationMessage())
.isEqualTo(successfullyUploaded)
.as("Document uploaded notification shows");

VersionDocumentsPage versionDocumentsPage = versionLanguagesPage
.submitUpload()
.clickUploadDone()
.gotoDocumentTab();

assertThat(versionDocumentsPage.sourceDocumentsContains(testFileName))
Expand Down

0 comments on commit 5b76932

Please sign in to comment.