-
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.
- Loading branch information
1 parent
db90ff2
commit 4bccc7e
Showing
42 changed files
with
762 additions
and
573 deletions.
There are no files selected for viewing
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,16 +1,16 @@ | ||
import { defineConfig } from "cypress"; | ||
import { defineConfig } from 'cypress' | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
e2e: { | ||
setupNodeEvents() { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}, | ||
|
||
component: { | ||
devServer: { | ||
framework: "react", | ||
bundler: "vite", | ||
component: { | ||
devServer: { | ||
framework: 'react', | ||
bundler: 'vite', | ||
}, | ||
}, | ||
}, | ||
}); | ||
}) |
134 changes: 81 additions & 53 deletions
134
frontend/frontend/cypress/component/AssignmentListItem.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,59 +1,87 @@ | ||
import { AssignmentListItem } from '../../src/components/AssignmentListItem'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import fixtures from '../fixtures/fixtures.json'; | ||
import { AssignmentListItem } from '../../src/components/AssignmentListItem' | ||
import { BrowserRouter } from 'react-router-dom' | ||
import fixtures from '../fixtures/fixtures.json' | ||
|
||
describe('AssignmentListItem', () => { | ||
const mockProps = { | ||
id: fixtures.id, | ||
projectName: fixtures.project, | ||
dueDate: new Date().toLocaleDateString(), | ||
status: false, | ||
isStudent: true, | ||
}; | ||
const mockProps = { | ||
id: fixtures.id, | ||
projectName: fixtures.project, | ||
dueDate: new Date().toLocaleDateString(), | ||
status: false, | ||
isStudent: true, | ||
} | ||
|
||
it('renders with cross', () => { | ||
cy.mount(<BrowserRouter><AssignmentListItem {...mockProps} /></BrowserRouter>); | ||
cy.get('.MuiListItem-root').should('exist'); | ||
cy.get('#project' + fixtures.id).should('exist'); | ||
cy.get('#projectName').should('contain.text', fixtures.project); | ||
cy.get('#dueDate').should('contain.text', new Date().toLocaleDateString()); | ||
cy.get('#cross').should('exist'); | ||
cy.get('#check').should('not.exist'); | ||
}); | ||
it('renders with cross', () => { | ||
cy.mount( | ||
<BrowserRouter> | ||
<AssignmentListItem {...mockProps} /> | ||
</BrowserRouter> | ||
) | ||
cy.get('.MuiListItem-root').should('exist') | ||
cy.get('#project' + fixtures.id).should('exist') | ||
cy.get('#projectName').should('contain.text', fixtures.project) | ||
cy.get('#dueDate').should( | ||
'contain.text', | ||
new Date().toLocaleDateString() | ||
) | ||
cy.get('#cross').should('exist') | ||
cy.get('#check').should('not.exist') | ||
}) | ||
|
||
it('renders with checkmark', () => { | ||
mockProps.status = true; | ||
cy.mount(<BrowserRouter><AssignmentListItem {...mockProps} /></BrowserRouter>); | ||
cy.get('.MuiListItem-root').should('exist'); | ||
cy.get('#project' + fixtures.id).should('exist'); | ||
cy.get('#projectName').should('contain.text', fixtures.project); | ||
cy.get('#dueDate').should('contain.text', new Date().toLocaleDateString()); | ||
cy.get('#cross').should('not.exist'); | ||
cy.get('#check').should('exist'); | ||
}); | ||
it('renders with checkmark', () => { | ||
mockProps.status = true | ||
cy.mount( | ||
<BrowserRouter> | ||
<AssignmentListItem {...mockProps} /> | ||
</BrowserRouter> | ||
) | ||
cy.get('.MuiListItem-root').should('exist') | ||
cy.get('#project' + fixtures.id).should('exist') | ||
cy.get('#projectName').should('contain.text', fixtures.project) | ||
cy.get('#dueDate').should( | ||
'contain.text', | ||
new Date().toLocaleDateString() | ||
) | ||
cy.get('#cross').should('not.exist') | ||
cy.get('#check').should('exist') | ||
}) | ||
|
||
it('renders with no due date', () => { | ||
mockProps.dueDate = undefined; | ||
cy.mount(<BrowserRouter><AssignmentListItem {...mockProps} /></BrowserRouter>); | ||
cy.get('.MuiListItem-root').should('exist'); | ||
cy.get('#project' + fixtures.id).should('exist'); | ||
cy.get('#projectName').should('contain.text', fixtures.project); | ||
// normaal zou hier 'no deadline' moeten staan in de correcte taal, maar blijkbaar gaat dat niet in de testen | ||
// omdat er hier niet echt een taal is ingesteld? | ||
cy.get('#dueDate').should('not.contain.text', new Date().toLocaleDateString()); | ||
cy.get('#cross').should('not.exist'); | ||
cy.get('#check').should('exist'); | ||
}); | ||
it('renders with no due date', () => { | ||
mockProps.dueDate = undefined | ||
cy.mount( | ||
<BrowserRouter> | ||
<AssignmentListItem {...mockProps} /> | ||
</BrowserRouter> | ||
) | ||
cy.get('.MuiListItem-root').should('exist') | ||
cy.get('#project' + fixtures.id).should('exist') | ||
cy.get('#projectName').should('contain.text', fixtures.project) | ||
// normaal zou hier 'no deadline' moeten staan in de correcte taal, maar blijkbaar gaat dat niet in de testen | ||
// omdat er hier niet echt een taal is ingesteld? | ||
cy.get('#dueDate').should( | ||
'not.contain.text', | ||
new Date().toLocaleDateString() | ||
) | ||
cy.get('#cross').should('not.exist') | ||
cy.get('#check').should('exist') | ||
}) | ||
|
||
it('renders as teacher', () => { | ||
mockProps.isStudent = false; | ||
mockProps.dueDate = new Date().toLocaleDateString(); | ||
cy.mount(<BrowserRouter><AssignmentListItem {...mockProps} /></BrowserRouter>); | ||
cy.get('.MuiListItem-root').should('exist'); | ||
cy.get('#project' + fixtures.id).should('exist'); | ||
cy.get('#projectName').should('contain.text', fixtures.project); | ||
cy.get('#dueDate').should('contain.text', new Date().toLocaleDateString()); | ||
cy.get('#cross').should('not.exist'); | ||
cy.get('#check').should('not.exist'); | ||
}); | ||
}); | ||
it('renders as teacher', () => { | ||
mockProps.isStudent = false | ||
mockProps.dueDate = new Date().toLocaleDateString() | ||
cy.mount( | ||
<BrowserRouter> | ||
<AssignmentListItem {...mockProps} /> | ||
</BrowserRouter> | ||
) | ||
cy.get('.MuiListItem-root').should('exist') | ||
cy.get('#project' + fixtures.id).should('exist') | ||
cy.get('#projectName').should('contain.text', fixtures.project) | ||
cy.get('#dueDate').should( | ||
'contain.text', | ||
new Date().toLocaleDateString() | ||
) | ||
cy.get('#cross').should('not.exist') | ||
cy.get('#check').should('not.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,82 @@ | ||
import { CourseCard } from '../../src/components/CourseCard'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import fixtures from '../fixtures/fixtures.json'; | ||
import { CourseCard } from '../../src/components/CourseCard' | ||
import { BrowserRouter } from 'react-router-dom' | ||
import fixtures from '../fixtures/fixtures.json' | ||
|
||
describe('CourseCard', () => { | ||
const mockProps = { | ||
courseId: fixtures.id, | ||
archived: false, | ||
isStudent: true, | ||
}; | ||
} | ||
|
||
it('renders as student', () => { | ||
cy.mount(<BrowserRouter><CourseCard {...mockProps} /></BrowserRouter>); | ||
cy.mount( | ||
<BrowserRouter> | ||
<CourseCard {...mockProps} /> | ||
</BrowserRouter> | ||
) | ||
// data is fetched from the backend, so we can't check that | ||
cy.get('.MuiCard-root').should('exist'); | ||
cy.get('.MuiCardContent-root').should('exist'); | ||
cy.get('#courseInfo').should('have.text', 'undefined: undefined: 0').click(); | ||
cy.get('#student').should('exist'); | ||
cy.get('#teacherArchived').should('not.exist'); | ||
cy.get('#teacherNonArchived').should('not.exist'); | ||
cy.get('#project').contains('Project'); | ||
cy.get('#deadline').contains('Deadline'); | ||
cy.get('#status').contains('Status'); | ||
cy.get('#archiveButton').should('not.exist'); | ||
}); | ||
cy.get('.MuiCard-root').should('exist') | ||
cy.get('.MuiCardContent-root').should('exist') | ||
cy.get('#courseInfo') | ||
.should('have.text', 'undefined: undefined: 0') | ||
.click() | ||
cy.get('#student').should('exist') | ||
cy.get('#teacherArchived').should('not.exist') | ||
cy.get('#teacherNonArchived').should('not.exist') | ||
cy.get('#project').contains('Project') | ||
cy.get('#deadline').contains('Deadline') | ||
cy.get('#status').contains('Status') | ||
cy.get('#archiveButton').should('not.exist') | ||
}) | ||
|
||
it('renders archived as teacher', () => { | ||
const mockProps = { | ||
courseId: fixtures.id, | ||
archived: true, | ||
isStudent: false, | ||
}; | ||
cy.mount(<BrowserRouter><CourseCard {...mockProps} /></BrowserRouter>); | ||
cy.get('.MuiCard-root').should('exist'); | ||
cy.get('.MuiCardContent-root').should('exist'); | ||
cy.get('#courseInfo').should('have.text', 'undefined: undefined: 0').click(); | ||
cy.get('#student').should('not.exist'); | ||
cy.get('#teacherArchived').should('exist'); | ||
cy.get('#teacherNonArchived').should('not.exist'); | ||
cy.get('#project').contains('Project'); | ||
cy.get('#deadline').contains('Deadline'); | ||
cy.get('#status').should('not.exist'); | ||
cy.get('#archiveButton').should('not.exist'); | ||
}); | ||
} | ||
cy.mount( | ||
<BrowserRouter> | ||
<CourseCard {...mockProps} /> | ||
</BrowserRouter> | ||
) | ||
cy.get('.MuiCard-root').should('exist') | ||
cy.get('.MuiCardContent-root').should('exist') | ||
cy.get('#courseInfo') | ||
.should('have.text', 'undefined: undefined: 0') | ||
.click() | ||
cy.get('#student').should('not.exist') | ||
cy.get('#teacherArchived').should('exist') | ||
cy.get('#teacherNonArchived').should('not.exist') | ||
cy.get('#project').contains('Project') | ||
cy.get('#deadline').contains('Deadline') | ||
cy.get('#status').should('not.exist') | ||
cy.get('#archiveButton').should('not.exist') | ||
}) | ||
|
||
it('renders non-archived as teacher', () => { | ||
const mockProps = { | ||
courseId: fixtures.id, | ||
archived: false, | ||
isStudent: false, | ||
}; | ||
cy.mount(<BrowserRouter><CourseCard {...mockProps} /></BrowserRouter>); | ||
cy.get('.MuiCard-root').should('exist'); | ||
cy.get('.MuiCardContent-root').should('exist'); | ||
cy.get('#courseInfo').should('have.text', 'undefined: undefined: 0').click(); | ||
cy.get('#student').should('not.exist'); | ||
cy.get('#teacherArchived').should('not.exist'); | ||
cy.get('#teacherNonArchived').should('exist'); | ||
cy.get('#project').contains('Project'); | ||
cy.get('#deadline').contains('Deadline'); | ||
cy.get('#status').should('not.exist'); | ||
cy.get('#archiveButton').should('exist'); | ||
}); | ||
}); | ||
} | ||
cy.mount( | ||
<BrowserRouter> | ||
<CourseCard {...mockProps} /> | ||
</BrowserRouter> | ||
) | ||
cy.get('.MuiCard-root').should('exist') | ||
cy.get('.MuiCardContent-root').should('exist') | ||
cy.get('#courseInfo') | ||
.should('have.text', 'undefined: undefined: 0') | ||
.click() | ||
cy.get('#student').should('not.exist') | ||
cy.get('#teacherArchived').should('not.exist') | ||
cy.get('#teacherNonArchived').should('exist') | ||
cy.get('#project').contains('Project') | ||
cy.get('#deadline').contains('Deadline') | ||
cy.get('#status').should('not.exist') | ||
cy.get('#archiveButton').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
9 changes: 6 additions & 3 deletions
9
frontend/frontend/cypress/component/GroupAccessComponent.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,17 +1,20 @@ | ||
import { GroupAccessComponent } from '../../src/components/GroupAccessComponent' | ||
import { BrowserRouter } from 'react-router-dom' | ||
|
||
|
||
describe('GroupAccessComponent', () => { | ||
const mockProps = { | ||
assignmentid: 1, | ||
courseid: 1, | ||
} | ||
|
||
it('toggles group access', () => { | ||
cy.mount(<BrowserRouter><GroupAccessComponent {...mockProps} /></BrowserRouter>) | ||
cy.mount( | ||
<BrowserRouter> | ||
<GroupAccessComponent {...mockProps} /> | ||
</BrowserRouter> | ||
) | ||
cy.get('#groupButton').should('not.exist') | ||
cy.get('#groupSwitch').click() | ||
cy.get('#groupButton').should('exist') | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.