diff --git a/i18n/messages.en.js b/i18n/messages.en.js index 79d27e8..005a221 100644 --- a/i18n/messages.en.js +++ b/i18n/messages.en.js @@ -147,6 +147,7 @@ module.exports = { teacherAssistantsTitle: 'Teacher Assistants', examinerTitle: 'Examiner', otherContactsTitle: 'Other Contacts', + infoContactName: 'Course Contact', }, extraInfo: { season: { diff --git a/i18n/messages.se.js b/i18n/messages.se.js index ac5e344..bbb35ad 100644 --- a/i18n/messages.se.js +++ b/i18n/messages.se.js @@ -118,6 +118,7 @@ module.exports = { teacherAssistantsTitle: 'Lärarassistenter', examinerTitle: 'Examinator', otherContactsTitle: 'Övriga kontakter', + infoContactName: 'Kontaktperson', }, extraInfo: { season: { diff --git a/public/js/app/components/AboutCourseContacts.jsx b/public/js/app/components/AboutCourseContacts.jsx index e9b69df..2c8b0ad 100644 --- a/public/js/app/components/AboutCourseContacts.jsx +++ b/public/js/app/components/AboutCourseContacts.jsx @@ -3,6 +3,22 @@ import React from 'react' import { EMPTY } from '../util/constants' import HtmlWrapper from './HtmlWrapper' +// Mandatory information +const InfoContact = ({ languageIndex, infoContactName, labels }) => + infoContactName ? ( + <> +

{labels.infoContactName}

+ + + ) : ( + <> +

{labels.infoContactName}

+

+ {EMPTY[languageIndex]} +

+ + ) + // Mandatory information const ExaminerContacts = ({ languageIndex, examiners, labels }) => examiners ? ( @@ -19,9 +35,10 @@ const ExaminerContacts = ({ languageIndex, examiners, labels }) => ) -const CourseContacts = ({ languageIndex, examiners = '', labels = {} }) => ( +const CourseContacts = ({ languageIndex, infoContactName = '', examiners = '', labels = {} }) => ( <>
+
diff --git a/public/js/app/pages/AboutCourseMemo.jsx b/public/js/app/pages/AboutCourseMemo.jsx index bee72d4..7b76ed3 100644 --- a/public/js/app/pages/AboutCourseMemo.jsx +++ b/public/js/app/pages/AboutCourseMemo.jsx @@ -367,6 +367,7 @@ function AboutCourseMemo({ mockKursPmDataApi = false, mockMixKoppsApi = false })

{courseContactsLabels.courseContactsTitle}

diff --git a/public/js/app/pages/__tests__/AboutCourseMemoEN.test.js b/public/js/app/pages/__tests__/AboutCourseMemoEN.test.js index 760dd11..d42cff3 100644 --- a/public/js/app/pages/__tests__/AboutCourseMemoEN.test.js +++ b/public/js/app/pages/__tests__/AboutCourseMemoEN.test.js @@ -87,7 +87,7 @@ describe('User language: English. Component show all memos: pd const mainContent = screen.getByRole('main') const allH3Headers = within(mainContent).getAllByRole('heading', { level: 3 }) - expect(allH3Headers.length).toBe(4) + expect(allH3Headers.length).toBe(5) const expectedh3ds = [ 'Course offerings starting Autumn 2020', 'Course offerings starting Autumn 2019', @@ -109,7 +109,7 @@ describe('User language: English. Component show all memos: pd test('renders text about empty fields (Course Contact, Examiner) ', () => { const noInfo = getAllByText('No information inserted') - expect(noInfo.length).toBe(1) + expect(noInfo.length).toBe(2) }) test('renders menu link of web-based memo as expected', () => { diff --git a/public/js/app/pages/__tests__/AboutCourseMemoSV.test.js b/public/js/app/pages/__tests__/AboutCourseMemoSV.test.js index b58eeba..4325c43 100644 --- a/public/js/app/pages/__tests__/AboutCourseMemoSV.test.js +++ b/public/js/app/pages/__tests__/AboutCourseMemoSV.test.js @@ -88,7 +88,7 @@ describe('User language: Swedish. Component show all memos: pd test('renders h3 ', () => { const mainContent = screen.getByRole('main') const allH3Headers = within(mainContent).getAllByRole('heading', { level: 3 }) - expect(allH3Headers.length).toBe(4) + expect(allH3Headers.length).toBe(5) const expectedh3ds = [ 'Kursomgångar som startar HT 2020', 'Kursomgångar som startar HT 2019', @@ -108,6 +108,11 @@ describe('User language: Swedish. Component show all memos: pd expectedh4ds.map((h4, index) => expect(allH4Headers[index]).toHaveTextContent(h4)) }) + test('renders text about empty fields (Kontaktperson) ', () => { + const noInfo = getAllByText('Ingen information tillagd') + expect(noInfo.length).toBe(1) + }) + test('renders menu link of web-based memo as expected', done => { const menuItems = getAllByText('Course memo Autumn 2019-1') expect(menuItems.length).toBe(2) diff --git a/server/controllers/memoCtrl.js b/server/controllers/memoCtrl.js index 934b2cc..49c2072 100644 --- a/server/controllers/memoCtrl.js +++ b/server/controllers/memoCtrl.js @@ -200,17 +200,23 @@ async function getContent(req, res, next) { let fromTerm = semester ?? extractTerm(courseCode, finalMemoEndPoint) - const { courseMainSubjects, title, credits, creditUnitAbbr, examiners, roundInfos } = await getDetailedInformation( - courseCode, - languagesContext.memoLanguage, - fromTerm - ) + const { + courseMainSubjects, + recruitmentText, + title, + credits, + creditUnitAbbr, + infoContactName, + examiners, + roundInfos, + } = await getDetailedInformation(courseCode, languagesContext.memoLanguage, fromTerm) const courseContext = { courseMainSubjects, title, credits, creditUnitAbbr, + infoContactName, examiners, } @@ -324,16 +330,15 @@ async function getOldContent(req, res, next) { memoDatas: [], } - const { courseMainSubjects, title, credits, creditUnitAbbr, examiners } = await getDetailedInformation( - courseCode, - languagesContext.memoLanguage - ) + const { courseMainSubjects, recruitmentText, title, credits, creditUnitAbbr, infoContactName, examiners } = + await getDetailedInformation(courseCode, languagesContext.memoLanguage) const courseContext = { courseMainSubjects, title, credits, creditUnitAbbr, + infoContactName, examiners, } @@ -411,7 +416,7 @@ async function getAboutContent(req, res, next) { const fromTerm = getLastYearsTerm() - const { title, credits, creditUnitAbbr, examiners, roundInfos } = await getDetailedInformation( + const { title, credits, creditUnitAbbr, infoContactName, examiners, roundInfos } = await getDetailedInformation( courseCode, responseLanguage, fromTerm @@ -419,6 +424,7 @@ async function getAboutContent(req, res, next) { webContext.title = title webContext.credits = credits webContext.creditUnitAbbr = creditUnitAbbr + webContext.infoContactName = infoContactName webContext.examiners = examiners webContext.memoDatas = enrichMemoDatasWithOutdatedFlag(rawMemos, roundInfos) diff --git a/server/koppsApi.js b/server/koppsApi.js index b502fd4..c84d999 100644 --- a/server/koppsApi.js +++ b/server/koppsApi.js @@ -67,6 +67,7 @@ async function getDetailedInformation(courseCode, language, fromTerm) { title: course && course.title ? course.title : '', credits: isCreditNotStandard ? course.credits + '.0' : course.credits || '', creditUnitAbbr: course && course.creditUnitAbbr ? course.creditUnitAbbr : '', + infoContactName: course && course.infoContactName ? course.infoContactName : '', examiners: createPersonHtml(examiners), roundInfos: roundInfos || [], } diff --git a/server/ssr-context/createServerSideContext.js b/server/ssr-context/createServerSideContext.js index a286286..cf95bea 100644 --- a/server/ssr-context/createServerSideContext.js +++ b/server/ssr-context/createServerSideContext.js @@ -24,6 +24,7 @@ function createServerSideContext() { title: '', credits: '', creditUnitAbbr: '', + infoContactName: '', semester: '', examiners: '', userLanguageIndex: 1, diff --git a/test/mock-api/responses.js b/test/mock-api/responses.js index d331ad3..faae36f 100644 --- a/test/mock-api/responses.js +++ b/test/mock-api/responses.js @@ -41,6 +41,7 @@ module.exports = { extraHeaders4: '', extraHeaders5: '', equipment: '', + infoContactName: '', literature: '', possibilityToCompletion: '', possibilityToAddition: '',