Skip to content

Commit

Permalink
Merge pull request #4688 from UniversityOfHelsinkiCS/material-ui-univ…
Browse files Browse the repository at this point in the history
…ersity

Material UI: University
  • Loading branch information
rikurauhala authored Nov 26, 2024
2 parents dad7ddc + ec5cfcc commit 4b37fd4
Show file tree
Hide file tree
Showing 40 changed files with 1,735 additions and 173 deletions.
159 changes: 48 additions & 111 deletions cypress/e2e/University.js
Original file line number Diff line number Diff line change
@@ -1,159 +1,96 @@
/// <reference types="cypress" />

const levels = ['Bachelors', 'BachelorMasters', 'Masters', 'Doctoral']
const progressLevels = ['Bachelors', 'BachelorMasters', 'Masters', 'Doctoral']

const checkProgressGraphs = () => {
levels.forEach(level => cy.get(`[data-cy=Graph-Faculty${level}Progress]`))
const checkProgressBarCharts = () => {
progressLevels.forEach(level => cy.get(`[data-cy=Faculty${level}ProgressBarChart]`))
}

const checkProgressTables = () => {
levels.forEach(level => cy.get(`[data-cy=Table-Faculty${level}Progress]`))
progressLevels.forEach(level => cy.get(`[data-cy=Faculty${level}ProgressTable]`))
}

const checkAverageGraduationTimesGraphs = breakdown => {
const levels = ['bachelor', 'bcMsCombo', 'master', 'doctor']
levels.forEach(level => {
cy.get(`[data-cy=Section-${level}] .graduations-chart-container .faculty-${breakdown ? 'breakdown-' : ''}graph`)
})
}
const graduationTimesLevels = ['bachelor', 'master', 'doctor'] // ? Bachelor + master seems to be missing in test data

const checkProgressStatsFacultyLevelBreakdown = () => {
cy.get('[data-cy=Table-FacultyBachelorsProgress]').within(() => {
cy.contains('2021 - 2022').click()
cy.contains('29.5%').trigger('mouseover', { force: true })
cy.contains('Matemaattis-luonnontieteellinen tiedekunta')
cy.contains('H50 - H50')
cy.contains('0 Credits: 0')
cy.contains('1 ≤ Credits < 45: 13')
cy.contains('45 ≤ Credits < 90: 10')
cy.contains('90 ≤ Credits < 135: 16')
cy.contains('135 ≤ Credits < 180: 3')
cy.contains('180 ≤ Credits: 2')
const checkAverageGraduationTimesBreakdownBarCharts = () => {
graduationTimesLevels.forEach(level => {
cy.get(`[data-cy=${level}BreakdownBarChart]`)
})
}

const checkAverageGraduationTimesFacultyLevelBreakdown = breakdown => {
cy.get('[data-cy=Section-bachelor] .graduations-chart-container').within(() => {
cy.contains('.graduations-message', "Click a bar to view that year's faculty level breakdown")
cy.contains(breakdown ? '51' : '141 graduated').click()
cy.contains('.graduations-message', "Click a bar to view that year's faculty level breakdown").should('not.exist')
cy.contains(`.programmes-${breakdown ? 'breakdown-' : ''}graph`, 'Year 2021 by graduation year')
const checkAverageGraduationTimesMedianBarCharts = () => {
graduationTimesLevels.forEach(level => {
cy.get(`[data-cy=${level}MedianBarChart]`)
})
}

describe('University view', () => {
beforeEach(() => {
cy.init('/university')
cy.contains('University-level view')
cy.contains('University')
cy.contains('Programme MH90_001 (Veterinary medicine bachelor + licentiate) is currently excluded.')
})

describe('Progress stats section', () => {
it('has all the correct progress graphs', () => {
checkProgressGraphs()
describe('Faculty progress tab', () => {
it('contains all the correct progress bar charts', () => {
checkProgressBarCharts()
})

it('has all the correct progress tables', () => {
it('contains all the correct progress tables', () => {
checkProgressTables()
})

it("'Graduated included/excluded' toggle works", () => {
it("'Graduated included / Graduated excluded' toggle works", () => {
cy.get('[data-cy=GraduatedToggle]').click()
checkProgressGraphs()
checkProgressBarCharts()
checkProgressTables()
})

it("'All studyrights/Special studyrights excluded' toggle works", () => {
cy.get('[data-cy=StudentToggle]').click()
checkProgressGraphs()
it("'All study rights / Special study rights excluded' toggle works", () => {
cy.get('[data-cy=StudyRightToggle]').click()
checkProgressBarCharts()
checkProgressTables()
})

it('Years in the tables can be clicked to show faculty level breakdown', () => {
// Filtering out special study rights to make the data match with the Evaluation overview page
cy.get('[data-cy=StudentToggle]').click()
checkProgressStatsFacultyLevelBreakdown()
})
})

describe('Average graduation times section', () => {
it('graphs exist', () => {
checkAverageGraduationTimesGraphs(true)
})

it('Faculty level breakdown can be seen by clicking a bar in the breakdown graph', () => {
checkAverageGraduationTimesFacultyLevelBreakdown(true)
})

it("'Breakdown/Median times' toggle works", () => {
cy.get('[data-cy=GraduationTimeToggle]').click()
checkAverageGraduationTimesGraphs(false)
it('years in the tables can be clicked to show faculty level breakdown', () => {
cy.get('[data-cy=StudyRightToggle]').click()
cy.get('[data-cy=FacultyBachelorsProgressTableShowButton3]').click()
cy.contains('29.5%').trigger('mouseover', { force: true })
cy.contains('Matemaattis-luonnontieteellinen tiedekunta')
cy.contains('H50')
cy.contains('0 Credits: 0')
cy.contains('1 ≤ Credits < 45: 13')
cy.contains('45 ≤ Credits < 90: 10')
cy.contains('90 ≤ Credits < 135: 16')
cy.contains('135 ≤ Credits < 180: 3')
cy.contains('180 ≤ Credits: 2')
})

it('Faculty level breakdown can be seen by clicking a bar in the median times graph', () => {
cy.get('[data-cy=GraduationTimeToggle]').click()
checkAverageGraduationTimesFacultyLevelBreakdown(false)
it('info boxes contain correct information', () => {
cy.get('[data-cy=FacultyProgressInfoBoxButton]').click()
cy.get('[data-cy=FacultyProgressInfoBoxContent]').contains('Kuvaa tiedekuntaan kuuluvien')
cy.get('[data-cy=FacultyBachelorMastersProgressInfoBoxButton]').click()
cy.get('[data-cy=FacultyBachelorMastersProgressInfoBoxContent]').contains('The starting year is the')
})
})
})

// It's better to have these tests defined here than in the 'Evaluation overview' tests as they use the same data as the 'University view' tests
describe("'Evaluation overview' university page", () => {
beforeEach(() => {
cy.init('/evaluationoverview/university')
cy.contains('University-level view')
})

it('page opens', () => {
cy.contains("This view is a combined version of Oodikone's Faculty Evaluation Overview")
})

it('has links to faculty evaluation overview pages', () => {
cy.get('.facultyLinkBox span').should('have.length', 12)
cy.contains('.facultyLinkBox span a', 'H50 Matemaattis-luonnontieteellinen tiedekunta').click()
cy.url().should('include', '/evaluationoverview/faculty/H50')
})

describe('Progress stats section', () => {
it('has all the correct progress graphs', () => {
checkProgressGraphs()
})

it('has all the correct progress tables', () => {
checkProgressTables()
})

it("'Graduated included/excluded' toggle works", () => {
cy.get('[data-cy=GraduatedToggle]').click()
checkProgressGraphs()
checkProgressTables()
describe('Faculty graduations tab', () => {
beforeEach(() => {
cy.get('[data-cy=FacultyGraduationsTab]').click()
})

it("'All studyrights/Special studyrights excluded' toggle doesn't exist", () => {
cy.get('.toggle-container [data-cy=StudentToggle]').should('not.exist')
})

it('Years in the tables can be clicked to show faculty level breakdown', () => {
checkProgressStatsFacultyLevelBreakdown()
})
})

describe('Average graduation times section', () => {
it('graphs exist', () => {
checkAverageGraduationTimesGraphs(true)
})

it('Faculty level breakdown can be seen by clicking a bar in the breakdown graph', () => {
checkAverageGraduationTimesFacultyLevelBreakdown(true)
it('has all the correct median time bar charts', () => {
checkAverageGraduationTimesBreakdownBarCharts()
})

it("'Breakdown/Median times' toggle works", () => {
cy.get('[data-cy=GraduationTimeToggle]').click()
checkAverageGraduationTimesGraphs(false)
checkAverageGraduationTimesMedianBarCharts()
})

it('Faculty level breakdown can be seen by clicking a bar in the median times graph', () => {
cy.get('[data-cy=GraduationTimeToggle]').click()
checkAverageGraduationTimesFacultyLevelBreakdown(false)
it('info boxes contain correct information', () => {
cy.get('[data-cy=AverageGraduationTimesInfoBoxButton]').click()
cy.get('[data-cy=AverageGraduationTimesInfoBoxContent]').contains('Opiskelijoiden keskimääräiset valmistumisajat')
})
})
})
3 changes: 1 addition & 2 deletions services/backend/src/models/user.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { CreationOptional, InferAttributes, InferCreationAttributes } from 'sequelize'
import { AutoIncrement, Column, DataType, Default, Model, PrimaryKey, Table, Unique } from 'sequelize-typescript'

import { Role } from '../shared/types'
import { Language } from '../types'
import { Language, Role } from '../shared/types'

@Table({
underscored: true,
Expand Down
4 changes: 2 additions & 2 deletions services/backend/src/routes/university.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// const router = require('express').Router()
import { Request, Response, Router } from 'express'
import { cloneDeep } from 'lodash'

Expand All @@ -16,6 +15,7 @@ import {
} from '../services/faculty/facultyService'
import { combineFacultyStudentProgress, FacultyProgressData } from '../services/faculty/facultyStudentProgress'
import { getMedian } from '../services/studyProgramme/studyProgrammeHelpers'
import { NameWithCode } from '../shared/types'
import { Graduated } from '../types'
import logger from '../util/logger'

Expand All @@ -24,7 +24,7 @@ const router = Router()
const degreeNames = ['bachelor', 'bachelorMaster', 'master', 'doctor'] as const

const getProgrammeNames = (faculties: Organization[]) => {
return faculties.reduce<Record<string, { code: string; en?: string; fi?: string; sv?: string }>>((obj, faculty) => {
return faculties.reduce<Record<string, NameWithCode>>((obj, faculty) => {
const { name, code } = faculty.dataValues
obj[faculty.code] = { code, ...name }
return obj
Expand Down
2 changes: 1 addition & 1 deletion services/backend/src/routes/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as auth from '../middleware/auth'
import { sendNotificationAboutAccessToUser, previewNotificationAboutAccessToUser } from '../services/mailService'
import * as userService from '../services/userService'
import { LANGUAGE_CODES } from '../shared/language'
import { Language } from '../types'
import { Language } from '../shared/types'
import logger from '../util/logger'

const router = Router()
Expand Down
1 change: 0 additions & 1 deletion services/backend/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export { ExtentCode } from './extentCode'
export { Graduated, SpecialGroups, StatsType, ProgrammeFilter, YearType } from './faculty'
export { GenderCode } from './genderCode'
export { IamAccess } from './iamAccess'
export { Language } from './language'
export { Phase } from './phase'
export { SemesterEnrollment } from './semesterEnrollment'
export { StudyTrack } from './studyTrack'
Expand Down
3 changes: 1 addition & 2 deletions services/backend/src/types/user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { InferAttributes } from 'sequelize'

import { User } from '../models/user'
import { Role } from '../shared/types'
import { Language, Role } from '../shared/types'
import { DetailedProgrammeRights } from './detailedProgrammeRights'
import { Language } from './language'

export type ExpandedUser = InferAttributes<User> & {
iamGroups: string[]
Expand Down
29 changes: 29 additions & 0 deletions services/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions services/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@types/lodash": "^4.17.13",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/react-highcharts": "^16.0.6",
"@vitejs/plugin-react-swc": "^3.7.1",
"typescript": "^5.6.3",
"vite": "^5.4.11"
Expand Down
5 changes: 5 additions & 0 deletions services/frontend/src/common/InfoToolTips/faculty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export const facultyToolTips: Record<string, string> = {
Mukana ovat oletusarvoisesti myös ohjelmaan siirtyneet.
`,
bachelorMasterProgress: `
The starting year is the study right start in the bachelor programme. The credits are computed by the
start date of the bachelor programme and at the moment, they do not include any transferred credits.
Thus, in these statistics some students have fewer credits than in reality.
`,
}

facultyToolTips.studentsStatsOfTheFaculty = studyProgrammeToolTips.studyTrackOverview.replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const getGradeGraphOptions = (
},
plotOptions: {
column: {
stacking: 'normal',
stacking: 'normal' as const,
borderRadius: 2,
},
series: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const passRateAttemptGraphOptions = (isRelative: boolean, categories: string[],
},
plotOptions: {
column: {
stacking: 'normal',
stacking: 'normal' as const,
borderRadius: 3,
},
series: {
Expand Down Expand Up @@ -76,7 +76,7 @@ const passRateStudentGraphOptions = (isRelative: boolean, categories: string[],
},
plotOptions: {
column: {
stacking: 'normal',
stacking: 'normal' as const,
borderRadius: 1,
},
series: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ type Series = {
name: string
data: number[]
stack: string
type: 'column'
}

export const getDataObject = (name: string, data: number[], stack: string): Series => {
return {
name,
data,
stack,
type: 'column' as const,
}
}

Expand Down
Loading

0 comments on commit 4b37fd4

Please sign in to comment.