Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnoutAllaert committed May 23, 2024
1 parent db90ff2 commit 4bccc7e
Show file tree
Hide file tree
Showing 42 changed files with 762 additions and 573 deletions.
22 changes: 11 additions & 11 deletions frontend/frontend/cypress.config.ts
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 frontend/frontend/cypress/component/AssignmentListItem.cy.tsx
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')
})
})
104 changes: 61 additions & 43 deletions frontend/frontend/cypress/component/CourseCard.cy.tsx
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')
})
})
43 changes: 23 additions & 20 deletions frontend/frontend/cypress/component/FileUploadButton.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import InputFileUpload from '../../src/components/FileUploadButton';
import fixtures from '../fixtures/fixtures.json';
import InputFileUpload from '../../src/components/FileUploadButton'
import fixtures from '../fixtures/fixtures.json'

describe('FileUploadButton', () => {
const mockProps = {
Expand All @@ -8,25 +8,28 @@ describe('FileUploadButton', () => {
onFileChange: () => {},
fileTypes: ['pdf'],
path: '../fixtures/test.pdf',
};
}

it('renders', () => {
cy.mount(<InputFileUpload {...mockProps} />);
cy.get('#uploadButton').should('exist').should('have.text', fixtures.name);
cy.get('input[type=file]').should('exist');
cy.contains(fixtures.tooltip).should('not.exist');
cy.get('#uploadButton').trigger('mouseover');
cy.contains(fixtures.tooltip).should('be.visible');
cy.get('#uploadButton').trigger('mouseout');
cy.contains(fixtures.tooltip).should('not.exist');
cy.get('#clearButton').should('exist');
});
cy.mount(<InputFileUpload {...mockProps} />)
cy.get('#uploadButton')
.should('exist')
.should('have.text', fixtures.name)
cy.get('input[type=file]').should('exist')
cy.contains(fixtures.tooltip).should('not.exist')
cy.get('#uploadButton').trigger('mouseover')
cy.contains(fixtures.tooltip).should('be.visible')
cy.get('#uploadButton').trigger('mouseout')
cy.contains(fixtures.tooltip).should('not.exist')
cy.get('#clearButton').should('exist')
})

it('no path', () => {
mockProps.path = '';
cy.mount(<InputFileUpload {...mockProps} />);
cy.get('#uploadButton').should('exist').should('have.text', fixtures.name);
cy.get('#clearButton').should('not.exist');
});

});
mockProps.path = ''
cy.mount(<InputFileUpload {...mockProps} />)
cy.get('#uploadButton')
.should('exist')
.should('have.text', fixtures.name)
cy.get('#clearButton').should('not.exist')
})
})
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')
})
})
})
Loading

0 comments on commit 4bccc7e

Please sign in to comment.