Skip to content

Commit

Permalink
chore: debug
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Zedel <[email protected]>
  • Loading branch information
mzedel committed Aug 9, 2023
1 parent ba05eb6 commit 71522f9
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/e2e_tests/integration/03-files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import dayjs from 'dayjs';
import isBetween from 'dayjs/plugin/isBetween.js';
import * as fs from 'fs';
import md5 from 'md5';
import https from 'https';

import test, { expect } from '../fixtures/fixtures';
import { selectors, timeouts } from '../utils/constants';
import axios from 'axios';

dayjs.extend(isBetween);

Expand Down Expand Up @@ -53,13 +55,18 @@ test.describe('Files', () => {
await page.click(`.leftNav :text('Releases')`);
await page.click(`text=/mender-demo-artifact/i`);
await page.click('.expandButton');
await page.waitForSelector(`text=Download Artifact`, { timeout: timeouts.fiveSeconds }); // slightly longer
expect(await page.isVisible(`text=Download Artifact`)).toBeTruthy();
// unfortunately the firefox integration gets flaky with the download attribute set + the chrome + webkit integrations time out
// waiting for the download event almost every time => work around by getting the file
// let's see if things have improved
const [download] = await Promise.all([page.waitForEvent('download'), page.getByRole('button', { name: /download artifact/i }).click()]);
const downloadTargetPath = await download.path();
const downloadButton = await page.getByText(/download artifact/i);
expect(await downloadButton.isVisible()).toBeTruthy();
const [download] = await Promise.all([page.waitForEvent('download'), downloadButton.click()]);
let downloadTargetPath = await download.path();
const downloadError = await download.failure();
if (downloadError) {
const downloadUrl = download.url();
const response = await axios.get(downloadUrl, { httpsAgent: new https.Agent({ rejectUnauthorized: false }), responseType: 'arraybuffer' });
const fileData = Buffer.from(response.data, 'binary');
downloadTargetPath = `./${download.suggestedFilename()}`;
fs.writeFileSync(downloadTargetPath, fileData);
}
const newFile = await fs.readFileSync(downloadTargetPath);
const testFile = await fs.readFileSync(`fixtures/${fileName}`);
expect(md5(newFile)).toEqual(md5(testFile));
Expand Down

0 comments on commit 71522f9

Please sign in to comment.