Skip to content
Open
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
18 changes: 3 additions & 15 deletions src/tests/views/Validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ describe('Validation.vue - Business Logic', () => {
expect(filesStore.addFile).not.toHaveBeenCalled()
})

it('updates the policies store when requester effective policies are returned', async () => {
it('shows the requester legal information returned with the validation', async () => {
const { usePoliciesStore } = await import('../../store/policies')
const policiesStore = usePoliciesStore()

Expand All @@ -1085,25 +1085,13 @@ describe('Validation.vue - Business Logic', () => {
legal_information: {
policyKey: 'legal_information',
effectiveValue: 'Requester legal copy',
sourceScope: 'user_policy',
visible: true,
editableByCurrentActor: false,
allowedValues: [],
canSaveAsUserDefault: false,
canUseAsRequestOverride: false,
preferenceWasCleared: false,
blockedBy: null,
},
},
},
})

expect(policiesStore.setPolicies).toHaveBeenCalledWith({
legal_information: expect.objectContaining({
effectiveValue: 'Requester legal copy',
sourceScope: 'user_policy',
}),
})
expect(wrapper.vm.legalInformation).toBe('Requester legal copy')
expect(policiesStore.setPolicies).not.toHaveBeenCalled()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The view Validation.vue no longer imports store/policies (neither do its child components, and the spec uses shallowMount), so setPolicies can never be called here. This assertion always passes and doesn't protect anything from 37d92dd.

Please remove:

  • this assertion and the usePoliciesStore lookup at the top of the test (lines 1078-1079);
  • the vi.mock('../../store/policies', ...) block at line 187, which is only used by this test.

The legalInformation assertion is enough to cover the new behavior.

})
})

Expand Down
5 changes: 4 additions & 1 deletion tests/php/Integration/Controller/PageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use OCA\Libresign\Service\IdentifyMethodService;
use OCA\Libresign\Service\Policy\PolicyAuthorizationService;
use OCA\Libresign\Service\Policy\PolicyService;
use OCA\Libresign\Service\Policy\ValidationEffectivePolicyService;
use OCA\Libresign\Service\RequestSignatureService;
use OCA\Libresign\Service\SessionService;
use OCA\Libresign\Service\SignerElementsService;
Expand Down Expand Up @@ -150,6 +151,7 @@ public function setUp(): void {
signFileService: $this->signFileService,
requestSignatureService: \OCP\Server::get(RequestSignatureService::class),
policyService: $this->policyService,
validationEffectivePolicyService: new ValidationEffectivePolicyService($this->policyService),
policyAuthorizationService: $this->policyAuthorizationService,
signerElementsService: $this->signerElementsService,
l10n: $this->createMock(IL10N::class),
Expand Down Expand Up @@ -343,6 +345,7 @@ public function testValidationFilePublicBootstrapsRequesterPoliciesWithoutUserSc
signFileService: $signFileService,
requestSignatureService: \OCP\Server::get(RequestSignatureService::class),
policyService: $policyService,
validationEffectivePolicyService: new ValidationEffectivePolicyService($policyService),
policyAuthorizationService: $this->policyAuthorizationService,
signerElementsService: $this->signerElementsService,
l10n: $this->createMock(IL10N::class),
Expand All @@ -362,7 +365,7 @@ public function testValidationFilePublicBootstrapsRequesterPoliciesWithoutUserSc

$response = $controller->validationFilePublic('validation-file-uuid');

self::assertArrayHasKey('effective_policies', $capturedInitialState);
self::assertSame(['policies' => []], $capturedInitialState['effective_policies'] ?? null);
self::assertSame('external', $response->getTemplateName());
self::assertSame(TemplateResponse::RENDER_AS_BASE, $response->getRenderAs());
}
Expand Down
Loading