+ {{ icon('circle-user') }} {% if message.createdBy == ticket.requester %} @@ -71,6 +71,12 @@ + {% if ticket.solution == message %} + + {{ icon('check') }} + + {% endif %} + {{ message.createdBy.email }} @@ -93,7 +99,8 @@ @@ -128,6 +135,21 @@ >{{ message }} + + + + + {{ 'Mark as solution' | trans }} + + + @@ -143,6 +165,7 @@ aria-invalid="true" aria-errormessage="status-error" {% endif %} + data-ticket-editor-target="statusSelect" > {% for value, label in statuses %} diff --git a/tests/Controller/Organizations/TicketsControllerTest.php b/tests/Controller/Organizations/TicketsControllerTest.php index 3a1e61e7..298eb95a 100644 --- a/tests/Controller/Organizations/TicketsControllerTest.php +++ b/tests/Controller/Organizations/TicketsControllerTest.php @@ -192,6 +192,7 @@ public function testPostCreateCreatesATicketAndRedirects(): void $this->assertSame('medium', $ticket->getUrgency()); $this->assertSame('medium', $ticket->getImpact()); $this->assertSame('medium', $ticket->getPriority()); + $this->assertNull($ticket->getSolution()); $this->assertSame($requester->getId(), $ticket->getRequester()->getId()); $this->assertSame($assignee->getId(), $ticket->getAssignee()->getId()); $this->assertSame($organization->getId(), $ticket->getOrganization()->getId()); @@ -201,7 +202,6 @@ public function testPostCreateCreatesATicketAndRedirects(): void $this->assertSame($user->getId(), $message->getCreatedBy()->getId()); $this->assertSame($ticket->getId(), $message->getTicket()->getId()); $this->assertFalse($message->isPrivate()); - $this->assertFalse($message->isSolution()); $this->assertSame('webapp', $message->getVia()); } diff --git a/tests/Controller/Tickets/MessagesControllerTest.php b/tests/Controller/Tickets/MessagesControllerTest.php index f9364086..079ec506 100644 --- a/tests/Controller/Tickets/MessagesControllerTest.php +++ b/tests/Controller/Tickets/MessagesControllerTest.php @@ -48,7 +48,6 @@ public function testPostCreateCreatesAMessageAndRedirects(): void $this->assertSame($user->getId(), $message->getCreatedBy()->getId()); $this->assertSame($ticket->getId(), $message->getTicket()->getId()); $this->assertFalse($message->isPrivate()); - $this->assertFalse($message->isSolution()); $this->assertSame('webapp', $message->getVia()); } @@ -101,6 +100,37 @@ public function testPostCreateChangesTheTicketStatus(): void $this->assertSame('pending', $ticket->getStatus()); } + public function testPostCreateForcesStatusToResolvedIfIsSolutionIsTrue(): void + { + $now = new \DateTimeImmutable('2022-11-02'); + Time::freeze($now); + $client = static::createClient(); + $user = UserFactory::createOne(); + $client->loginUser($user->object()); + $ticket = TicketFactory::createOne([ + 'createdBy' => $user, + 'status' => 'in_progress', + ]); + $messageContent = 'My message'; + + $this->assertSame(0, MessageFactory::count()); + + $client->request('GET', "/tickets/{$ticket->getUid()}"); + $crawler = $client->submitForm('form-create-message-submit', [ + 'message' => $messageContent, + 'isSolution' => true, + ]); + + Time::unfreeze(); + $this->assertSame(1, MessageFactory::count()); + + $this->assertResponseRedirects("/tickets/{$ticket->getUid()}", 302); + $message = MessageFactory::first(); + $ticket->refresh(); + $this->assertSame($message->getId(), $ticket->getSolution()->getId()); + $this->assertSame('resolved', $ticket->getStatus()); + } + public function testPostCreateFailsIfMessageIsEmpty(): void { $client = static::createClient(); diff --git a/translations/messages.en_GB.yaml b/translations/messages.en_GB.yaml index 88da7c58..754f48c6 100644 --- a/translations/messages.en_GB.yaml +++ b/translations/messages.en_GB.yaml @@ -71,3 +71,5 @@ Actions: Actions 'My tickets': 'My tickets' 'No ticket': 'No ticket' 'No organization': 'No organization' +'This message resolved the ticket': 'This message resolved the ticket' +'Mark as solution': 'Mark as solution' diff --git a/translations/messages.fr_FR.yaml b/translations/messages.fr_FR.yaml index 589da474..ebb1c0a0 100644 --- a/translations/messages.fr_FR.yaml +++ b/translations/messages.fr_FR.yaml @@ -71,3 +71,5 @@ Actions: Actions 'My tickets': 'Mes tickets' 'No ticket': 'Aucun ticket' 'No organization': 'Aucune organisation' +'This message resolved the ticket': 'Ce message a résolu le ticket' +'Mark as solution': 'Marquer comme solution'
{{ icon('circle-user') }} {% if message.createdBy == ticket.requester %} @@ -71,6 +71,12 @@ + {% if ticket.solution == message %} + + {{ icon('check') }} + + {% endif %} + {{ message.createdBy.email }} @@ -93,7 +99,8 @@ @@ -128,6 +135,21 @@ >{{ message }} + + + + + {{ 'Mark as solution' | trans }} + + + @@ -143,6 +165,7 @@ aria-invalid="true" aria-errormessage="status-error" {% endif %} + data-ticket-editor-target="statusSelect" > {% for value, label in statuses %} diff --git a/tests/Controller/Organizations/TicketsControllerTest.php b/tests/Controller/Organizations/TicketsControllerTest.php index 3a1e61e7..298eb95a 100644 --- a/tests/Controller/Organizations/TicketsControllerTest.php +++ b/tests/Controller/Organizations/TicketsControllerTest.php @@ -192,6 +192,7 @@ public function testPostCreateCreatesATicketAndRedirects(): void $this->assertSame('medium', $ticket->getUrgency()); $this->assertSame('medium', $ticket->getImpact()); $this->assertSame('medium', $ticket->getPriority()); + $this->assertNull($ticket->getSolution()); $this->assertSame($requester->getId(), $ticket->getRequester()->getId()); $this->assertSame($assignee->getId(), $ticket->getAssignee()->getId()); $this->assertSame($organization->getId(), $ticket->getOrganization()->getId()); @@ -201,7 +202,6 @@ public function testPostCreateCreatesATicketAndRedirects(): void $this->assertSame($user->getId(), $message->getCreatedBy()->getId()); $this->assertSame($ticket->getId(), $message->getTicket()->getId()); $this->assertFalse($message->isPrivate()); - $this->assertFalse($message->isSolution()); $this->assertSame('webapp', $message->getVia()); } diff --git a/tests/Controller/Tickets/MessagesControllerTest.php b/tests/Controller/Tickets/MessagesControllerTest.php index f9364086..079ec506 100644 --- a/tests/Controller/Tickets/MessagesControllerTest.php +++ b/tests/Controller/Tickets/MessagesControllerTest.php @@ -48,7 +48,6 @@ public function testPostCreateCreatesAMessageAndRedirects(): void $this->assertSame($user->getId(), $message->getCreatedBy()->getId()); $this->assertSame($ticket->getId(), $message->getTicket()->getId()); $this->assertFalse($message->isPrivate()); - $this->assertFalse($message->isSolution()); $this->assertSame('webapp', $message->getVia()); } @@ -101,6 +100,37 @@ public function testPostCreateChangesTheTicketStatus(): void $this->assertSame('pending', $ticket->getStatus()); } + public function testPostCreateForcesStatusToResolvedIfIsSolutionIsTrue(): void + { + $now = new \DateTimeImmutable('2022-11-02'); + Time::freeze($now); + $client = static::createClient(); + $user = UserFactory::createOne(); + $client->loginUser($user->object()); + $ticket = TicketFactory::createOne([ + 'createdBy' => $user, + 'status' => 'in_progress', + ]); + $messageContent = 'My message'; + + $this->assertSame(0, MessageFactory::count()); + + $client->request('GET', "/tickets/{$ticket->getUid()}"); + $crawler = $client->submitForm('form-create-message-submit', [ + 'message' => $messageContent, + 'isSolution' => true, + ]); + + Time::unfreeze(); + $this->assertSame(1, MessageFactory::count()); + + $this->assertResponseRedirects("/tickets/{$ticket->getUid()}", 302); + $message = MessageFactory::first(); + $ticket->refresh(); + $this->assertSame($message->getId(), $ticket->getSolution()->getId()); + $this->assertSame('resolved', $ticket->getStatus()); + } + public function testPostCreateFailsIfMessageIsEmpty(): void { $client = static::createClient(); diff --git a/translations/messages.en_GB.yaml b/translations/messages.en_GB.yaml index 88da7c58..754f48c6 100644 --- a/translations/messages.en_GB.yaml +++ b/translations/messages.en_GB.yaml @@ -71,3 +71,5 @@ Actions: Actions 'My tickets': 'My tickets' 'No ticket': 'No ticket' 'No organization': 'No organization' +'This message resolved the ticket': 'This message resolved the ticket' +'Mark as solution': 'Mark as solution' diff --git a/translations/messages.fr_FR.yaml b/translations/messages.fr_FR.yaml index 589da474..ebb1c0a0 100644 --- a/translations/messages.fr_FR.yaml +++ b/translations/messages.fr_FR.yaml @@ -71,3 +71,5 @@ Actions: Actions 'My tickets': 'Mes tickets' 'No ticket': 'Aucun ticket' 'No organization': 'Aucune organisation' +'This message resolved the ticket': 'Ce message a résolu le ticket' +'Mark as solution': 'Marquer comme solution'