Search in sources :

Example 1 with UploadElement

use of com.vaadin.flow.component.upload.testbench.UploadElement in project flow by vaadin.

the class AppViewIT method upload_file_in_private_view.

@Test
public void upload_file_in_private_view() throws IOException {
    open("private");
    loginUser();
    UploadElement upload = $(UploadElement.class).first();
    File tmpFile = File.createTempFile("security-flow-image", ".png");
    InputStream imageStream = getClass().getClassLoader().getResourceAsStream("image.png");
    IOUtils.copyLarge(imageStream, new FileOutputStream(tmpFile));
    tmpFile.deleteOnExit();
    upload.upload(tmpFile);
    TestBenchElement text = $("p").id("uploadText");
    TestBenchElement img = $("img").id("uploadImage");
    Assert.assertEquals("Loan application uploaded by John the User", text.getText());
    Assert.assertTrue(img.getPropertyString("src").contains("/VAADIN/dynamic/resource/"));
}
Also used : InputStream(java.io.InputStream) UploadElement(com.vaadin.flow.component.upload.testbench.UploadElement) FileOutputStream(java.io.FileOutputStream) File(java.io.File) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test)

Aggregations

UploadElement (com.vaadin.flow.component.upload.testbench.UploadElement)1 TestBenchElement (com.vaadin.testbench.TestBenchElement)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 Test (org.junit.Test)1