diff --git a/backend/api/Authorization/AuthService.cs b/backend/api/Authorization/AuthService.cs index 4a05ee1f..a914b42a 100644 --- a/backend/api/Authorization/AuthService.cs +++ b/backend/api/Authorization/AuthService.cs @@ -9,7 +9,6 @@ namespace api.Authorization public interface IAuthService { public string GetOID(); - public void AssertIsFacilitator(string evaluationId); } public class AuthService : IAuthService @@ -33,17 +32,5 @@ public string GetOID() string oid = httpContext.User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; return oid; } - - public void AssertIsFacilitator(string evaluationId) - { - string oid = GetOID(); - Evaluation evaluation = _evaluationService.GetEvaluation(evaluationId); - Participant participant = _participantService.GetParticipant(oid, evaluation); - if (participant.Role != Role.Facilitator) - { - throw new UnauthorizedAccessException($"Current user is not Facilitator"); - - } - } } } diff --git a/backend/api/GQL/Mutation.cs b/backend/api/GQL/Mutation.cs index c34d5c8f..212e53a0 100644 --- a/backend/api/GQL/Mutation.cs +++ b/backend/api/GQL/Mutation.cs @@ -69,9 +69,11 @@ public Evaluation CreateEvaluation(string name, public Evaluation ProgressEvaluation(string evaluationId, Progression newProgression) { - _authService.AssertIsFacilitator(evaluationId); Evaluation evaluation = _evaluationService.GetEvaluation(evaluationId); + Role[] canBePerformedBy = { Role.Facilitator }; + AssertCanPerformMutation(evaluation, canBePerformedBy); + _evaluationService.ProgressEvaluation(evaluation, newProgression); _participantService.ProgressAllParticipants(evaluation, newProgression); @@ -87,9 +89,11 @@ public Evaluation ProgressEvaluation(string evaluationId, Progression newProgres public Evaluation SetSummary(string evaluationId, string summary) { - _authService.AssertIsFacilitator(evaluationId); Evaluation evaluation = _evaluationService.GetEvaluation(evaluationId); + Role[] canBePerformedBy = { Role.Facilitator }; + AssertCanPerformMutation(evaluation, canBePerformedBy); + _evaluationService.SetSummary(evaluation, summary); return evaluation; } @@ -100,6 +104,9 @@ public Participant ProgressParticipant(string evaluationId, Progression newProgr Evaluation evaluation = _evaluationService.GetEvaluation(evaluationId); Participant participant = _participantService.GetParticipant(azureUniqueId, evaluation); + Role[] canBePerformedBy = { Role.Facilitator, Role.OrganizationLead, Role.Participant }; + AssertCanPerformMutation(evaluation, canBePerformedBy); + Participant progressedParticipant = _participantService.ProgressParticipant(participant, newProgression); return progressedParticipant; @@ -108,11 +115,42 @@ public Participant ProgressParticipant(string evaluationId, Progression newProgr public Participant CreateParticipant(string azureUniqueId, string evaluationId, Organization organization, Role role) { Evaluation evaluation = _evaluationService.GetEvaluation(evaluationId); + + Role[] canBePerformedBy = { Role.Facilitator, Role.OrganizationLead }; + AssertCanPerformMutation(evaluation, canBePerformedBy); + return _participantService.Create(azureUniqueId, evaluation, organization, role); } public Participant DeleteParticipant(string participantId) { + Evaluation evaluation = _participantService.GetAll() + .Where(p => p.Id.Equals(participantId)) + .Select(p => p.Evaluation) + .First() + ; + + Role[] canBePerformedBy = { Role.Facilitator, Role.OrganizationLead }; + AssertCanPerformMutation(evaluation, canBePerformedBy); + + Participant subject = _participantService.GetParticipant(participantId); + + /* Safeguard against deleting the last Facilitator */ + if (subject.Role.Equals(Role.Facilitator)) + { + int facilitators = evaluation.Participants + .Where(p => p.Role.Equals(Role.Facilitator)) + .Count() + ; + + if (facilitators < 2) + { + string msg = "Cannot delete last Facilitator in Evaluation"; + throw new InvalidOperationException(msg); + + } + } + return _participantService.Remove(participantId); } @@ -157,6 +195,10 @@ public Answer SetAnswer(string questionId, Severity severity, string text, Progr IQueryable queryableQuestion = _questionService.GetQuestion(questionId); Question question = queryableQuestion.First(); Evaluation evaluation = queryableQuestion.Select(q => q.Evaluation).First(); + + Role[] canBePerformedBy = { Role.Facilitator, Role.Participant, Role.OrganizationLead }; + AssertCanPerformMutation(evaluation, canBePerformedBy); + Participant currentUser = CurrentUser(evaluation); Answer answer; try @@ -178,6 +220,9 @@ public Action CreateAction(string questionId, string assignedToId, string descri Question question = queryableQuestion.First(); Evaluation evaluation = queryableQuestion.Select(q => q.Evaluation).First(); + Role[] canBePerformedBy = { Role.Facilitator, Role.Participant, Role.OrganizationLead }; + AssertCanPerformMutation(evaluation, canBePerformedBy); + Participant assignedTo = _participantService.GetParticipant(assignedToId); return _actionService.Create(CurrentUser(evaluation), assignedTo, description, dueDate, title, priority, question); @@ -187,6 +232,10 @@ public Action EditAction(string actionId, string assignedToId, string descriptio { IQueryable queryableAction = _actionService.GetAction(actionId); Action action = queryableAction.First(); + Evaluation evaluation = queryableAction.Select(q => q.Question.Evaluation).First(); + + Role[] canBePerformedBy = { Role.Facilitator, Role.Participant, Role.OrganizationLead }; + AssertCanPerformMutation(evaluation, canBePerformedBy); Participant assignedTo = _participantService.GetParticipant(assignedToId); @@ -198,6 +247,10 @@ public Action DeleteAction(string actionId) /* Note that no related fields are loaded */ IQueryable queryableAction = _actionService.GetAction(actionId); Action action = queryableAction.First(); + Evaluation evaluation = queryableAction.Select(q => q.Question.Evaluation).First(); + + Role[] canBePerformedBy = { Role.Facilitator }; + AssertCanPerformMutation(evaluation, canBePerformedBy); _actionService.Remove(action); return action; @@ -209,13 +262,10 @@ public Note CreateNote(string actionId, string text) Action action = queryableAction.First(); Evaluation evaluation = queryableAction.Select(a => a.Question.Evaluation).First(); - return _noteService.Create(CurrentUser(evaluation), text, action); - } + Role[] canBePerformedBy = { Role.Facilitator, Role.Participant, Role.OrganizationLead }; + AssertCanPerformMutation(evaluation, canBePerformedBy); - public Note EditNote(string noteId, string text) - { - Note note = _noteService.GetNote(noteId); - return _noteService.EditNote(note, text); + return _noteService.Create(CurrentUser(evaluation), text, action); } public ClosingRemark CreateClosingRemark(string actionId, string text) @@ -224,6 +274,9 @@ public ClosingRemark CreateClosingRemark(string actionId, string text) Action action = queryableAction.First(); Evaluation evaluation = queryableAction.Select(a => a.Question.Evaluation).First(); + Role[] canBePerformedBy = { Role.Facilitator, Role.Participant, Role.OrganizationLead }; + AssertCanPerformMutation(evaluation, canBePerformedBy); + return _closingRemarkService.Create(CurrentUser(evaluation), text, action); } @@ -232,5 +285,25 @@ private Participant CurrentUser(Evaluation evaluation) string azureUniqueId = _authService.GetOID(); return _participantService.GetParticipant(azureUniqueId, evaluation); } + + private void AssertCanPerformMutation(Evaluation evaluation, Role[] validRoles) { + string oid = _authService.GetOID(); + Role userRoleInEvaluation; + + try + { + userRoleInEvaluation = _participantService.GetParticipant(oid, evaluation).Role; + } + catch(NotFoundInDBException) { + string msg = "Non-participants cannot perform mutations on Evaluation"; + throw new UnauthorizedAccessException(msg); + } + + if (!validRoles.Contains(userRoleInEvaluation)) + { + string msg = "{0} are not allowed to perform this operation"; + throw new UnauthorizedAccessException(String.Format(msg, userRoleInEvaluation)); + }; + } } } diff --git a/backend/tests/DbContextTestSetup.cs b/backend/tests/DbContextTestSetup.cs index ca4968be..f305b758 100644 --- a/backend/tests/DbContextTestSetup.cs +++ b/backend/tests/DbContextTestSetup.cs @@ -5,6 +5,7 @@ using api.Authorization; using api.Context; +using api.Models; namespace tests { @@ -33,15 +34,23 @@ public void Dispose() } } - class MockAuthService : IAuthService + public class MockAuthService : IAuthService { - public string GetOID() + private string _loggedInUser = "1"; + + public void LoginUser(string azureUniqueId) { - return "1"; + _loggedInUser = azureUniqueId; } - public void AssertIsFacilitator(string evaluationId) + + public void LoginUser(Participant participant) + { + _loggedInUser = participant.AzureUniqueId; + } + + public string GetOID() { - // Do nothing + return _loggedInUser; } } } diff --git a/backend/tests/GQL/Mutation.cs b/backend/tests/GQL/Mutation.cs index 60f5ce60..99eef449 100644 --- a/backend/tests/GQL/Mutation.cs +++ b/backend/tests/GQL/Mutation.cs @@ -4,7 +4,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using System; using System.Linq; using System.Collections.Generic; using Xunit; @@ -14,16 +13,22 @@ namespace tests [Collection("UsesDbContext")] public class MutationTest : DbContextTestSetup { - private readonly Mutation _mutation; - private readonly ProjectService _projectService; - private readonly EvaluationService _evaluationService; - private readonly ParticipantService _participantService; - private readonly QuestionService _questionService; - private readonly AnswerService _answerService; - private readonly QuestionTemplateService _questionTemplateService; - private readonly ActionService _actionService; - private readonly NoteService _noteService; - private readonly ClosingRemarkService _closingRemarkService; + /* Services */ + protected readonly Mutation _mutation; + protected readonly ProjectService _projectService; + protected readonly EvaluationService _evaluationService; + protected readonly ParticipantService _participantService; + protected readonly QuestionService _questionService; + protected readonly AnswerService _answerService; + protected readonly QuestionTemplateService _questionTemplateService; + protected readonly ActionService _actionService; + protected readonly NoteService _noteService; + protected readonly ClosingRemarkService _closingRemarkService; + protected readonly MockAuthService _authService; + + /* Helpers */ + private readonly Project _project; + public MutationTest() { ILoggerFactory factory = new NullLoggerFactory(); @@ -36,6 +41,7 @@ public MutationTest() _actionService = new ActionService(_context); _noteService = new NoteService(_context); _closingRemarkService = new ClosingRemarkService(_context); + _authService = new MockAuthService(); _mutation = new Mutation( _projectService, _evaluationService, @@ -46,49 +52,258 @@ public MutationTest() _actionService, _noteService, _closingRemarkService, - new MockAuthService(), + _authService, new Logger(factory) ); + + _project = _projectService.Create("Project"); + } + + /* Mutation wrappers with default values */ + + protected Evaluation CreateEvaluation( + string name = null, + string projectId = null, + string previousEvaluationId = null) + { + if (name == null) + { + name = Randomize.String(); + } + + if (projectId == null) + { + projectId = _project.Id; + } + + if (previousEvaluationId == null) + { + previousEvaluationId = ""; + } + + Evaluation evaluation = _mutation.CreateEvaluation( + name: name, + projectId: projectId, + previousEvaluationId: previousEvaluationId + ); + + return evaluation; } - [Fact] - public void CreateEvaluation() + protected Participant CreateParticipant( + Evaluation evaluation, + string azureUniqueId = null, + Organization? organization = null, + Role? role = null) { - string projectId = _context.Projects.First().Id; - int evaluationsBefore = _context.Evaluations.Count(); - _mutation.CreateEvaluation("CreateEvaluation", projectId, ""); - int evaluationsAfter = _context.Evaluations.Count(); + if (azureUniqueId == null) + { + azureUniqueId = Randomize.Integer().ToString(); + } + + Participant participant = _mutation.CreateParticipant( + azureUniqueId: azureUniqueId, + evaluationId: evaluation.Id, + organization: organization.GetValueOrDefault(Randomize.Organization()), + role: role.GetValueOrDefault(Randomize.Role()) + ); - Assert.Equal(evaluationsBefore + 1, evaluationsAfter); + return participant; } - [Fact] - public void ProgressEvaluationToFollowup() + protected Answer SetAnswer( + string questionId, + Severity? severity = null, + string text = null, + Progression? progression = null) { - Project project = _projectService.Create("ProgressEvaluationToFollowup"); - Evaluation evaluation = _evaluationService.Create("ProgressEvaluationToFollowup", project, ""); - Participant participant = _participantService.Create("ProgressEvaluationToFollowup", evaluation, Organization.All, Role.Facilitator); - List questions = _questionService.CreateBulk(_questionTemplateService.GetAll().ToList(), evaluation); - _answerService.Create(participant, questions[0], Severity.High, "test_answer_0", Progression.Workshop); - _answerService.Create(participant, questions[1], Severity.High, "test_answer_1", Progression.Workshop); - _answerService.Create(participant, questions[2], Severity.High, "test_answer_2", Progression.Workshop); + if (text == null) + { + text = Randomize.String(); + } - int nAnswersWorkshop = _context.Answers.Where( - a => (a.Progression.Equals(Progression.Workshop) && a.Question.Evaluation.Equals(evaluation)) - ).Count(); + Answer answer= _mutation.SetAnswer( + questionId: questionId, + severity: severity.GetValueOrDefault(Randomize.Severity()), + text: text, + progression: progression.GetValueOrDefault(Randomize.Progression()) + ); + + return answer; + } - // Forces null on db relations - // To simulate behavior of normal API call - _context.ChangeTracker.Clear(); + protected Action CreateAction( + string questionId, + string assignedToId, + string description = null, + System.DateTimeOffset? dueDate = null, + Priority? priority = null, + string title = null) + { - _mutation.ProgressEvaluation(evaluation.Id, Progression.FollowUp); + if (title == null) + { + title = Randomize.String(); + } - int nAnswersFollowup = _context.Answers.Where( - a => (a.Progression.Equals(Progression.FollowUp) && a.Question.Evaluation.Equals(evaluation)) - ).Count(); + if (description == null) + { + description = Randomize.String(); + } + + Action action = _mutation.CreateAction( + questionId: questionId, + assignedToId: assignedToId, + description: description, + dueDate: dueDate.GetValueOrDefault(System.DateTimeOffset.Now), + priority: priority.GetValueOrDefault(Randomize.Priority()), + title: title + ); + + return action; + } + + protected Action EditAction( + string actionId, + string assignedToId, + string description = null, + System.DateTimeOffset? dueDate = null, + Priority? priority = null, + string title = null, + bool onHold = false, + bool completed = false) + { + + if (title == null) + { + title = Randomize.String(); + } + + if (description == null) + { + description = Randomize.String(); + } + + Action action = _mutation.EditAction( + actionId: actionId, + assignedToId: assignedToId, + description: description, + dueDate: dueDate.GetValueOrDefault(System.DateTimeOffset.Now), + priority: priority.GetValueOrDefault(Randomize.Priority()), + title: title, + onHold: onHold, + completed: completed + ); + + return action; + } + + protected void DeleteAction(string actionId) + { + _mutation.DeleteAction(actionId); + } + + protected Note CreateNote( + string actionId, + string text = null) + { - Assert.Equal(nAnswersWorkshop, nAnswersFollowup); + if (text == null) + { + text = Randomize.String(); + } + + Note note = _mutation.CreateNote( + actionId: actionId, + text: text + ); + + return note; + } + + protected ClosingRemark CreateClosingRemark( + string actionId, + string text = null) + { + + if (text == null) + { + text = Randomize.String(); + } + + ClosingRemark remark = _mutation.CreateClosingRemark( + actionId: actionId, + text: text + ); + + return remark; + } + + /* Helper methods */ + + protected int NumberOfParticipants(Evaluation evaluation) + { + int participants = _participantService + .GetAll() + .Where(p => p.Evaluation == evaluation) + .Count() + ; + + return participants; + } + + protected int NumberOfAnswers(Question question) + { + int answers = _answerService + .GetAll() + .Where(a => a.Question == question) + .Count() + ; + + return answers; + } + + protected int NumberOfActions(Question question) + { + int actions = _actionService + .GetAll() + .Where(a => a.Question == question) + .Count() + ; + + return actions; + } + + protected int NumberOfNotes(Action action) + { + int notes = _noteService + .GetAll() + .Where(a => a.Action == action) + .Count() + ; + + return notes; + } + + protected int NumberOfClosingRemarks(Action action) + { + int remarks = _closingRemarkService + .GetAll() + .Where(a => a.Action == action) + .Count() + ; + + return remarks; + } + + protected Question GetFirstQuestion(Evaluation evaluation) + { + return _questionService + .GetAll() + .Where(q => q.Evaluation.Id == evaluation.Id) + .First() + ; } } } diff --git a/backend/tests/GQL/Mutations/CreateAction.cs b/backend/tests/GQL/Mutations/CreateAction.cs new file mode 100644 index 00000000..c13f92ac --- /dev/null +++ b/backend/tests/GQL/Mutations/CreateAction.cs @@ -0,0 +1,89 @@ +using Xunit; +using System; +using System.Linq; + +using api.Models; +using api.Services; +using api.GQL; + + +namespace tests +{ + public class CreateActionMutation : MutationTest + { + private readonly Evaluation _evaluation; + private readonly Participant _facilitator; + private readonly Participant _organizationLead; + private readonly Participant _participant; + private readonly Participant _readonly; + private readonly Question _question; + + public CreateActionMutation() { + _evaluation = CreateEvaluation(); + _facilitator = _evaluation.Participants.First(); + _authService.LoginUser(_facilitator); + + _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead); + _participant = CreateParticipant(_evaluation, role: Role.Participant); + _readonly = CreateParticipant(_evaluation, role: Role.ReadOnly); + _question = GetFirstQuestion(_evaluation); + } + + /* Tests */ + + [Fact] + public void FacilitatorCanUseMutation() + { + AssertCanCreate(_facilitator); + } + + [Fact] + public void OrganizationLeadCanUseMutation() + { + AssertCanCreate(_organizationLead); + } + + [Fact] + public void ParticipantIsCanUseMutation() + { + AssertCanCreate(_participant); + } + + [Fact] + public void ReadOnlyIsUnauthorized() + { + AssertIsNotAuthorized(_readonly.AzureUniqueId); + } + + [Fact] + public void NonParcipantIsUnauthorized() + { + string AzureUniqueId = Randomize.Integer().ToString(); + AssertIsNotAuthorized(AzureUniqueId); + } + + /* Helper methods */ + + private void AssertCanCreate(Participant user) + { + _authService.LoginUser(user); + int answers = NumberOfActions(_question); + CreateAction( + questionId: _question.Id, + assignedToId: Randomize.Value(_evaluation.Participants).Id + ); + Assert.True(NumberOfActions(_question) == answers + 1); + } + + private void AssertIsNotAuthorized(string azureUniqueId) + { + _authService.LoginUser(azureUniqueId); + Assert.Throws(() => + CreateAction( + questionId: _question.Id, + assignedToId: Randomize.Value(_evaluation.Participants).Id + ) + ); + } + } +} diff --git a/backend/tests/GQL/Mutations/CreateClosingRemark.cs b/backend/tests/GQL/Mutations/CreateClosingRemark.cs new file mode 100644 index 00000000..dd717062 --- /dev/null +++ b/backend/tests/GQL/Mutations/CreateClosingRemark.cs @@ -0,0 +1,94 @@ +using Xunit; +using System; +using System.Linq; + +using api.Models; +using api.Services; +using api.GQL; + + +namespace tests +{ + public class CreateClosingRemarkMutation : MutationTest + { + private readonly Evaluation _evaluation; + private readonly Participant _facilitator; + private readonly Participant _organizationLead; + private readonly Participant _participant; + private readonly Participant _readonly; + private readonly Question _question; + private readonly api.Models.Action _action; + + public CreateClosingRemarkMutation() { + _evaluation = CreateEvaluation(); + _facilitator = _evaluation.Participants.First(); + _authService.LoginUser(_facilitator); + + _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead); + _participant = CreateParticipant(_evaluation, role: Role.Participant); + _readonly = CreateParticipant(_evaluation, role: Role.ReadOnly); + _question = GetFirstQuestion(_evaluation); + _action = CreateAction( + questionId: _question.Id, + assignedToId: Randomize.Value(_evaluation.Participants).Id + ); + } + + /* Tests */ + + [Fact] + public void FacilitatorCanUseMutation() + { + AssertCanCreate(_facilitator); + } + + [Fact] + public void OrganizationLeadCanUseMutation() + { + AssertCanCreate(_organizationLead); + } + + [Fact] + public void ParticipantCanUseMutation() + { + AssertCanCreate(_participant); + } + + [Fact] + public void ReadOnlyIsUnauthorized() + { + AssertIsNotAuthorized(_readonly.AzureUniqueId); + } + + [Fact] + public void NonParcipantIsUnauthorized() + { + string AzureUniqueId = Randomize.Integer().ToString(); + AssertIsNotAuthorized(AzureUniqueId); + } + + /* Helper methods */ + + private void AssertCanCreate(Participant user) + { + _authService.LoginUser(user); + int notes = NumberOfClosingRemarks(_action); + CreateClosingRemark( + actionId: _action.Id, + text: Randomize.String() + ); + Assert.True(NumberOfClosingRemarks(_action) == notes + 1); + } + + private void AssertIsNotAuthorized(string azureUniqueId) + { + _authService.LoginUser(azureUniqueId); + Assert.Throws(() => + CreateClosingRemark( + actionId: _action.Id, + text: Randomize.String() + ) + ); + } + } +} diff --git a/backend/tests/GQL/Mutations/CreateNote.cs b/backend/tests/GQL/Mutations/CreateNote.cs new file mode 100644 index 00000000..37c2bf38 --- /dev/null +++ b/backend/tests/GQL/Mutations/CreateNote.cs @@ -0,0 +1,94 @@ +using Xunit; +using System; +using System.Linq; + +using api.Models; +using api.Services; +using api.GQL; + + +namespace tests +{ + public class CreateNoteMutation : MutationTest + { + private readonly Evaluation _evaluation; + private readonly Participant _facilitator; + private readonly Participant _organizationLead; + private readonly Participant _participant; + private readonly Participant _readonly; + private readonly Question _question; + private readonly api.Models.Action _action; + + public CreateNoteMutation() { + _evaluation = CreateEvaluation(); + _facilitator = _evaluation.Participants.First(); + _authService.LoginUser(_facilitator); + + _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead); + _participant = CreateParticipant(_evaluation, role: Role.Participant); + _readonly = CreateParticipant(_evaluation, role: Role.ReadOnly); + _question = GetFirstQuestion(_evaluation); + _action = CreateAction( + questionId: _question.Id, + assignedToId: Randomize.Value(_evaluation.Participants).Id + ); + } + + /* Tests */ + + [Fact] + public void FacilitatorCanUseMutation() + { + AssertCanCreate(_facilitator); + } + + [Fact] + public void OrganizationLeadCanUseMutation() + { + AssertCanCreate(_organizationLead); + } + + [Fact] + public void ParticipantCanUseMutation() + { + AssertCanCreate(_participant); + } + + [Fact] + public void ReadOnlyIsUnauthorized() + { + AssertIsNotAuthorized(_readonly.AzureUniqueId); + } + + [Fact] + public void NonParcipantIsUnauthorized() + { + string AzureUniqueId = Randomize.Integer().ToString(); + AssertIsNotAuthorized(AzureUniqueId); + } + + /* Helper methods */ + + private void AssertCanCreate(Participant user) + { + _authService.LoginUser(user); + int notes = NumberOfNotes(_action); + CreateNote( + actionId: _action.Id, + text: Randomize.String() + ); + Assert.True(NumberOfNotes(_action) == notes + 1); + } + + private void AssertIsNotAuthorized(string azureUniqueId) + { + _authService.LoginUser(azureUniqueId); + Assert.Throws(() => + CreateNote( + actionId: _action.Id, + text: Randomize.String() + ) + ); + } + } +} diff --git a/backend/tests/GQL/Mutations/CreateParticipant.cs b/backend/tests/GQL/Mutations/CreateParticipant.cs new file mode 100644 index 00000000..ec58f13a --- /dev/null +++ b/backend/tests/GQL/Mutations/CreateParticipant.cs @@ -0,0 +1,86 @@ +using Xunit; +using System; +using System.Linq; + +using api.Models; +using api.Services; +using api.GQL; + + +namespace tests +{ + public class CreateParticipantMutation : MutationTest + { + private readonly Evaluation _evaluation; + private readonly Participant _facilitator; + private readonly Participant _organizationLead; + private readonly Participant _participant; + private readonly Participant _readonly; + + public CreateParticipantMutation() { + _evaluation = CreateEvaluation(); + _facilitator = _evaluation.Participants.First(); + _authService.LoginUser(_facilitator); + + _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead); + _participant = CreateParticipant(_evaluation, role: Role.Participant); + _readonly = CreateParticipant(_evaluation, role: Role.ReadOnly); + } + + /* Tests */ + + [Fact] + public void FacilitatorCanUseMutation() + { + AssertCanCreate(_facilitator); + } + + [Fact] + public void OrganizationLeadCanUseMutation() + { + AssertCanCreate(_organizationLead); + } + + [Fact] + public void ParticipantIsUnauthorized() + { + AssertIsNotAuthorized(_participant); + } + + [Fact] + public void ReadOnlyIsUnauthorized() + { + AssertIsNotAuthorized(_readonly); + } + + [Fact] + public void NonParcipantIsUnauthorized() + { + string AzureUniqueId = Randomize.Integer().ToString(); + AssertIsNotAuthorized(AzureUniqueId); + } + + /* Helper methods */ + + private void AssertCanCreate(Participant user) + { + _authService.LoginUser(user); + int participants = NumberOfParticipants(_evaluation); + CreateParticipant(_evaluation); + Assert.True(NumberOfParticipants(_evaluation) == participants + 1); + } + + private void AssertIsNotAuthorized(string azureUniqueId) + { + _authService.LoginUser(azureUniqueId); + Assert.Throws(() => + CreateParticipant(_evaluation) + ); + } + + private void AssertIsNotAuthorized(Participant user) + { + AssertIsNotAuthorized(user.AzureUniqueId); + } + } +} diff --git a/backend/tests/GQL/Mutations/DeleteAction.cs b/backend/tests/GQL/Mutations/DeleteAction.cs new file mode 100644 index 00000000..350db8f1 --- /dev/null +++ b/backend/tests/GQL/Mutations/DeleteAction.cs @@ -0,0 +1,93 @@ +using Xunit; +using System; +using System.Linq; + +using api.Models; +using api.Services; +using api.GQL; + + +namespace tests +{ + public class DeleteActionMutation : MutationTest + { + private readonly Evaluation _evaluation; + private readonly Participant _facilitator; + private readonly Participant _organizationLead; + private readonly Participant _participant; + private readonly Participant _readonly; + private readonly Question _question; + private readonly api.Models.Action _action; + + public DeleteActionMutation() { + _evaluation = CreateEvaluation(); + _facilitator = _evaluation.Participants.First(); + _authService.LoginUser(_facilitator); + + _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead); + _participant = CreateParticipant(_evaluation, role: Role.Participant); + _readonly = CreateParticipant(_evaluation, role: Role.ReadOnly); + _question = GetFirstQuestion(_evaluation); + _action = CreateAction( + questionId: _question.Id, + assignedToId: Randomize.Value(_evaluation.Participants).Id + ); + } + + /* Tests */ + + [Fact] + public void FacilitatorCanUseMutation() + { + AssertCanDelete(_facilitator); + } + + [Fact] + public void OrganizationLeadIsUnauthorized() + { + AssertIsNotAuthorized(_organizationLead.AzureUniqueId); + } + + [Fact] + public void ParticipantIsUnauthorized() + { + AssertIsNotAuthorized(_participant.AzureUniqueId); + } + + [Fact] + public void ReadOnlyIsUnauthorized() + { + AssertIsNotAuthorized(_readonly.AzureUniqueId); + } + + [Fact] + public void NonParcipantIsUnauthorized() + { + string AzureUniqueId = Randomize.Integer().ToString(); + AssertIsNotAuthorized(AzureUniqueId); + } + + /* Helper methods */ + + private void AssertCanDelete(Participant user) + { + var toDelete = CreateAction( + questionId: _question.Id, + assignedToId: Randomize.Value(_evaluation.Participants).Id + ); + + _authService.LoginUser(user); + int answers = NumberOfActions(_question); + DeleteAction(toDelete.Id); + Assert.True(NumberOfActions(_question) == answers - 1); + } + + private void AssertIsNotAuthorized(string azureUniqueId) + { + _authService.LoginUser(azureUniqueId); + Assert.Throws(() => + DeleteAction(_action.Id) + ); + } + } +} diff --git a/backend/tests/GQL/Mutations/DeleteParticipant.cs b/backend/tests/GQL/Mutations/DeleteParticipant.cs new file mode 100644 index 00000000..d39ed8b3 --- /dev/null +++ b/backend/tests/GQL/Mutations/DeleteParticipant.cs @@ -0,0 +1,121 @@ +using Xunit; +using System; +using System.Linq; + +using api.Models; +using api.Services; +using api.GQL; + + +namespace tests +{ + public class DeleteParticipantMutation : MutationTest + { + private readonly Evaluation _evaluation; + private readonly Participant _facilitator; + private readonly Participant _organizationLead; + private readonly Participant _participant; + private readonly Participant _readonly; + + public DeleteParticipantMutation() { + _evaluation = CreateEvaluation(); + _facilitator = _evaluation.Participants.First(); + _authService.LoginUser(_facilitator); + + _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead); + _participant = CreateParticipant(_evaluation, role: Role.Participant); + _readonly = CreateParticipant(_evaluation, role: Role.ReadOnly); + } + + /* Tests */ + + [Fact] + public void FacilitatorCanUseMutation() + { + AssertCanDelete(_facilitator); + } + + [Fact] + public void OrganizationLeadCanUseMutation() + { + AssertCanDelete(_organizationLead); + } + + [Fact] + public void ParticipantIsUnauthorized() + { + AssertIsNotAuthorized(_participant.AzureUniqueId); + } + + [Fact] + public void ReadOnlyIsUnauthorized() + { + AssertIsNotAuthorized(_readonly.AzureUniqueId); + } + + [Fact] + public void NonParcipantIsUnauthorized() + { + string AzureUniqueId = Randomize.Integer().ToString(); + AssertIsNotAuthorized(AzureUniqueId); + } + + [Fact] + public void CannotPerformOnNonLastFacilitator() + { + Evaluation evaluation = CreateEvaluation(); + Participant first = evaluation.Participants.First(); + _authService.LoginUser(first); + Participant second = CreateParticipant(evaluation, role: Role.Facilitator); + + int participants = evaluation.Participants.Count(); + Assert.Equal(2, participants); + + _authService.LoginUser(second); + _mutation.DeleteParticipant(first.Id); + + participants = evaluation.Participants.Count(); + Assert.Equal(1, participants); + } + + [Fact] + public void CannotPerformOnLastFacilitator() + { + Evaluation evaluation = CreateEvaluation(); + Participant facilitator = evaluation.Participants.First(); + _authService.LoginUser(facilitator); + + Assert.Throws(() => + _mutation.DeleteParticipant(facilitator.Id) + ); + } + + /* Helper methods */ + + private void AssertCanDelete(Participant user) + { + var toDelete = CreateParticipant( + evaluation: _evaluation, + azureUniqueId: Randomize.Integer().ToString() + ); + + _authService.LoginUser(user); + int participants = NumberOfParticipants(_evaluation); + _mutation.DeleteParticipant(toDelete.Id); + Assert.True(NumberOfParticipants(_evaluation) == participants - 1); + } + + private void AssertIsNotAuthorized(string azureUniqueId) + { + var toDelete = CreateParticipant( + evaluation: _evaluation, + azureUniqueId: Randomize.Integer().ToString() + ); + + _authService.LoginUser(azureUniqueId); + Assert.Throws(() => + _mutation.DeleteParticipant(toDelete.Id) + ); + } + } +} diff --git a/backend/tests/GQL/Mutations/EditAction.cs b/backend/tests/GQL/Mutations/EditAction.cs new file mode 100644 index 00000000..d3bf58b8 --- /dev/null +++ b/backend/tests/GQL/Mutations/EditAction.cs @@ -0,0 +1,100 @@ +using Xunit; +using System; +using System.Linq; + +using api.Models; +using api.Services; +using api.GQL; + + +namespace tests +{ + public class EditActionMutation : MutationTest + { + private readonly Evaluation _evaluation; + private readonly Participant _facilitator; + private readonly Participant _organizationLead; + private readonly Participant _participant; + private readonly Participant _readonly; + private readonly Question _question; + private readonly api.Models.Action _action; + + public EditActionMutation() { + _evaluation = CreateEvaluation(); + _facilitator = _evaluation.Participants.First(); + _authService.LoginUser(_facilitator); + + _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead); + _participant = CreateParticipant(_evaluation, role: Role.Participant); + _readonly = CreateParticipant(_evaluation, role: Role.ReadOnly); + _question = GetFirstQuestion(_evaluation); + _action = CreateAction( + questionId: _question.Id, + assignedToId: Randomize.Value(_evaluation.Participants).Id + ); + } + + /* Tests */ + + [Fact] + public void FacilitatorCanUseMutation() + { + AssertCanEdit(_facilitator); + } + + [Fact] + public void OrganizationLeadCanUseMutation() + { + AssertCanEdit(_organizationLead); + } + + [Fact] + public void ParticipantIsCanUseMutation() + { + AssertCanEdit(_participant); + } + + [Fact] + public void ReadOnlyIsUnauthorized() + { + AssertIsNotAuthorized(_readonly.AzureUniqueId); + } + + [Fact] + public void NonParcipantIsUnauthorized() + { + string AzureUniqueId = Randomize.Integer().ToString(); + AssertIsNotAuthorized(AzureUniqueId); + } + + /* Helper methods */ + + private void AssertCanEdit(Participant user) + { + _authService.LoginUser(user); + int answers = NumberOfActions(_question); + string description = _action.Description; + string actionId = _action.Id; + + var action = EditAction( + actionId: actionId, + assignedToId: Randomize.Value(_evaluation.Participants).Id, + description: Randomize.String() + ); + Assert.True(NumberOfActions(_question) == answers); + Assert.True(actionId == action.Id); + Assert.False(description == action.Description); + } + + private void AssertIsNotAuthorized(string azureUniqueId) + { + _authService.LoginUser(azureUniqueId); + Assert.Throws(() => + EditAction( + actionId: _action.Id, + assignedToId: Randomize.Value(_evaluation.Participants).Id + ) + ); + } + } +} diff --git a/backend/tests/GQL/Mutations/ProgressEvaluation.cs b/backend/tests/GQL/Mutations/ProgressEvaluation.cs new file mode 100644 index 00000000..c5bb29f8 --- /dev/null +++ b/backend/tests/GQL/Mutations/ProgressEvaluation.cs @@ -0,0 +1,94 @@ +using Xunit; +using System; +using System.Linq; + +using api.Models; +using api.Services; +using api.GQL; + + +namespace tests +{ + public class ProgressEvaluationMutation : MutationTest + { + private readonly Evaluation _evaluation; + private readonly Participant _facilitator; + private readonly Participant _organizationLead; + private readonly Participant _participant; + private readonly Participant _readonly; + + public ProgressEvaluationMutation() { + _evaluation = CreateEvaluation(); + _facilitator = _evaluation.Participants.First(); + _authService.LoginUser(_facilitator); + + _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead); + _participant = CreateParticipant(_evaluation, role: Role.Participant); + _readonly = CreateParticipant(_evaluation, role: Role.ReadOnly); + } + + /* Tests */ + + [Fact] + public void FacilitatorCanUseMutation() + { + AssertCanProgress(_facilitator); + } + + [Fact] + public void OrganizationLeadIsUnauthorized() + { + AssertIsNotAuthorized(_organizationLead); + } + + [Fact] + public void ParticipantIsUnauthorized() + { + AssertIsNotAuthorized(_participant); + } + + [Fact] + public void ReadOnlyIsUnauthorized() + { + AssertIsNotAuthorized(_readonly); + } + + [Fact] + public void NonParcipantIsUnauthorized() + { + string AzureUniqueId = Randomize.Integer().ToString(); + AssertIsNotAuthorized(AzureUniqueId); + } + + /* Helper methods */ + + private void AssertCanProgress(Participant user) + { + _authService.LoginUser(user); + Progression newProgression = Randomize.Progression(); + + _mutation.ProgressEvaluation( + evaluationId: _evaluation.Id, + newProgression: newProgression + ); + + Assert.True(_evaluation.Progression == newProgression); + } + + private void AssertIsNotAuthorized(string azureUniqueId) + { + _authService.LoginUser(azureUniqueId); + Assert.Throws(() => + _mutation.ProgressEvaluation( + evaluationId: _evaluation.Id, + newProgression: Randomize.Progression() + ) + ); + } + + private void AssertIsNotAuthorized(Participant user) + { + AssertIsNotAuthorized(user.AzureUniqueId); + } + } +} diff --git a/backend/tests/GQL/Mutations/ProgressParticipant.cs b/backend/tests/GQL/Mutations/ProgressParticipant.cs new file mode 100644 index 00000000..0bd3cf02 --- /dev/null +++ b/backend/tests/GQL/Mutations/ProgressParticipant.cs @@ -0,0 +1,82 @@ +using Xunit; +using System; +using System.Linq; + +using api.Models; +using api.Services; +using api.GQL; + + +namespace tests +{ + public class ProgressParticipantMutation : MutationTest + { + private readonly Evaluation _evaluation; + private readonly Participant _facilitator; + private readonly Participant _organizationLead; + private readonly Participant _participant; + private readonly Participant _readonly; + + public ProgressParticipantMutation() { + _evaluation = CreateEvaluation(); + _facilitator = _evaluation.Participants.First(); + _authService.LoginUser(_facilitator); + + _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead); + _participant = CreateParticipant(_evaluation, role: Role.Participant); + _readonly = CreateParticipant(_evaluation, role: Role.ReadOnly); + } + + /* Tests */ + + [Fact] + public void FacilitatorCanUseMutation() + { + AssertCanProgress(_facilitator); + } + + [Fact] + public void OrganizationLeadCanUseMutation() + { + AssertCanProgress(_organizationLead); + } + + [Fact] + public void ParticipantCanUseMutation() + { + AssertCanProgress(_participant); + } + + [Fact] + public void ReadOnlyIsUnauthorized() + { + AssertIsNotAuthorized(_readonly); + } + + /* Helper methods */ + + private void AssertCanProgress(Participant user) + { + _authService.LoginUser(user); + Progression newProgression = Randomize.Progression(); + + _mutation.ProgressParticipant( + evaluationId: _evaluation.Id, + newProgression: newProgression + ); + + Assert.True(user.Progression == newProgression); + } + + private void AssertIsNotAuthorized(Participant user) + { + _authService.LoginUser(user.AzureUniqueId); + Assert.Throws(() => + _mutation.ProgressParticipant( + evaluationId: _evaluation.Id, + newProgression: Randomize.Progression() + ) + ); + } + } +} diff --git a/backend/tests/GQL/Mutations/SetAnswer.cs b/backend/tests/GQL/Mutations/SetAnswer.cs new file mode 100644 index 00000000..e64655d5 --- /dev/null +++ b/backend/tests/GQL/Mutations/SetAnswer.cs @@ -0,0 +1,88 @@ +using Xunit; +using System; +using System.Linq; + +using api.Models; +using api.Services; +using api.GQL; + + +namespace tests +{ + public class SetAnswerMutation : MutationTest + { + private readonly Evaluation _evaluation; + private readonly Participant _facilitator; + private readonly Participant _organizationLead; + private readonly Participant _participant; + private readonly Participant _readonly; + private readonly Question _question; + + public SetAnswerMutation() { + _evaluation = CreateEvaluation(); + _facilitator = _evaluation.Participants.First(); + _authService.LoginUser(_facilitator); + + _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead); + _participant = CreateParticipant(_evaluation, role: Role.Participant); + _readonly = CreateParticipant(_evaluation, role: Role.ReadOnly); + _question = GetFirstQuestion(_evaluation); + } + + /* Tests */ + + [Fact] + public void FacilitatorCanUseMutation() + { + AssertCanSet(_facilitator); + } + + [Fact] + public void OrganizationLeadCanUseMutation() + { + AssertCanSet(_organizationLead); + } + + [Fact] + public void ParticipantCanUseMutation() + { + AssertCanSet(_participant); + } + + [Fact] + public void ReadOnlyIsUnauthorized() + { + AssertIsNotAuthorized(_readonly); + } + + [Fact] + public void NonParcipantIsUnauthorized() + { + string AzureUniqueId = Randomize.Integer().ToString(); + AssertIsNotAuthorized(AzureUniqueId); + } + + /* Helper methods */ + + private void AssertCanSet(Participant user) + { + _authService.LoginUser(user); + int answers = NumberOfAnswers(_question); + SetAnswer(_question.Id); + Assert.True(NumberOfAnswers(_question) == answers + 1); + } + + private void AssertIsNotAuthorized(string azureUniqueId) + { + _authService.LoginUser(azureUniqueId); + Assert.Throws(() => + SetAnswer(_question.Id) + ); + } + + private void AssertIsNotAuthorized(Participant user) + { + AssertIsNotAuthorized(user.AzureUniqueId); + } + } +} diff --git a/backend/tests/GQL/Mutations/SetSummary.cs b/backend/tests/GQL/Mutations/SetSummary.cs new file mode 100644 index 00000000..572472ce --- /dev/null +++ b/backend/tests/GQL/Mutations/SetSummary.cs @@ -0,0 +1,94 @@ +using Xunit; +using System; +using System.Linq; + +using api.Models; +using api.Services; +using api.GQL; + + +namespace tests +{ + public class SetSummaryMutation: MutationTest + { + private readonly Evaluation _evaluation; + private readonly Participant _facilitator; + private readonly Participant _organizationLead; + private readonly Participant _participant; + private readonly Participant _readonly; + + public SetSummaryMutation() { + _evaluation = CreateEvaluation(); + _facilitator = _evaluation.Participants.First(); + _authService.LoginUser(_facilitator); + + _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead); + _participant = CreateParticipant(_evaluation, role: Role.Participant); + _readonly = CreateParticipant(_evaluation, role: Role.ReadOnly); + } + + /* Tests */ + + [Fact] + public void FacilitatorCanUseMutation() + { + AssertCanSet(_facilitator); + } + + [Fact] + public void OrganizationLeadIsUnauthorized() + { + AssertIsNotAuthorized(_organizationLead); + } + + [Fact] + public void ParticipantIsUnauthorized() + { + AssertIsNotAuthorized(_participant); + } + + [Fact] + public void ReadOnlyIsUnauthorized() + { + AssertIsNotAuthorized(_readonly); + } + + [Fact] + public void NonParcipantIsUnauthorized() + { + string AzureUniqueId = Randomize.Integer().ToString(); + AssertIsNotAuthorized(AzureUniqueId); + } + + /* Helper methods */ + + private void AssertCanSet(Participant user) + { + _authService.LoginUser(user); + + string summary = Randomize.String(); + _mutation.SetSummary( + evaluationId: _evaluation.Id, + summary: summary + ); + + Assert.True(_evaluation.Summary == summary); + } + + private void AssertIsNotAuthorized(string azureUniqueId) + { + _authService.LoginUser(azureUniqueId); + Assert.Throws(() => + _mutation.SetSummary( + evaluationId: _evaluation.Id, + summary: Randomize.String() + ) + ); + } + + private void AssertIsNotAuthorized(Participant user) + { + AssertIsNotAuthorized(user.AzureUniqueId); + } + } +} diff --git a/backend/tests/Randomize.cs b/backend/tests/Randomize.cs new file mode 100644 index 00000000..b655cf22 --- /dev/null +++ b/backend/tests/Randomize.cs @@ -0,0 +1,75 @@ +using System; +using System.Linq; +using System.Collections; +using System.Collections.Generic; + + +using api.Models; + + +namespace tests +{ + public static class Randomize + { + private static Random random = new Random(); + private static string alphanumeric = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + + "abcdefghijklmnopqrstuvwxyz" + + "0123456789"; + + public static string Integer() + { + return random.Next(Int32.MinValue, Int32.MaxValue).ToString(); + } + + /* Random alphanumeric string of 8-32 characters */ + public static string String() + { + char[] chars = new char[random.Next(8, 32)]; + + for (int i = 0; i < chars.Length; i++) + { + chars[i] = alphanumeric[random.Next(alphanumeric.Length)]; + } + + return new String(chars); + } + + public static Role Role() + { + return RandomEnumValue(); + } + + public static Organization Organization() + { + return RandomEnumValue(); + } + + public static Progression Progression() + { + return RandomEnumValue(); + } + + public static Severity Severity() + { + return RandomEnumValue(); + } + + public static Priority Priority() + { + return RandomEnumValue(); + } + + public static T Value(ICollection values) + { + int pick = random.Next(values.Count); + return values.ElementAt(pick); + } + + private static T RandomEnumValue() + { + Array values = Enum.GetValues(typeof(T)); + return (T)values.GetValue(random.Next(values.Length)); + } + } +} diff --git a/frontend/cypress/integration/actions_spec.ts b/frontend/cypress/integration/actions_spec.ts index f2ae4e33..07635368 100644 --- a/frontend/cypress/integration/actions_spec.ts +++ b/frontend/cypress/integration/actions_spec.ts @@ -1,5 +1,5 @@ import { EvaluationSeed } from '../support/evaluation_seed' -import { Progression, Priority } from '../../src/api/models' +import { Progression, Priority, Role } from '../../src/api/models' import { FUSION_DATE_LOCALE } from '../support/helpers' import { barrierToString, organizationToString } from '../../src/utils/EnumToString' import { Action, Note, Participant } from '../support/mocks' @@ -130,7 +130,7 @@ describe('Actions', () => { ;({ seed, actionToDelete, actionToStay } = createDeleteSeed()) seed.plant().then(() => { - const user = faker.random.arrayElement(seed.participants).user + const user = faker.random.arrayElement(seed.participants.filter(x => x.role === Role.Facilitator)).user cy.visitEvaluation(seed.evaluationId, user) evaluationPage.progressionStepLink(deleteActionFrom).click() cy.contains(actionToDelete.title).should('exist') @@ -176,6 +176,7 @@ describe('Actions', () => { } }) + cy.login(seed.participants[0].user) deleteAction() cy.testCacheAndDB( diff --git a/frontend/cypress/support/evaluation_seed.ts b/frontend/cypress/support/evaluation_seed.ts index 089b4413..92618167 100644 --- a/frontend/cypress/support/evaluation_seed.ts +++ b/frontend/cypress/support/evaluation_seed.ts @@ -207,39 +207,34 @@ const populateDB = (seed: EvaluationSeed) => { }) }) .then(() => { - cy.log(`EvaluationSeed: Progressing evaluation for creator ${seed.participants[0].user}`) - cy.gql(PROGRESS_PARTICIPANT, { + return seed.participants.slice(1) + }) + .each((participant: Participant) => { + cy.log(`EvaluationSeed: Adding Participants`) + cy.gql(ADD_PARTICIPANT, { variables: { + azureUniqueId: participant.user.id, evaluationId: seed.evaluationId, - newProgression: seed.participants[0].progression, + organization: participant.organization, + role: participant.role, }, + }).then(res => { + participant.id = res.body.data.createParticipant.id }) }) .then(() => { - return seed.participants.slice(1) + return seed.participants }) .each((participant: Participant) => { - cy.log(`EvaluationSeed: Adding and progressing additional Participants`) - return cy - .gql(ADD_PARTICIPANT, { + cy.login(participant.user).then(() => { + cy.log(`EvaluationSeed: Progressing Participant`) + cy.gql(PROGRESS_PARTICIPANT, { variables: { - azureUniqueId: participant.user.id, evaluationId: seed.evaluationId, - organization: participant.organization, - role: participant.role, + newProgression: participant.progression, }, }) - .then(res => { - participant.id = res.body.data.createParticipant.id - cy.login(participant.user).then(() => { - cy.gql(PROGRESS_PARTICIPANT, { - variables: { - evaluationId: seed.evaluationId, - newProgression: participant.progression, - }, - }) - }) - }) + }) }) .then(() => { return seed.answers diff --git a/frontend/cypress/support/testdata.ts b/frontend/cypress/support/testdata.ts index 0bac24b5..9a4e9490 100644 --- a/frontend/cypress/support/testdata.ts +++ b/frontend/cypress/support/testdata.ts @@ -20,7 +20,7 @@ export function createAction( this: EvaluationSeed, { assignedTo = faker.random.arrayElement(this!.participants), - createdBy = faker.random.arrayElement(this!.participants), + createdBy = faker.random.arrayElement(this!.participants.filter(x => x.role !== Role.ReadOnly)), // no access to questions as creation is run before plant. Reconsider? questionOrder = faker.datatype.number({ min: 1, max: 3 }), dueDate = faker.date.future(), diff --git a/frontend/src/api/models.ts b/frontend/src/api/models.ts index a6b22c38..fd352506 100644 --- a/frontend/src/api/models.ts +++ b/frontend/src/api/models.ts @@ -327,7 +327,6 @@ export type Mutation = { editAction?: Maybe; deleteAction?: Maybe; createNote?: Maybe; - editNote?: Maybe; createClosingRemark?: Maybe; }; @@ -435,12 +434,6 @@ export type MutationCreateNoteArgs = { }; -export type MutationEditNoteArgs = { - noteId?: Maybe; - text?: Maybe; -}; - - export type MutationCreateClosingRemarkArgs = { actionId?: Maybe; text?: Maybe;