Skip to content

Commit

Permalink
work on e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-ji committed Sep 26, 2023
1 parent 14aa817 commit b54161f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
name: benchmarks
path: e2e/results/
retention-days: 30
27 changes: 24 additions & 3 deletions e2e/tests/pageload.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { test, expect } from '@playwright/test';
import fs from 'fs';

let errors: string[] = [];

test.beforeEach(async ({ page }) => {
Expand All @@ -27,13 +26,35 @@ const downloadFile = async (page, identifier: string, location: string) => {
await download.saveAs(location + download.suggestedFilename());
}


test('run example data', async ({ page, browserName }) => {
test.setTimeout(15000);
await page.getByTestId('load-example-data').click();
await page.getByTestId('run').click();
await expect(page.getByTestId('output-text')).toHaveValue(/Done! Time Elapsed:/);

await expect(page.getByTestId('output-text')).toHaveValue(/Done! Time Elapsed:/, { timeout: 10000 });
const timeElapsed = (await page.getByTestId('duration-text').textContent())?.replace(/[^0-9\.]/g, '') ?? '-1';
await expect(parseFloat(timeElapsed)).toBeGreaterThan(0);
await downloadFile(page, 'Download', 'e2e/results/' + browserName + '/example/');
fs.appendFileSync('e2e/results/' + browserName + '/example/time.txt', timeElapsed);
});

const runBenchmark = async (page, browserName: string, alignmentFiles: string[], referenceFile, downloadedLocation: string, runTimeout: number) => {
test.setTimeout(runTimeout + 15000);
await page.getByTestId('alignment-files').setInputFiles(...alignmentFiles);
await page.getByTestId('reference-file').setInputFiles(referenceFile);
await page.getByTestId('run').click();

await expect(page.getByTestId('output-text')).toHaveValue(/Done! Time Elapsed:/, { timeout: runTimeout });
const timeElapsed = (await page.getByTestId('duration-text').textContent())?.replace(/[^0-9\.]/g, '') ?? '-1';
await expect(parseFloat(timeElapsed)).toBeGreaterThan(0);
await downloadFile(page, 'Download Consensus FASTA', 'e2e/results/' + browserName + '/' + downloadedLocation + '/');
fs.appendFileSync('e2e/results/' + browserName + '/' + downloadedLocation + '/time.txt', timeElapsed);
}

test('run example data - uploaded', async ({ page, browserName }) => {
await runBenchmark(page, browserName, ['./public/data/example.bam'], './public/data/NC_045512.2.fas', 'example-uploaded', 10000);
});

test('run large data set', async ({ page, browserName }) => {
await runBenchmark(page, browserName, ['./public/data/reads.fastq.gz'], './public/data/NC_045512.2.fas', 'large dataset', 240000);
});
Binary file added public/data/reads.fastq.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ export class App extends Component {
<div id="input-content">
<div className="d-flex flex-column mb-4">
<label htmlFor="alignment-files" className="form-label">Upload Input Reads File(s) (BAM, SAM, FASTQ(s))<span className="text-danger"> *</span></label>
<input className={`form-control ${!this.state.alignmentFilesValid && 'is-invalid'}`} type="file" multiple accept=".sam,.bam,.fastq,.fastq.gz,.fq,.fq.gz" id="alignment-files" onChange={this.uploadAlignmentFiles} />
<input className={`form-control ${!this.state.alignmentFilesValid && 'is-invalid'}`} type="file" multiple accept=".sam,.bam,.fastq,.fastq.gz,.fq,.fq.gz" id="alignment-files" data-testid="alignment-files" onChange={this.uploadAlignmentFiles} />
{this.state.alignmentFiles === 'EXAMPLE_DATA' &&
<p className="mt-2 mb-0"><strong>Using Loaded Example file: <a
href={`${import.meta.env.BASE_URL || ''}${EXAMPLE_ALIGNMENT_FILE}`}
Expand Down Expand Up @@ -760,7 +760,7 @@ export class App extends Component {
<div className="d-flex flex-column mb-4">
<label htmlFor="reference-file" className="form-label">Reference File (FASTA)<span className="text-danger"> *</span></label>
<div className="input-group">
<input className={`form-control ${!this.state.refFileValid && 'is-invalid'}`} type="file" id="reference-file" onChange={this.uploadRefFile} />
<input className={`form-control ${!this.state.refFileValid && 'is-invalid'}`} type="file" id="reference-file" data-testid="reference-file" onChange={this.uploadRefFile} />
<button className="btn btn-outline-danger" type="button" id="reference-file-addon" onClick={this.clearRefFile}><i className="bi bi-trash"></i></button>
</div>
</div>
Expand Down

0 comments on commit b54161f

Please sign in to comment.