Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Add "Messaging not disabled" to tab display conditions #57

Merged
merged 5 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions module/Olcs/src/Controller/Listener/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,19 @@ private function toggleMessagesTab(bool $shouldShowMessagesTab): void

private function shouldShowMessagesTab(): bool
{
$hasPendingOrValidLicence = $this->identity->getUserData()['hasOrganisationSubmittedLicenceApplication'];
$messagingToggleEnabled = $this->querySender->featuresEnabled([FeatureToggle::MESSAGING]);

$messagingToggleState = $this->querySender->featuresEnabled([FeatureToggle::MESSAGING]);
$userData = $this->identity->getUserData();

return $messagingToggleState && $hasPendingOrValidLicence;
$hasOrganisationSubmittedLicenceApplication = $userData['hasOrganisationSubmittedLicenceApplication'];

$isMessagingEnabled = $userData['organisationUsers'][0]['organisation']['isMessagingDisabled'] === false;

return (
$messagingToggleEnabled &&
$hasOrganisationSubmittedLicenceApplication &&
$isMessagingEnabled
);
}

/**
Expand Down
49 changes: 45 additions & 4 deletions test/Olcs/src/Controller/Listener/NavigationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,18 @@ public function testOnDispatchWithNoReferalAnonymousUser()
{
$this->mockIdentity->shouldReceive('isAnonymous')->once()->withNoArgs()->andReturn(true);

$this->mockIdentity->expects('getUserData')->once()->andReturn(['hasOrganisationSubmittedLicenceApplication' => false]);
$this->mockIdentity->expects('getUserData')
->once()
->andReturn([
'hasOrganisationSubmittedLicenceApplication' => false,
'organisationUsers' => [
0 => [
'organisation' => [
'isMessagingDisabled' => false
]
]
]
]);

$this->mockQuerySender->shouldReceive('featuresEnabled')->with([$this->messagingToggle])->once();

Expand Down Expand Up @@ -101,9 +112,20 @@ public function testOnDispatchWithNoReferalAnonymousUser()
public function testOnDispatchWithNoReferal($eligibleForPermits)
{
$this->mockIdentity->shouldReceive('isAnonymous')->once()->withNoArgs()->andReturn(false);

$this->mockIdentity->expects('getUserData')
->twice()
->andReturn(['eligibleForPermits' => $eligibleForPermits, 'hasOrganisationSubmittedLicenceApplication' => false]);
->andReturn([
'eligibleForPermits' => $eligibleForPermits,
'hasOrganisationSubmittedLicenceApplication' => false,
'organisationUsers' => [
0 => [
'organisation' => [
'isMessagingDisabled' => false
]
]
]
]);

$this->mockQuerySender->shouldReceive('featuresEnabled')->with([$this->messagingToggle])->once();

Expand Down Expand Up @@ -155,7 +177,16 @@ public function testOnDispatchWithGovUkReferalMatch()

$this->mockIdentity->expects('getUserData')
->once()
->andReturn(['hasOrganisationSubmittedLicenceApplication' => false]);
->andReturn([
'hasOrganisationSubmittedLicenceApplication' => false,
'organisationUsers' => [
0 => [
'organisation' => [
'isMessagingDisabled' => false
]
]
]
]);

$this->mockQuerySender->shouldReceive('featuresEnabled')->once()->with([$this->messagingToggle]);

Expand Down Expand Up @@ -192,7 +223,17 @@ public function testOnDispatchWithNoGovUkReferal($eligibleForPermits)

$this->mockIdentity->expects('getUserData')
->twice()
->andReturn(['eligibleForPermits' => $eligibleForPermits, 'hasOrganisationSubmittedLicenceApplication' => false]);
->andReturn([
'eligibleForPermits' => $eligibleForPermits,
'hasOrganisationSubmittedLicenceApplication' => false,
'organisationUsers' => [
0 => [
'organisation' => [
'isMessagingDisabled' => false
]
]
]
]);

$this->mockNavigation
->shouldReceive('findBy')
Expand Down
Loading