Skip to content

Commit

Permalink
Merge branch 'dev' into luis/test-ci-dec-11
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm authored Dec 30, 2024
2 parents 1b4b428 + d1df66d commit 82ef9cb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
48 changes: 30 additions & 18 deletions playwright/PageObjects/MainPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,28 +417,40 @@ export default class MainPage {
);
}

async validateInstallerIsDownloaded() {
const downloadPath = path.join(__dirname, "downloads");
if (!fs.existsSync(downloadPath)) {
fs.mkdirSync(downloadPath);
}
async validateInstallerIsDownloaded(viewport: string) {
if (viewport === "mobile-chrome") {
const pagePromise = this.page.waitForEvent("popup");
await this.buttonDownloadInstallAlert.click();
const newTab = await pagePromise;
await expect(newTab).toHaveURL(
"https://play.google.com/store/apps/details?id=com.uplink.app",
);
} else {
const downloadPath = path.join(__dirname, "downloads");
if (!fs.existsSync(downloadPath)) {
fs.mkdirSync(downloadPath);
}

const downloadPromise = this.page.waitForEvent("download");
await this.buttonDownloadInstallAlert.click();
const download = await downloadPromise;
const downloadPromise = this.page.waitForEvent("download");
await this.buttonDownloadInstallAlert.click();

const fileName = download.suggestedFilename(); // Get the suggested filename
const filePath = path.join(downloadPath, fileName);
await download.saveAs(filePath); // Save the file to the designated path
const download = await downloadPromise;

// Validate the downloaded file
console.log(`Downloaded file saved at: ${filePath}`);
expect(fs.existsSync(filePath)).toBeTruthy(); // Check file exists
expect([".msi", ".dmg", ".deb", ".apk"]).toContain(path.extname(fileName)); // Validate file extension
const fileName = download.suggestedFilename(); // Get the suggested filename
const filePath = path.join(downloadPath, fileName);
await download.saveAs(filePath); // Save the file to the designated path

// Clean up after test
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath); // Delete the file
// Validate the downloaded file
console.log(`Downloaded file saved at: ${filePath}`);
expect(fs.existsSync(filePath)).toBeTruthy(); // Check file exists
expect([".msi", ".dmg", ".deb", ".apk"]).toContain(
path.extname(fileName),
); // Validate file extension

// Clean up after test
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath); // Delete the file
}
}

// Validate install banner is gone
Expand Down
2 changes: 1 addition & 1 deletion playwright/specs/01-pin-input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ test.describe("Create Account and Login Tests", () => {
});

await test.step("User can download installer from button and banner is hidden", async () => {
await createOrImport.validateInstallerIsDownloaded();
await createOrImport.validateInstallerIsDownloaded(viewport);
});
});

Expand Down

0 comments on commit 82ef9cb

Please sign in to comment.