Skip to content

Commit

Permalink
Merge pull request #20 from bcgov/EMSEDT-194_Dry_Run_File_Error_Check
Browse files Browse the repository at this point in the history
EMSEDT-194: Dry Run
  • Loading branch information
barrfalk authored Jul 17, 2024
2 parents c2d4ce1 + ff331c3 commit f0a992e
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 33 deletions.
19 changes: 0 additions & 19 deletions frontend/cypress/e2e/home-page.cy.ts

This file was deleted.

93 changes: 93 additions & 0 deletions frontend/cypress/e2e/upload-file-page.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/// <reference types="cypress" />
const testData = [
{
numFiles: 1,
filepath: 'cypress/testUploadFiles/cypressTestTxt.txt',
description: 'drag and drop one text file',
filename: ['cypressTestTxt.txt'],
},
{
numFiles: 1,
filepath: 'cypress/testUploadFiles/cypressTestCSV.csv',
description: 'drag and drop one csv file',
filename: ['cypressTestCSV.csv'],
},
{
numFiles: 1,
filepath: 'cypress/testUploadFiles/cypressTestXLSX.xlsx',
description: 'drag and drop one xlsx file',
filename: ['cypressTestXLSX.xlsx'],
},
{
numFiles: 3,
filepath: [
'cypress/testUploadFiles/cypressTestTxt.txt',
'cypress/testUploadFiles/cypressTestCSV.csv',
'cypress/testUploadFiles/cypressTestXLSX.xlsx',
],
description: 'drag and drop one text file, csv and xlsx file',
filename: [
'cypressTestTxt.txt',
'cypressTestCSV.csv',
'cypressTestXLSX.xlsx',
],
},
]

describe('File Upload page functionality', () => {
beforeEach(function () {
cy.viewport('macbook-16')
cy.kcLogout().kcLogin()
})

it('should be on the submit page', () => {
cy.get('.MuiTypography-h3').should(
'have.text',
'Electronic Data Transfer - Upload',
)
})

testData.forEach((data) => {
it('should ' + data.description, () => {
cy.get('#file-upload').selectFile(data.filepath, {
action: 'drag-drop',
})

if (data.numFiles == 1) {
cy.get('#file-list-dropdown > label').should(
'have.text',
'1 files selected',
)
} else if (data.numFiles == 3) {
cy.get('#file-list-dropdown > label').should(
'have.text',
'3 files selected',
)
}

cy.get('#select-all-checkbox').should('be.checked')
cy.get('#select-all-text').should('have.text', 'Select All')

for (var i = 0; i < data.numFiles; i++) {
cy.get('#selected-file-' + i)
.children()
.first()
.should('have.text', data.filename[i])
cy.get('#delete-file-' + i).should('exist')
cy.get('#selected-file-' + i + '-checkbox').should('be.checked')
cy.get('#selected-file-' + i + '-text').should(
'have.text',
'Receive Email Conformation',
)
cy.get('#selected-file-' + i + '-validate').should(
'have.text',
'Validate',
)
cy.get('#selected-file-' + i + '-submit').should('have.text', 'Submit')

cy.get('#all-files-validate').should('have.text', 'Validate All')
cy.get('#all-files-submit').should('have.text', 'Submit All')
}
})
})
})
17 changes: 17 additions & 0 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,20 @@ function extractTopLevelDomain(url: string): string {

return tld
}

