From 851bf5bea8e04a655ff98998b6a21e636cd69f5a Mon Sep 17 00:00:00 2001 From: Solomon Nsubuga Date: Thu, 15 Aug 2024 12:57:39 +0100 Subject: [PATCH] Fix the issue of not loading green book through id_selection config --- .../cypress/fixtures/valid_documents.json | 13 ++--- .../pages/document-verification-za.html | 47 +++++++++++++++++++ .../embed/cypress/tests/id-selection.cy.cjs | 17 +++++++ packages/embed/src/js/doc-verification.js | 6 ++- 4 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 packages/embed/cypress/pages/document-verification-za.html diff --git a/packages/embed/cypress/fixtures/valid_documents.json b/packages/embed/cypress/fixtures/valid_documents.json index 37bb6750..45273185 100644 --- a/packages/embed/cypress/fixtures/valid_documents.json +++ b/packages/embed/cypress/fixtures/valid_documents.json @@ -9715,12 +9715,13 @@ "name": "Identity Card", "has_back": true, "code": "IDENTITY_CARD", - "example": [ - "National IDs", - "Green Book", - "Consular IDs", - "Diplomat IDs" - ] + "example": ["National IDs", "Consular IDs", "Diplomat IDs"] + }, + { + "name": "Green Book", + "has_back": false, + "code": "IDENTITY_CARD", + "example": ["Green Book"] }, { "name": "Passport", diff --git a/packages/embed/cypress/pages/document-verification-za.html b/packages/embed/cypress/pages/document-verification-za.html new file mode 100644 index 00000000..14995e3c --- /dev/null +++ b/packages/embed/cypress/pages/document-verification-za.html @@ -0,0 +1,47 @@ + + + + + + + + + + + + + diff --git a/packages/embed/cypress/tests/id-selection.cy.cjs b/packages/embed/cypress/tests/id-selection.cy.cjs index 8ba2ed91..f082853a 100644 --- a/packages/embed/cypress/tests/id-selection.cy.cjs +++ b/packages/embed/cypress/tests/id-selection.cy.cjs @@ -302,6 +302,23 @@ describe('Preselected Country', () => { .should('contain', 'Bank Verification'); }); + it('should have the correct country and id_types if IDENTITY CARD is pre-selected', () => { + cy.visit('/document-verification-za'); + + cy.loadIDOptions(); + cy.getIFrameBody().find('#country').should('contain', 'South Africa'); + + cy.getIFrameBody().find('smileid-combobox-trigger > button').click(); + + cy.getIFrameBody() + .find('smileid-combobox-option[value="IDENTITY_CARD__Identity Card"]') + .should('be.visible'); + + cy.getIFrameBody() + .find('smileid-combobox-option[value="IDENTITY_CARD__Green Book"]') + .should('be.visible'); + }); + it('document_verification', () => { cy.visit('/document-verification-pre-select-country'); diff --git a/packages/embed/src/js/doc-verification.js b/packages/embed/src/js/doc-verification.js index 46de0e63..78f57c6b 100644 --- a/packages/embed/src/js/doc-verification.js +++ b/packages/embed/src/js/doc-verification.js @@ -321,7 +321,11 @@ import { version as sdkVersion } from '../../package.json'; }; const idTypes = config.id_selection[selectedCountry]; - if (idTypes.length === 1 || typeof idTypes === 'string') { + + if ( + (idTypes.length === 1 || typeof idTypes === 'string') && + !(idTypes.includes('IDENTITY_CARD') && selectedCountry === 'ZA') + ) { id_info.id_type = Array.isArray(idTypes) ? idTypes[0] : idTypes; const countryConstraints = constraints.find(