Skip to content

Commit

Permalink
Add excel downloads to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fhennig committed Jan 22, 2025
1 parent be43d38 commit 92f2556
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
16 changes: 14 additions & 2 deletions website/tests/pages/revise/revise.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,21 @@ export class RevisePage {
await this.page.getByRole('button', { name: 'Submit' }).click();
}

public async downloadMetadataTemplate() {
public async downloadTsvMetadataTemplate() {
return this.downloadMetadataTemplate('TSV');
}

public async downloadXlsMetadataTemplate() {
return this.downloadMetadataTemplate('XLS');
}

public async downloadXlsxMetadataTemplate() {
return this.downloadMetadataTemplate('XLSX');
}

private async downloadMetadataTemplate(format: 'TSV' | 'XLS' | 'XLSX') {
const downloadPromise = this.page.waitForEvent('download');
await this.page.getByText('TSV', { exact: true }).click();
await this.page.getByText(format, { exact: true }).click();
return downloadPromise;
}

Expand Down
16 changes: 14 additions & 2 deletions website/tests/pages/submission/submit.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,21 @@ export class SubmitPage {
await this.page.click(restrictedSelector);
}

public async downloadMetadataTemplate() {
public async downloadTsvMetadataTemplate() {
return this.downloadMetadataTemplate('TSV');
}

public async downloadXlsMetadataTemplate() {
return this.downloadMetadataTemplate('XLS');
}

public async downloadXlsxMetadataTemplate() {
return this.downloadMetadataTemplate('XLSX');
}

private async downloadMetadataTemplate(format: 'TSV' | 'XLS' | 'XLSX') {
const downloadPromise = this.page.waitForEvent('download');
await this.page.getByText('TSV', { exact: true }).click();
await this.page.getByText(format, { exact: true }).click();
return downloadPromise;
}
}
16 changes: 14 additions & 2 deletions website/tests/pages/submission/template.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ test.describe('The submit page', () => {
const { groupId } = await loginAsTestUser();
await submitPage.goto(groupId);

const download = await submitPage.downloadMetadataTemplate();
let download = await submitPage.downloadTsvMetadataTemplate();

expect(download.suggestedFilename()).toBe('Test_Dummy_Organism_metadata_template.tsv');
const content = await getDownloadedContent(download);
expect(content).toStrictEqual('submissionId\tcountry\tdate\n');

download = await submitPage.downloadXlsMetadataTemplate();
expect(download.suggestedFilename()).toBe('Test_Dummy_Organism_metadata_template.xls');

download = await submitPage.downloadXlsMetadataTemplate();
expect(download.suggestedFilename()).toBe('Test_Dummy_Organism_metadata_template.xlsx');
});

test('should download the metadata file template for revision', async ({
Expand All @@ -30,11 +36,17 @@ test.describe('The submit page', () => {
const { groupId } = await loginAsTestUser();
await revisePage.goto(groupId);

const download = await revisePage.downloadMetadataTemplate();
let download = await revisePage.downloadTsvMetadataTemplate();

expect(download.suggestedFilename()).toBe('Test_Dummy_Organism_metadata_revision_template.tsv');
const content = await getDownloadedContent(download);
expect(content).toStrictEqual('accession\tsubmissionId\tcountry\tdate\n');

download = await revisePage.downloadXlsMetadataTemplate();
expect(download.suggestedFilename()).toBe('Test_Dummy_Organism_metadata_revision_template.xls');

download = await revisePage.downloadXlsMetadataTemplate();
expect(download.suggestedFilename()).toBe('Test_Dummy_Organism_metadata_revision_template.xlsx');
});

async function getDownloadedContent(download: Download) {
Expand Down

0 comments on commit 92f2556

Please sign in to comment.