Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions JeMPI_Apps/JeMPI_UI/cypress/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference types="cypress" />
describe('Dashboard Component', () => {
beforeEach(() => {
cy.visit('/')
Expand Down
86 changes: 86 additions & 0 deletions JeMPI_Apps/JeMPI_UI/cypress/e2e/dropzone.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/// <reference types="cypress" />

describe('It renders dropzone correctly', () => {
beforeEach(() => {
cy.visit('/import')
})
it('should open the file dialog when clicking on the SVG icon', () => {
cy.get('#upload-file-icon').click()
})

it('displays the threshold section with sliders and text fields', () => {
cy.contains('Threshold').should('be.visible')
cy.get('.MuiSlider-root').should('have.length', 2)
cy.get('input[name="minThreshold"]').should('be.visible')
cy.get('input[name="linkThreshold"]').should('be.visible')
cy.get('input[name="maxThreshold"]').should('be.visible')
cy.get('input[name="marginWindowSize"]').should('be.visible')
})

it('toggles between report options', () => {
cy.contains('Reports').should('be.visible')

cy.get('input[value="false"]').should('be.checked')
cy.get('input[value="true"]').should('not.be.checked')

cy.get('input[value="true"]').check()
cy.get('input[value="true"]').should('be.checked')
cy.get('input[value="false"]').should('not.be.checked')
})

it('toggles between upload workflow options', () => {
cy.contains('Send to the linker and use the current M & U values').should(
'be.visible'
)
cy.contains('Send to EM task to compute new M & U values').should(
'be.visible'
)

cy.get('input[name="uploadWorkflow"][value="0"]').should('be.checked')
cy.get('input[name="uploadWorkflow"][value="1"]').should('not.be.checked')

cy.get('input[name="uploadWorkflow"][value="1"]').check()
cy.get('input[name="uploadWorkflow"][value="1"]').should('be.checked')
cy.get('input[name="uploadWorkflow"][value="0"]').should('not.be.checked')
})

it('interacts with sliders', () => {
// Drag the slider to a different value
cy.get('.MuiSlider-root').eq(0).invoke('val', 0.5).trigger('change')
cy.get('.MuiSlider-root').eq(0).should('have.value', '0.5') // Adjust selector based on slider

cy.get('.MuiSlider-root').eq(1).invoke('val', 0.7).trigger('change')
cy.get('.MuiSlider-root').eq(1).should('have.value', '0.7') // Adjust selector based on slider
})

it('uploads a file and verifies upload status', () => {
const fileName = 'basic1000.csv'
cy.fixture(fileName).then(fileContent => {
cy.get('input[type="file"]').attachFile({
fileContent,
fileName,
mimeType: 'text/csv'
})
})
cy.contains(fileName).should('be.visible')

cy.get('button').contains('Submit').click()

cy.contains('file imported').should('be.visible')
})

it('can cancel file upload', () => {
const fileName = 'basic1000.csv'
cy.fixture(fileName).then(fileContent => {
cy.get('input[type="file"]').attachFile({
fileContent,
fileName,
mimeType: 'text/csv'
})
})

cy.get('button').contains('Cancel').click()

cy.get('input[type="file"]').should('not.have.value')
})
})
41 changes: 41 additions & 0 deletions JeMPI_Apps/JeMPI_UI/cypress/e2e/import.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/// <reference types="cypress" />
describe('Import Component', () => {
beforeEach(() => {
cy.visit('/import')
})

it('should display the UploadFileIcon', () => {
cy.get(
'#root > div.MuiBox-root.css-k008qs > main > div.MuiContainer-root.css-ur2jdm-MuiContainer-root > div.MuiStack-root.css-1lqoyt0-MuiStack-root > div > div > div > div.MuiGrid-root.MuiGrid-container.MuiGrid-item.MuiGrid-direction-xs-column.MuiGrid-grid-xs-12.MuiGrid-grid-lg-6.css-vlgb4c-MuiGrid-root > div.MuiGrid-root.MuiGrid-item.MuiGrid-grid-xs-8.css-wp27ow-MuiGrid-root > div > div > svg'
)
.should('exist')
.should('have.attr', 'data-testid', 'UploadFileIcon')
})

it('Uploads CSV', () => {
cy.fixture('basic1000.csv').then(fileContent => {
cy.get('input[type="file"]').attachFile({
fileContent: fileContent.toString(),
fileName: 'CSV',
mimeType: 'text/csv'
})
cy.get('#submit-csv').click()
})
})

it('should open the file dialog when clicking on the SVG icon', () => {
cy.get('#upload-file-icon').click()
})

it('should render the PageHeader component with the correct title and breadcrumbs', () => {
cy.get('#page-header').contains('Import')
})

it('should render the DropZone component', () => {
cy.get('input[type="file"]').should('exist')
})

it('displays the machine learning configuration section', () => {
cy.contains('Machine Learning Configuration').should('be.visible')
})
})
2 changes: 2 additions & 0 deletions JeMPI_Apps/JeMPI_UI/cypress/e2e/notifications.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="cypress" />

describe('Notifications', () => {
beforeEach(() => {
cy.visit('/notifications')
Expand Down
1 change: 1 addition & 0 deletions JeMPI_Apps/JeMPI_UI/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@

// cypress/support/commands.ts

import 'cypress-file-upload';

2 changes: 1 addition & 1 deletion JeMPI_Apps/JeMPI_UI/cypress/ts.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"noEmit": true,
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node", "jest"]
"types": ["cypress", "node", "jest","cypress-file-upload"]
},
"include": ["**/*.ts"]
}
Loading