Skip to content

Commit

Permalink
it: more reliable successful download test
Browse files Browse the repository at this point in the history
  • Loading branch information
giulong committed Dec 31, 2024
1 parent 31ab229 commit 24eac4b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import java.util.List;

import static io.github.giulong.spectrum.it.tests.FilesIT.FILE_TO_UPLOAD;

@Getter
@Endpoint("download")
@SuppressWarnings("unused")
Expand All @@ -20,4 +22,7 @@ public class DownloadPage extends SpectrumPage<DownloadPage, Void> {
@FindBy(tagName = "a"),
})
private List<WebElement> downloadLinks;

@FindBy(linkText = FILE_TO_UPLOAD)
private WebElement spectrumLogo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
@SuppressWarnings("unused")
public class FilesIT extends SpectrumTest<Void> {

// this must be different from the downloaded file since herokuapp will randomly serve exactly the files used to test the upload
public static final String FILE_TO_UPLOAD = "spectrum-logo.png";
private static final String FILE_TO_DOWNLOAD = "empty.txt";
private static final String FILE_TO_UPLOAD = "spectrum-logo.png";

private DownloadPage downloadPage;
private UploadPage uploadPage;
Expand Down Expand Up @@ -58,11 +57,7 @@ public void upload() {

downloadPage
.open()
.getDownloadLinks()
.stream()
.filter(webElement -> webElement.getText().equals(FILE_TO_UPLOAD))
.findFirst()
.orElseThrow()
.getSpectrumLogo()
.click();

assertTrue(checkDownloadedFile(FILE_TO_UPLOAD));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private void commonChecksFor(final String url) {
assertEquals("3", extentReportPage.getVideoLoginFormItWithUserGiulioWeExpectLoginToBeSuccessfulFalse().getDomProperty("duration"));
assertEquals("3", extentReportPage.getVideoLoginFormItWithUserTomWeExpectLoginToBeSuccessfulTrue().getDomProperty("duration"));

assertEquals("17", extentReportPage.getVideoFilesItUpload().getDomProperty("duration"));
assertEquals("2", extentReportPage.getVideoFilesItUpload().getDomProperty("duration"));
assertEquals("1", extentReportPage.getVideoFilesItDownload().getDomProperty("duration"));

// check screenshot was added programmatically with the screenshotInfo(String) method
Expand Down

0 comments on commit 24eac4b

Please sign in to comment.