Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(e2e): create e2e test for bulk download #2445

Merged
merged 18 commits into from
Aug 19, 2024
Merged
4 changes: 2 additions & 2 deletions kubernetes/loculus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1451,8 +1451,8 @@ insecureCookies: false
bannerMessage: "This is a development environment. Data will not be persisted."
additionalHeadHTML: '<script defer data-domain="main.loculus.org" src="https://plausible.io/js/script.js"></script>'
images:
lapisSilo: "ghcr.io/genspectrum/lapis-silo:0.2.12"
lapis: "ghcr.io/genspectrum/lapis:0.2.8"
lapisSilo: "ghcr.io/genspectrum/lapis-silo:0.2.13"
lapis: "ghcr.io/genspectrum/lapis:0.2.9"
secrets:
smtp-password:
type: raw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const DownloadButton: FC<DownloadButtonProps> = ({
className={`btn loculusColor ${disabled ? 'btn-disabled' : ''} text-white`}
href={downloadUrl}
onClick={handleClick}
data-testid='start-download'
>
Download
</a>
Expand Down
50 changes: 50 additions & 0 deletions website/tests/pages/search/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { type Page, type Download } from '@playwright/test';
import { DateTime } from 'luxon';

import { routes } from '../../../src/routes/routes.ts';
import { getAccessionVersionString } from '../../../src/utils/extractAccessionVersion.ts';
import { baseUrl, dummyOrganism, expect, test } from '../../e2e.fixture';
import { getTestSequences } from '../../util/testSequenceProvider.ts';

interface PerformDownloadOptions {
selectRawNucleotide?: boolean;
}

test.describe('The search page', () => {
test('should find no data in the future', async ({ searchPage }) => {
const tomorrow = DateTime.now().plus({ days: 1 }).toISODate();
Expand Down Expand Up @@ -97,4 +102,49 @@ test.describe('The search page', () => {

await expect(searchPage.getAccessionField()).toHaveValue('');
});

async function performDownload(page: Page, options: PerformDownloadOptions = {}): Promise<string> {
const { selectRawNucleotide = false } = options;

const downloadButton = page.getByRole('button', { name: 'Download' });
await downloadButton.click();

if (selectRawNucleotide === true) {
const rawNucleotideRadio = page.getByLabel('Raw nucleotide sequences');
await rawNucleotideRadio.check();
}

const agreeCheckbox = page.getByLabel(/I agree/);
await agreeCheckbox.check();

const downloadButton2 = page.getByTestId('start-download');

const downloadPromise: Promise<Download> = page.waitForEvent('download');

await downloadButton2.click();

const download: Download = await downloadPromise;

const suggestedFileName: string = download.suggestedFilename();
const filePath: string = '/tmp/' + String(Math.random()).slice(0, 5) + suggestedFileName;
await download.saveAs(filePath);

return filePath;
}

test('should download file when agreeing to terms', async ({ searchPage, page }) => {
await searchPage.goto();

const filePath = await performDownload(page);

expect(filePath).toBeTruthy();
});

test('should download raw nucleotide sequences when selected', async ({ searchPage, page }) => {
await searchPage.goto();

const filePath = await performDownload(page, { selectRawNucleotide: true });

expect(filePath).toBeTruthy();
});
});
Loading