-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
addChangeAssignmentPage component testen
- Loading branch information
1 parent
70055c3
commit 1fb7248
Showing
5 changed files
with
66 additions
and
85 deletions.
There are no files selected for viewing
68 changes: 15 additions & 53 deletions
68
frontend/frontend/cypress/page/addChangeAssignmentPage/AddChangeAssignmentPage.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,18 @@ | ||
import {AddChangeAssignmentPage} from '../../../src/pages/addChangeAssignmentPage/AddChangeAssignmentPage'; // Check if the file path is correct and if the required module exists in the specified location. | ||
import {BrowserRouter} from 'react-router-dom'; | ||
import fixtures from '../../fixtures/fixtures.json'; | ||
import { AddChangeAssignmentPage } from '../../../src/pages/addChangeAssignmentPage/AddChangeAssignmentPage' // Check if the file path is correct and if the required module exists in the specified location. | ||
import { BrowserRouter } from 'react-router-dom' | ||
|
||
// This page fetches data from the backend. | ||
// So as far as the component test is concerned, | ||
// we can only show what shows up before the fetch. | ||
// This is why only the loading animation is checked. | ||
// The rest of the tests are in the integration tests. | ||
describe('AddChangeAssignmentPage', () => { | ||
|
||
it('renders assignment name', () => { | ||
cy.mount(<BrowserRouter><AddChangeAssignmentPage/></BrowserRouter>); | ||
// check if the header is rendered | ||
cy.get('#logo').should('exist'); | ||
cy.get('#userMenu').should('exist'); | ||
// title field | ||
cy.get('#titleField').should('have.attr', 'placeholder', 'Title'); | ||
cy.get('#titleField').type('New title'); | ||
cy.get('#titleField').should('have.value', 'New title'); | ||
cy.get('#uploadButton').should('exist'); | ||
// deadline field | ||
cy.get('#deadline').should('have.text', 'Deadline:'); | ||
cy.get('#deadlineField').should('have.attr', 'placeholder', 'DD/MM/YYYY hh:mm'); | ||
cy.get('#deadlineField').type('311220252359'); | ||
cy.get('#deadlineField').should('have.value', '31/12/2025 23:59'); | ||
// extra deadline field | ||
cy.get('#extraDeadline').should('have.text', 'Extra Deadline:'); | ||
cy.get('#extraDeadlineField').should('have.attr', 'placeholder', 'DD/MM/YYYY hh:mm'); | ||
cy.get('#extraDeadlineField').type('311220262359'); | ||
cy.get('#extraDeadlineField').should('have.value', '31/12/2026 23:59'); | ||
//description field | ||
cy.get('#descriptionField').should('have.attr', 'placeholder', 'Description'); | ||
cy.get('#descriptionField').type('New description'); | ||
cy.get('#descriptionField').should('have.value', 'New description'); | ||
// restrictions field | ||
cy.get('#addRestrictionButton').should('exist').click(); | ||
cy.get('#upload').should('exist'); | ||
cy.get('#newScript').should('exist'); | ||
cy.get('#fileExtensionCheck').should('exist'); | ||
cy.get('#filesPresentCheck').should('exist'); | ||
cy.get('#mustPassSwitch').should('exist'); | ||
cy.get('#cancelButton').should('exist').click(); | ||
// max score field | ||
cy.get('#maxScore').should('have.text', 'Max Score:'); | ||
cy.get('#maxScoreField').should('have.value', '20'); | ||
cy.get('#maxScoreField').clear().type('30'); | ||
cy.get('#maxScoreField').should('have.value', '30'); | ||
// all buttons | ||
cy.get('#visibilityOff').should('exist').click(); | ||
cy.get('#visibilityOn').should('exist').click(); | ||
cy.get('#cancel').should('exist').click(); | ||
// these have popups | ||
cy.get('#submit').should('exist').click(); | ||
cy.get('#cancelButton').should('exist').click(); | ||
cy.get('#delete').should('exist').click(); | ||
cy.get('#actionButton').should('exist').click(); | ||
|
||
}); | ||
|
||
}); | ||
cy.mount( | ||
<BrowserRouter> | ||
<AddChangeAssignmentPage /> | ||
</BrowserRouter> | ||
) | ||
cy.get('[data-cy=loadingAnimation]').should('exist') | ||
}) | ||
}) |
31 changes: 15 additions & 16 deletions
31
frontend/frontend/cypress/page/addChangeAssignmentPage/AddRestrictionButton.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
import AddRestrictionButton from '../../../src/pages/addChangeAssignmentPage/AddRestrictionButton'; | ||
import {BrowserRouter} from 'react-router-dom'; | ||
import AddRestrictionButton from '../../../src/pages/addChangeAssignmentPage/AddRestrictionButton' | ||
import { BrowserRouter } from 'react-router-dom' | ||
|
||
describe('AddRestrictionsButton', () => { | ||
|
||
const mockProps = { | ||
restrictions: [], | ||
setRestrictions: () => {} | ||
}; | ||
setRestrictions: () => {}, | ||
} | ||
|
||
it('renders the restrictions add button', () => { | ||
cy.mount(<BrowserRouter><AddRestrictionButton {...mockProps} /></BrowserRouter>); | ||
cy.get('#addRestrictionButton').should('exist').click(); | ||
cy.get('#upload').should('exist'); | ||
cy.get('#newScript').should('exist'); | ||
cy.get('#fileExtensionCheck').should('exist'); | ||
cy.get('#filesPresentCheck').should('exist'); | ||
cy.get('#mustPassSwitch').should('exist').click(); | ||
cy.get('#cancelButton').should('exist').click(); | ||
}); | ||
|
||
}); | ||
cy.mount( | ||
<BrowserRouter> | ||
<AddRestrictionButton {...mockProps} /> | ||
</BrowserRouter> | ||
) | ||
cy.get('#addRestrictionButton').should('exist').click() | ||
cy.get('#upload').should('exist') | ||
cy.get('#newScript').should('exist') | ||
cy.get('#cancelButton').should('exist').click() | ||
}) | ||
}) |
36 changes: 23 additions & 13 deletions
36
frontend/frontend/cypress/page/addChangeAssignmentPage/RestrictionsDialog.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
import RestrictionsDialog from '../../../src/pages/addChangeAssignmentPage/RestrictionsDialog'; | ||
import {BrowserRouter} from 'react-router-dom'; | ||
import RestrictionsDialog from '../../../src/pages/addChangeAssignmentPage/RestrictionsDialog' | ||
import { BrowserRouter } from 'react-router-dom' | ||
|
||
describe('RestrictionsDialog', () => { | ||
|
||
const mockProps = { | ||
userid: 1, | ||
restrictions: [], | ||
setRestrictions: () => {}, | ||
closeParentDialog: () => {}, | ||
}; | ||
} | ||
|
||
it('renders the dialog', () => { | ||
cy.mount(<BrowserRouter><RestrictionsDialog {...mockProps} /></BrowserRouter>); | ||
cy.get('#upload').should('exist'); | ||
cy.get('#newScript').should('exist'); | ||
cy.get('#fileExtensionCheck').should('exist'); | ||
cy.get('#filesPresentCheck').should('exist'); | ||
cy.get('#mustPassSwitch').should('exist').click(); | ||
}); | ||
|
||
}); | ||
cy.mount( | ||
<BrowserRouter> | ||
<RestrictionsDialog {...mockProps} /> | ||
</BrowserRouter> | ||
) | ||
cy.get('[data-cy=new_scripts_section]').should('exist') | ||
cy.get('#upload').should('exist') | ||
cy.get('[data-cy=uploadInput]').should('exist') | ||
cy.get('#newScript').should('exist') | ||
cy.get('[data-cy=existing_scripts_section]').should('exist') | ||
cy.get('#newScript').click() | ||
cy.get('[data-cy=closeIcon]').should('exist') | ||
cy.get('#scriptName').should('exist') | ||
cy.get('#extension').should('exist') | ||
cy.get('#saveTemplate').should('exist') | ||
cy.get('#saveScript').should('exist') | ||
cy.get('#scriptContent').should('exist') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters