Skip to content

feat: improve tests coverage#6894

Merged
vitormattos merged 12 commits intomainfrom
feat/improve-tests-coverage
Feb 16, 2026
Merged

feat: improve tests coverage#6894
vitormattos merged 12 commits intomainfrom
feat/improve-tests-coverage

Conversation

@vitormattos
Copy link
Member

No description provided.

Add comprehensive test coverage for additional store methods:
- isDocumentPending(): verify pending state when enabled/disabled
- showDocumentsComponent(): verify component visibility
- needIdentificationDocument(): verify multiple scenarios
- toggleModal(): verify modal visibility toggle

All scenarios tested for both enabled and disabled states.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add comprehensive test coverage for handleRouteChange method:
- Verify sidebar visibility is preserved for allowed routes:
  * fileslist, SignPDF, ValidationFile, IdDocsApprove
- Verify sidebar is hidden for non-allowed routes
- Verify sidebar is hidden when navigating to home
- Handle edge cases (null/undefined route names gracefully)

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add import of SIGN_REQUEST_STATUS constant and expand test coverage:
- Add identificationDocument store mock
- Add tests for approver scenarios without signer
- Add identification document pending check for approvers
- Add approver DRAFT status validation
- Add idDocApproval URL parameter tests
- Add getSignatureMethodsForFile() method tests
- Test fallback to file settings when no signer methods exist

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add tests for signer validation with draft files:
- testValidateSignerAllowsDraftWhenFileHasIdDocs: verify draft is allowed
  when file has identification documents attached
- testValidateSignerBlocksDraftWhenFileHasNoIdDocs: verify draft is blocked
  when no identification documents exist

These tests ensure proper validation of draft signatures based on
identification document availability.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Refactor test data providers to use PHP 8+ attributes:
- Add import for DataProvider attribute from PHPUnit
- Migrate from @dataProvider annotations to #[DataProvider] attributes:
  * providerTestValidateCertificateDataUsingDataProvider →
    provideValidateCertificateDataCases (with named test cases)
  * New: provideValidateCreateToSignCases with multiple scenarios:
    - Invalid UUID validation
    - UUID not found handling
    - Email mismatch detection
    - User already exists check
    - Empty password validation
    - File not found scenarios

All test cases include descriptive keys for better test reporting.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Refactor test to use PHP 8+ data provider attributes:
- Add DataProvider attribute import
- Migrate from individual test methods to parameterized test:
  * Consolidate multiple testGetSettings* methods
  * Create providerGetSettings() with 7 comprehensive scenarios:
    - User in authorized group with/without signature
    - User not in authorized group
    - User with/without signature file
    - Null user handling
    - Empty approval groups
    - Multiple approval groups with/without matches

Use #[DataProvider] attribute for cleaner test organization.
All test cases include descriptive keys for better reporting.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add tests for SignRequest handling in FileResponseOptions:
- testDefaultSignRequestIsNull: verify SignRequest is null by default
- testCanSetSignRequest: verify ability to set and retrieve SignRequest
- testCanSetSignRequestToNull: verify ability to clear SignRequest

Include SignRequest import from OCA\Libresign\Db namespace.
Tests verify fluent interface compatibility for method chaining.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Major refactoring to use PHP 8+ attributes and parameterized tests:

Add imports:
- SignRequest entity for test mocking
- DataProvider attribute from PHPUnit

Consolidate identification document status tests:
- Create providerGetIdentificationDocumentsStatus() with 11 scenarios:
  * Disabled feature handling
  * No files → NEED_SEND
  * All deleted files → NEED_SEND
  * Mixed signed/draft → NEED_APPROVAL
  * All signed → APPROVED
  * User in approval group → APPROVED
  * SignRequest scenarios with various file states
  * Edge cases (null user/signRequest)
  * Single vs multiple file states

Consolidate user identification settings tests:
- Create providerGetUserIdentificationSettings() with 7 scenarios:
  * All feature states (disabled/enabled)
  * All identification statuses (NEED_SEND, NEED_APPROVAL, APPROVED)
  * User and signRequest variations
  * Expected outcomes for needIdentificationDocuments and
    identificationDocumentsWaitingApproval

Migrate from individual test methods to single parameterized methods
using #[DataProvider] attributes. All test cases include descriptive keys.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Simplify and reorganize IdDocsServiceTest:
- Remove unnecessary mock dependencies and imports
- Keep only essential mocks for IdDocsService:
  * IL10N, FileTypeMapper, IdDocsMapper
  * FileMapper, SignRequestMapper, IdentifyMethodMapper
  * ValidateHelper, RequestSignatureService, TimeFactory, IAppConfig

Remove unused AccountService-related test methods.

Keep core deletion tests:
- testDeleteIdDocAsApproverBypassesOwnershipCheck: approver can delete
- testDeleteIdDocAsNonApproverValidatesOwnership: non-approver must own doc
- testDeleteIdDocBySignRequestValidatesAndDeletes: delete via sign request
- testDeleteIdDocBySignRequestThrowsOnInvalidDoc: error on invalid doc

Improve getService() method to use proper constructor injection
for IdDocsService instead of AccountService.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add comprehensive tests for getSignRequestToSign method:

1. testGetSignRequestToSignUsesUuid: retrieve sign request by UUID
   - Validates file can be signed
   - Fetches correct sign request from mapper
   - Sets sequential signing context

2. testGetSignRequestToSignCreatesApproverSignRequest: approver flow
   - Creates new sign request for approvers
   - Validates approver has id docs to sign
   - Uses createOrUpdateSignRequest service

3. testGetSignRequestToSignFindsByIdentifyMethod: identify method matching
   - Test multiple identifier types (email, account)
   - Correct matching by UID or email address
   - Multiple sign requests with different identifiers
   - Exception on no match found

4. testGetSignRequestToSignFallsBackWhenApproverCreationFails: error handling
   - Gracefully falls back when id docs don't exist
   - Searches existing sign requests on failure
   - Returns matching sign request by identifier

Include import of IdDocs entity for test mocking.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos added this to the Next Major (34) milestone Feb 16, 2026
@vitormattos vitormattos self-assigned this Feb 16, 2026
@github-project-automation github-project-automation bot moved this to 0. Needs triage in Roadmap Feb 16, 2026
@vitormattos
Copy link
Member Author

/backport to stable33

@vitormattos
Copy link
Member Author

/backport to stable32

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos merged commit 6dae714 into main Feb 16, 2026
69 of 71 checks passed
@vitormattos vitormattos deleted the feat/improve-tests-coverage branch February 16, 2026 17:01
@github-project-automation github-project-automation bot moved this from 0. Needs triage to 4. to release in Roadmap Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 4. to release

Development

Successfully merging this pull request may close these issues.

1 participant

Comments