edulution-io / edulution-ui

https://edulution.io/
2 stars 0 forks source link

NIEDUUI-248: Add backend tests for the survey functions #105

Closed maierdominik closed 3 months ago

maierdominik commented 3 months ago

JIRA: https://schulz-informatik.atlassian.net/browse/NIEDUUI-248

BELOW IS A COMPLETE LIST OF THE TESTS TO CHECK FOR COMPLETENESS

NIEDUUI-248:

    * SurveyController
        * should be defined
        * findSurveys
            * should return a survey given the id
            * should return multiple surveys given the ids
        * getSurveyResult
            * should return the public answers of a survey given the Id
        * getOpenSurveys
            * should return the list of open (not jet participated) surveys 
        * getCreatedSurveys
            * should return the list of surveys that the user created
        * getAnsweredSurveys
            * should return the list of surveys the user has participated (answered) already
        * getAllSurveys
            * should return the full list of surveys
        * getCommittedSurveyAnswers
            * should return the commited answer for a survey from user document
        * updateOrCreateSurvey
            * should update a survey if it exists already
            * should create a survey if it does not exists already
            * should throw an error if the survey update fails
        * deleteSurvey
            * should remove a survey
            * should remove multiple surveys
            * should throw an error if the survey was not found
            * should throw an error if the survey removal fails
        * answerSurvey
            * should add an answer to a survey
            * should throw an error if adding an answer fails
            * in order to add an public answer it has to update the survey (first)
            * in order to add an public answer it has to update the survey (second)
        * addPublicAnswer
            * throw an error if the survey with the surveyId was not found
            * throw an error if a user adds an answer that is not marked as participating user
            * throw an error if a user adds an answer that already has participated and the survey does not accept multiple answers
            * should throw an error if the survey update fails

    * SurveyService
        * should be defined
        * findAllSurveys
            * should return all surveys
        * findSurvey
            * should return a single survey by ID
        * findSurveys
            * should return multiple surveys by ID
        * updateSurvey
            * should update a survey
            * should throw an error if the survey update fails
        * createSurvey
            * should create a survey
            * should throw an error if the survey creation fails
        * addPublicAnswer
            * throw an error if the survey with the surveyId was not found
            * throw an error if a user adds an answer that is not marked as participating user
            * throw an error if a user adds an answer that already has participated and the survey does not accept multiple answers
            * in order to add an public answer it has to update the survey

    * UsersSurveysService
        * should be defined
        * getExistingUser
            * should return a user
            * should throw an error if the user is not found
        * updateUser
            * should update a user 
        * getOpenSurveyIds
            * should return open survey ids
        * getCreatedSurveyIds
            * should return created survey ids
        * getAnsweredSurveyIds
            * should return answered survey ids
        * onRemoveSurvey
            * should remove survey from list of openSurveys if survey gets deleted and is open
            * should remove survey from list of createdSurveys if survey gets deleted and is in the created list
            * should remove survey from list of answeredSurveys if survey gets deleted was already answered
            * should remove survey from list of open-, created-, and answeredSurveys list if survey gets deleted and is included in all 3 (somehow)
            * should not remove any surveyId if the deleted id is not included in any of the lists
            * should throw an error if the user is not found
        * addToCreatedSurveys
            * should add a survey to the list of created surveys
            * should throw an error if the user is not found
        * addAnswer
            * should remove the survey from open surveys and move it to answered together with the answer
        * addToOpenSurveys
            * should add a survey to open surveys
            * should throw an error if the user is not found
        * populateSurvey
            * should populate survey to first participant
            * should populate survey to second participant
        * getCommitedAnswer
            * should return the previously commited answer for the survey with props.surveyId from user with props.username