Skip to content

Commit

Permalink
fix: compile test into one RUN
Browse files Browse the repository at this point in the history
  • Loading branch information
alicechaitea committed Feb 15, 2024
1 parent 911eb44 commit 5503c6f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ local/*
tests/wallet-automation/typhon/usrdatadir/*
tests/wallet-automation/typhon/playwright-report/*
tests/wallet-automation/node_modules/*
tests/wallet-automation/typhon/extensions/*
tests/wallet-automation/typhon/extensions/*
45 changes: 45 additions & 0 deletions tests/wallet-automation/wallet-setup.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { test, BrowserContext } from '@playwright/test';
import * as fs from 'fs/promises';
import * as path from 'path';


const typhonId = 'KFDNIEFADAANBJODLDOHAEDPHAFOFFOH';
const url = `https://clients2.google.com/service/update2/crx?response=redirect&os=win&arch=x64&os_arch=x86_64&nacl_arch=x86-64&prod=chromiumcrx&prodchannel=beta&prodversion=79.0.3945.53&lang=ru&acceptformat=crx3&x=id%3D${typhonId}%26installsource%3Dondemand%26uc`;
const downloadPath = path.resolve(__dirname, 'extensions');


test('downloadFile test', async ({ page }) => {
await fs.mkdir(downloadPath, { recursive: true });

const downloadPromise = new Promise(async (resolve) => {
page.once('download', async (download) => {
const filePath = path.join(downloadPath, download.suggestedFilename());
await download.saveAs(filePath);
console.log(`file has been downloaded to: ${filePath}`);
resolve(filePath);
});
});

try {
await page.goto(url, {
waitUntil: 'domcontentloaded',
timeout: 10000
});
} catch (error) {
console.log('navigation caused an exception, likely due to immediate download:', 'directDownload');
}

// wait for the download to complete
const downloadedFilePath = await downloadPromise;

// verify the file exists
try {
await fs.access(downloadedFilePath as string); // Type assertion to string
console.log('file verification succeeded, file exists.');
} catch {
console.error('file verification failed, file does not exist.');
throw new Error('downloaded file does not exist.');
};

});

0 comments on commit 5503c6f

Please sign in to comment.