Cypress.Commands.add("kcLogout", () => {
Cypress.log({ name: "Logout" });
const authBaseUrl = Cypress.env("auth_base_url");
const realm = Cypress.env("auth_realm");
cy.request({
url: `${authBaseUrl}/realms/${realm}/protocol/openid-connect/logout`,
});
cy.visit(Cypress.config().baseUrl);
cy.on("uncaught:exception", (e) => {
if (e.message.includes("Unexpected")) {
// we expected this error, so let's ignore it
// and let the test continue
return false;
}
});
});
1 change: 1 addition & 0 deletions frontend/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
declare namespace Cypress {
interface Chainable {
kcLogin(): Chainable<Element>;
kcLogout(): Chainable<any>;
}
}
24 changes: 24 additions & 0 deletions frontend/cypress/testUploadFiles/cypressTestCSV.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Observation ID,Location ID,Observed Property ID,Observed DateTime,Analyzed DateTime,Depth,Depth Unit,Data Classification,Result Value,Result Unit,Source of Rounded Value,Rounded Value,Rounding Specification,Result Status,Result Grade,Medium,Activity ID,Activity Name,Collection Method,Field: Device ID,Field: Device Type,Field: Comment,Lab: Specimen Name,Lab: Analysis Method,Lab: Detection Condition,Lab: Limit Type,Lab: MDL,Lab: MRL,Lab: Quality Flag,Lab: Received DateTime,Lab: Prepared DateTime,Lab: Sample Fraction,Lab: From Laboratory,Lab: Sample ID,Lab: Dilution Factor,Lab: Comment,QC: Type,QC: Source Sample ID,EA_DELETE - Depth Lower,EA_DELETE - Laboratory Name,EA_DELETE - Project,EA_DELETE - Sample Detail,EA_DELETE - Sampler,EA_Statistic,EA_TissueType
,DemoImportLoc001,Alkalinity,2015-01-01 12:00,2015-01-02 12:00,5,m,LAB,13.4,mg/l,PROVIDED_BY_USER,5.12,,Preliminary,Ok,Water,,SA-20150101-01,GRAB,,,,Loc001_Bottle_01,2320;Alkalinity in Water by Titration;APHA,,LOWER,0.1,0.5,,2015-01-02 12:00,2015-01-02 12:00,DISSOLVED,,,,,,,,,,,,,
,DemoImportLoc001,Alkalinity,2015-01-01 12:01,2015-01-02 12:01,10,m,LAB,11.4,mg/l,PROVIDED_BY_USER,6.12,,Preliminary,Ok,Other,,SA-20150101-02,,,,,Loc001_Bottle_01,2320;Alkalinity in Water by Titration;APHA,,LOWER,0.1,0.5,,2015-01-02 12:00,2015-01-02 12:00,,,,,,,,,,,,,,
,DemoImportLoc001,Alkalinity,2015-01-01 12:00,2015-01-02 12:00,5,m,LAB,13.4,mg/l,PROVIDED_BY_USER,7.12,,Preliminary,Ok,Water,,SA-20150101-01_REP,GRAB,,,,Loc001_Bottle_01,2320;Alkalinity in Water by Titration;APHA,,LOWER,0.1,0.5,,2015-01-02 12:00,2015-01-02 12:00,DISSOLVED,,,,,Replicate,SA-20150101-01,,,,,,,
,DemoImportLoc001,Alkalinity,2015-01-01 12:01,2015-01-02 12:01,10,m,LAB,11.4,mg/l,PROVIDED_BY_USER,8.12,,Preliminary,Ok,Other,,SA-20150101-02_REP,,,,,Loc001_Bottle_01,2320;Alkalinity in Water by Titration;APHA,,LOWER,0.1,0.5,,2015-01-02 12:00,2015-01-02 12:00,,,,,,Replicate,SA-20150101-02,,,,,,,
,DemoImportLoc001,Alkalinity,2015-01-01 12:00,2015-01-02 12:00,5,m,LAB,,,PROVIDED_BY_USER,9.12,,Preliminary,Ok,Water,,SA-20150101-01_TB,GRAB,,,,Loc001_Bottle_01,2320;Alkalinity in Water by Titration;APHA,,,,,,,,,,,,,Blank,,,,,,,,
,DemoImportLoc002,Alkalinity,2015-01-01 12:05,2015-01-02 12:05,12,m,LAB,46.3,mg/l,PROVIDED_BY_USER,10.12,,Preliminary,Ok,Biological,,,GRAB,,,,Loc001_Bottle_01,2320;Alkalinity in Water by Titration;APHA,,LOWER,0.1,0.5,,2015-01-02 12:05,2015-01-02 12:05,DISSOLVED,,,,,,,,,,,,,
,DemoImportLoc002,Alkalinity,2015-01-01 12:30,2015-01-02 12:30,8,m,LAB,,mg/l,PROVIDED_BY_USER,11.12,,Preliminary,Ok,Soil,,,GRAB,,,,Loc001_Bottle_01,2320;Alkalinity in Water by Titration;APHA,Not detected,LOWER,0.1,0.5,"X,P",2015-01-02 12:30,2015-01-02 12:30,TOTAL,,,,,,,,,,,,,
,DemoImportLoc002,Alkalinity,2015-01-01 12:45,2015-01-02 13:15,15,m,LAB,,mg/l,PROVIDED_BY_USER,12.2,,Preliminary,Ok,Soil,,,GRAB,,,,Loc001_Bottle_01,2320;Alkalinity in Water by Titration;APHA,Not detected,LOWER,0.1,0.5,"X,P",2015-01-02 12:30,2015-01-02 12:30,TOTAL,,,,,,,,,,,,,
,DemoImportLoc003,Temperature,2015-06-01 09:00,,3,m,FIELD_RESULT,7,degC,PROVIDED_BY_USER,13.12,,Preliminary,Ok,Water,,,,M001-A,Multimeter Type M,muddy,,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc004,Temperature,2015-06-01 10:00,,2,m,FIELD_RESULT,8,degC,PROVIDED_BY_USER,14.12,,Preliminary,Ok,Water,,,,M001-A,Multimeter Type M,,,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc004,Temperature,2015-06-01 11:00,,2,m,FIELD_RESULT,9,degC,PROVIDED_BY_USER,15.12,,Preliminary,Ok,Water,,,,M001-A,Multimeter Type M,attacking squirrels!,,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc004,Taxon,2016-09-01 12:00,,,,FIELD_SURVEY,Salmonidae,,PROVIDED_BY_USER,16.12,,Preliminary,Ok,Water,,Activity_id_123,,,,,specimen0001,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc004,Length,2016-09-01 12:00,,,,FIELD_SURVEY,28,in,PROVIDED_BY_USER,17.12,,Preliminary,Ok,Water,,Activity_id_123,,,,,specimen0001,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc004,Color,2016-09-01 12:00,,,,FIELD_SURVEY,Silver,,PROVIDED_BY_USER,18.12,,Preliminary,Ok,Water,,Activity_id_123,,,,,specimen0001,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc004,Taxon,2016-09-01 12:00,,,,FIELD_SURVEY,Ephemeroptera,,PROVIDED_BY_USER,19.12,,Preliminary,Ok,Water,,Activity_id_124,,,,,specimen0002,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc004,Count,2016-09-01 12:00,,,,FIELD_SURVEY,65,#,PROVIDED_BY_USER,20.12,,Preliminary,Ok,Water,,Activity_id_124,,,,,specimen0002,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc004,Taxon,2016-09-01 12:00,,,,FIELD_SURVEY,Diptera,,PROVIDED_BY_USER,21.12,,Preliminary,Ok,Water,,Activity_id_124,,,,,specimen0003,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc004,Count,2016-09-01 12:00,,,,FIELD_SURVEY,99,#,ROUNDING_SPECIFICATION,22.12,SIG(4),Preliminary,Ok,Water,,Activity_id_124,,,,,specimen0003,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc004,EPT Index,2016-09-01 12:00,,,,ACTIVITY_RESULT,39.6,%,ROUNDING_SPECIFICATION,23.12,SIG(4),Reviewed,Ok,Water,,Activity_id_124,,,,(EPT Taxa / Total Taxa) * 100%,,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc002,Alkalinity,2015-01-01T12:01:00.000-07:00,,10,m,VERTICAL_PROFILE,19.4,mg/l,ROUNDING_SPECIFICATION,24.12,SIG(4),Preliminary,OK,Other,,profile_id_456,GRAB,PQR,AZXCV,top profile measurement,,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc002,Alkalinity,2015-01-01T12:02:00.000-07:00,,13,m,VERTICAL_PROFILE,12.4,mg/l,ROUNDING_SPECIFICATION,25.12,SIG(4),Preliminary,OK,Other,,profile_id_456,GRAB,ZXC,,,,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc002,Alkalinity,2015-01-01T12:03:00.000-07:00,,14,m,VERTICAL_PROFILE,13.4,mg/l,ROUNDING_SPECIFICATION,26.12,SIG(4),Preliminary,OK,Other,,profile_id_456,GRAB,VDS,,,,,,,,,,,,,,,,,,,,,,,,,,,
,DemoImportLoc002,Alkalinity,2015-01-03T12:04:00.000-07:00,,16,m,VERTICAL_PROFILE,14.4,mg/l,ROUNDING_SPECIFICATION,27.12,SIG(4),Preliminary,OK,Other,,profile_id_789,GRAB,QFA,,top profile measurement,,,,,,,,,,,,,,,,,,,,,,,,,
Empty file.
Binary file not shown.
28 changes: 14 additions & 14 deletions frontend/src/pages/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ function FileUpload() {
return (
<div style={{ marginLeft: '4em', width: '100%' }}>
<Box sx={{ width: '1200px' }}>
<Typography variant="h3" component="h1" gutterBottom>
<Typography id="pageTitle" variant="h3" component="h1" gutterBottom>
Electronic Data Transfer - Upload
</Typography>
<Typography variant="h6" component="h2" gutterBottom>
<Typography id="pageSubTitle" variant="h6" component="h2" gutterBottom>
This screen allows an authorized user to upload EMS samples and
results.
</Typography>
Expand All @@ -179,7 +179,7 @@ function FileUpload() {
maxSize={10}
onSizeError={fileSizeError}
children={
<label className="upload-container">
<label id="file-upload" className="upload-container">
<div className="upload-children">
<span>
<UploadFile width="32" height="32" fontSize="large" />
Expand All @@ -199,7 +199,7 @@ function FileUpload() {
<div className="file-drop-list">
<Grid container>
<Grid item xs={6}>
<Button sx={{ color: 'black' }} onClick={handleExpandList}>
<Button id="file-list-dropdown" sx={{ color: 'black' }} onClick={handleExpandList}>
{expandList ? <ExpandMore /> : <ChevronRight />}
{selectedFiles.length > 0 && selectedFiles.length <= 10 ? (
<label>{selectedFiles.length + ' files selected'}</label>
Expand All @@ -219,11 +219,11 @@ function FileUpload() {
selectedFiles.length > 0 &&
selectedFiles.length <= 10 ? (
<Grid item xs={6}>
<FormControlLabel
<FormControlLabel id='select-all-text'
sx={{ float: 'right' }}
value="end"
control={
<Checkbox
<Checkbox id='select-all-checkbox'
checked={checkedItems.master}
onChange={handleMasterCheckboxChange}
color="secondary"
Expand All @@ -247,7 +247,7 @@ function FileUpload() {
<ListItem key={index}>
<Grid container>
<Grid item xs={5}>
<ListItemText
<ListItemText id={'selected-file-' + index}
key="test1"
primary={file.name}
secondary={
Expand Down Expand Up @@ -275,7 +275,7 @@ function FileUpload() {
''
)}

<Button
<Button id={'delete-file-' + index}
style={{ color: 'black' }}
onClick={() => {
handleOpen(index)
Expand All @@ -286,10 +286,10 @@ function FileUpload() {
</ButtonGroup>
</Grid>
<Grid item xs={4}>
<FormControlLabel
<FormControlLabel id={'selected-file-' + index + '-text'}
sx={{ float: 'right', paddingTop: '10px' }}
control={
<Checkbox
<Checkbox id={'selected-file-' + index + '-checkbox'}
color="secondary"
checked={checkedItems.items[index]}
onChange={handleCheckboxChange(index)}
Expand Down Expand Up @@ -324,7 +324,7 @@ function FileUpload() {
paddingBottom: '10px',
}}
>
<Button
<Button id={'selected-file-' + index + '-validate'}
variant="contained"
color="secondary"
onClick={() => {
Expand All @@ -333,7 +333,7 @@ function FileUpload() {
>
Validate
</Button>
<Button
<Button id={'selected-file-' + index + '-submit'}
variant="contained"
color="secondary"
onClick={() => {
Expand Down Expand Up @@ -392,7 +392,7 @@ function FileUpload() {
<Box sx={{ paddingTop: '20px' }}>
{files && selectedFiles.length > 0 ? (
<ButtonGroup variant="text" style={{ color: 'black' }}>
<Button
<Button id={'all-files-validate'}
variant="contained"
color="secondary"
onClick={() => {
Expand All @@ -401,7 +401,7 @@ function FileUpload() {
>
Validate All
</Button>
<Button
<Button id={'all-files-submit'}
variant="contained"
color="secondary"
onClick={() => {
Expand Down

0 comments on commit f0a992e

Please sign in to comment.