Skip to content

Commit

Permalink
enh(DocVerification): support global document verification (#57)
Browse files Browse the repository at this point in the history
* refactor: remove development environment

* redesign: use `valid_documents` for global doc v

* tests: fix flaxy tests by loading fixtures early

* assets: change the chevron-down icon, add chevron-up

* enh: add `Combobox` component for autocomplete, custom dropdown

* enh: use `Combobox in document verification

* tests: rewrite tests for a combobox world

* temp: use preview build of updated smart-camera-web for global doc v

* enh(Combobox): add button next to input for text

- add focus / blur events to input
- add button for control of listbox

* enh: handle single country case

* tests: select id type using direct descendant selector

* enh(Combobox): add `value` and `disabled` attributes

* redesign(Combobox): remove focus / blur listeners on input, fix spaces

* redesign: fix preselection state for document verification

* tests: load id options in before each hooks

* tests: fix test names for verification-method-selection

* enh: change back / close buttons

* styles: add hover styles for combobox-option

* refactor: remove search icon from Combobox

* styles(combobox): listbox inline-size should match trigger, add .5rem offset

* fix: reload id types on country change

* refactor: use function and not arrow function

* refactor: close combobox on external click or focus event

* tests: fix failing test

* version: bump version number for global docv

* redesign: support legacy id types

* fix: fix lint errors

* refactor: rename eslintrc as cjs

* fix: reference minified file

* refactor: reinstate global doc v changes

* tests: fix broken test

* tmp: use unminified versions for debugging

* Revert "tmp: use unminified versions for debugging"

This reverts commit ebf0afe.

* enh: allow "Others" in id_selection

* format: use spaces and not tabs

* enh: make "others" check in id_selection case insensitive

* fix: fix lint error

* fix: fix "others" case insensitive bug

* version: bump version for global doc v
  • Loading branch information
tamssokari authored Oct 5, 2023
1 parent 7983521 commit b9b077e
Show file tree
Hide file tree
Showing 26 changed files with 17,354 additions and 351 deletions.
15,877 changes: 15,877 additions & 0 deletions cypress/fixtures/valid_documents.json

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions cypress/pages/document-verification-legacy-id_types.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
max-width: 100%;
min-height: 100%;
}
</style>
</head>

<body>
<script src="js/script.min.js"></script>

<script>
SmileIdentity({
token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXJ0bmVyX3BhcmFtcyI6eyJ1c2VyX2lkIjoidXNlci1mZTIwY2JkYS1jMjJiLTRmZmUtOWRlZC05YjZhZGI2MDE1ZmIiLCJqb2JfaWQiOiJqb2ItNjYzY2VhNTUtZWIxYy00MjI2LWI1N2YtOGEwMTAwOTc4ZjViIiwiam9iX3R5cGUiOjF9LCJjYWxsYmFja191cmwiOiJodHRwczovL3dlYmhvb2suc2l0ZS9iZTM0YzkzZC1hOTFmLTQzZGItYWVmMi05MDZjNWNkOTVkNDciLCJpYXQiOjE2MzQyODE0MTAsImV4cCI6MTYzNTkxNTY4NH0.B4JaP4UWbNs38hV9nQ_9_Pnpos0fM3qu2nGG7Eymjs8",
product: "doc_verification",
callback_url:
"https://portal.smileidentity.com/api/v2/007/postback/update_status",
environment: "sandbox",
id_selection: {
NG: ["DRIVERS_LICENSE", "VOTER_ID", "PASSPORT"],
ZA: ["NATIONAL_ID", "GREEN_BOOK", "Others"],
GH: ["SSNIT"],
},
partner_details: {
name: "Test Org",
logo_url: "https://portal.smileidentity.com/favicon.ico",
partner_id: "007",
policy_url: "https://smileidentity.com/privacy-policy",
theme_color: "#000",
},
onSuccess: () => {},
onClose: () => {},
});
</script>
</body>
</html>
32 changes: 30 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Cypress.Commands.add("loadIDOptions", () => {

cy.intercept("GET", "**/v1/services", { fixture: "services.json" });

cy.intercept("POST", "**/v1/valid_documents", {
fixture: "valid_documents.json",
});

cy.intercept("POST", "**/v1/products_config", {
fixture: "products_config.json",
});
Expand Down Expand Up @@ -133,9 +137,33 @@ Cypress.Commands.add("selectPASSPORTIDType", () => {

cy.log("selectingPASSPORTIDType");

cy.getIFrameBody().find("#country").select("NG");
cy.getIFrameBody().find("smileid-combobox-trigger input").type("Nigeria");

cy.getIFrameBody().find('smileid-combobox-option[value="NG"]').click();

cy.getIFrameBody().find("smileid-combobox-trigger > button").click();

cy.getIFrameBody().find("#id_type").select("PASSPORT");
cy.getIFrameBody().find('smileid-combobox-option[value="PASSPORT"]').click();

cy.getIFrameBody().find("#submitConfig").click();
});

Cypress.Commands.add("selectZAGREENBOOKIDType", () => {
cy.loadIDOptions();

cy.log("selectingPASSPORTIDType");

cy.getIFrameBody()
.find("smileid-combobox-trigger input")
.type("South Africa");

cy.getIFrameBody().find('smileid-combobox-option[value="ZA"]').click();

cy.getIFrameBody().find("smileid-combobox-trigger > button").click();

cy.getIFrameBody()
.find('smileid-combobox-option[value="GREEN_BOOK"]')
.click();

cy.getIFrameBody().find("#submitConfig").click();
});
Expand Down
74 changes: 43 additions & 31 deletions cypress/tests/consent-required.cy.cjs
Original file line number Diff line number Diff line change
@@ -1,47 +1,59 @@
it("should show consent screen for the required id type", () => {
cy.visit("/consent-required");
describe("consent required", () => {
beforeEach(() => {
cy.loadIDOptions();
});

cy.selectBVNIDType();
it("should show consent screen for the required id type", () => {
cy.visit("/consent-required");

cy.getIFrameBody()
.find("end-user-consent")
.shadow()
.find("#consent-screen")
.should("be.visible");
});
cy.selectBVNIDType();

it("should NOT show consent screen for the non-required id type", () => {
cy.visit("/consent-required");
cy.getIFrameBody()
.find("end-user-consent")
.shadow()
.find("#consent-screen")
.should("be.visible");
});

cy.loadIDOptions();
it("should NOT show consent screen for the non-required id type", () => {
cy.visit("/consent-required");

cy.getIFrameBody()
.find("#country")
.select("Nigeria")
.should("have.value", "NG");
cy.loadIDOptions();

cy.getIFrameBody().find("#id_type").select("NIN").should("have.value", "NIN");
cy.getIFrameBody()
.find("#country")
.select("Nigeria")
.should("have.value", "NG");

cy.getIFrameBody().find("#submitConfig").click();
cy.getIFrameBody()
.find("#id_type")
.select("NIN")
.should("have.value", "NIN");

cy.getIFrameBody().find("end-user-consent").should("not.exist");
});
cy.getIFrameBody().find("#submitConfig").click();

cy.getIFrameBody().find("end-user-consent").should("not.exist");
});

it("should NOT show consent screen when configuration is absent", () => {
cy.visit("/consent-not-required");
it("should NOT show consent screen when configuration is absent", () => {
cy.visit("/consent-not-required");

cy.loadIDOptions();
cy.loadIDOptions();

cy.getIFrameBody()
.find("#country")
.select("Nigeria")
.should("have.value", "NG");
cy.getIFrameBody()
.find("#country")
.select("Nigeria")
.should("have.value", "NG");

cy.getIFrameBody().find("#id_type").select("NIN").should("have.value", "NIN");
cy.getIFrameBody()
.find("#id_type")
.select("NIN")
.should("have.value", "NIN");

cy.getIFrameBody().find("#submitConfig").click();
cy.getIFrameBody().find("#submitConfig").click();

cy.getIFrameBody().find("end-user-consent").should("not.exist");
cy.getIFrameBody().find("end-user-consent").should("not.exist");

cy.getIFrameBody().find("smart-camera-web").should("exist");
cy.getIFrameBody().find("smart-camera-web").should("exist");
});
});
2 changes: 2 additions & 0 deletions cypress/tests/data-input.cy.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
describe("id-info screen", () => {
beforeEach(() => {
cy.loadIDOptions();

cy.visit("/");

cy.selectNINIDType();
Expand Down
112 changes: 106 additions & 6 deletions cypress/tests/document-verification.cy.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ describe("document verification", () => {

cy.visit("/document-verification");

cy.getIFrameBody().find("#country").select("NG");

cy.getIFrameBody().find("#id_type").select("NATIONAL_ID");

cy.getIFrameBody().find("#submitConfig").click();
cy.selectPASSPORTIDType();

cy.navigateThroughCameraScreens();
});
Expand All @@ -38,7 +34,111 @@ describe("document verification", () => {
cy.getIFrameBody()
.find("smart-camera-web")
.invoke("attr", "document-type")
.should("eq", "NATIONAL_ID");
.should("eq", "PASSPORT");

cy.getIFrameBody()
.find("smart-camera-web")
.shadow()
.find("#id-entry-screen")
.should("be.visible");

cy.getIFrameBody()
.find("smart-camera-web")
.shadow()
.find("#id-entry-screen #take-photo")
.click();

cy.getIFrameBody()
.find("smart-camera-web")
.shadow()
.find("#id-camera-screen")
.should("be.visible");

cy.getIFrameBody()
.find("smart-camera-web")
.shadow()
.find("#capture-id-image")
.click();

cy.wait(2000);

cy.getIFrameBody()
.find("smart-camera-web")
.shadow()
.find("#id-camera-screen")
.should("not.be.visible");

cy.getIFrameBody()
.find("smart-camera-web")
.shadow()
.find("#select-id-image")
.click();

cy.getIFrameBody()
.find("smart-camera-web")
.shadow()
.find("#id-review-screen")
.should("not.be.visible");

cy.wait("@getUploadURL");

cy.wait("@successfulUpload");

cy.getIFrameBody().find("#complete-screen").should("be.visible");
});
});

describe("legacy support - preselected country / id_types", () => {
beforeEach(() => {
cy.intercept(
{
method: "POST",
url: "*upload*",
},
{
upload_url:
"https://smile-uploads-development01.s3.us-west-2.amazonaws.com/videos/212/212-0000060103-0gdzke3mdtlco5k0sdfh6vifzcrd3n/ekyc_smartselfie.zip",
},
).as("getUploadURL");

cy.intercept(
{
method: "PUT",
url: "https://smile-uploads-development01.s3.us-west-2.amazonaws.com/videos/212/212-0000060103-0gdzke3mdtlco5k0sdfh6vifzcrd3n/ekyc_smartselfie.zip",
},
{
statusCode: 200,
},
).as("successfulUpload");

cy.loadIDOptions();

cy.visit("/document-verification-legacy-id_types");
});

it("should show the Others input when selected", () => {
cy.getIFrameBody()
.find("smileid-combobox-trigger input")
.type("South Africa");

cy.getIFrameBody().find('smileid-combobox-option[value="ZA"]').click();

cy.getIFrameBody().find("smileid-combobox-trigger > button").click();

cy.getIFrameBody()
.find('smileid-combobox-option[value=""]')
.should("be.visible");
});

it("should allow legacy id_types without capturing the back", () => {
cy.selectZAGREENBOOKIDType();

cy.navigateThroughCameraScreens();

cy.getIFrameBody()
.find("smart-camera-web")
.invoke("attr", "document-type")
.should("eq", "GREEN_BOOK");

cy.getIFrameBody()
.find("smart-camera-web")
Expand Down
18 changes: 14 additions & 4 deletions cypress/tests/id-selection.cy.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ describe("No ID Selection", () => {
});

describe("Preselected Country", () => {
beforeEach(() => {
cy.loadIDOptions();
});

it("basic_kyc", () => {
cy.visit("/basic_kyc_pre_select_country");

Expand Down Expand Up @@ -326,7 +330,11 @@ describe("Preselected Country", () => {

cy.getIFrameBody().find("#country").should("contain", "Nigeria");

cy.getIFrameBody().find("#id_type").select("PASSPORT");
cy.getIFrameBody().find("smileid-combobox-trigger > button").click();

cy.getIFrameBody()
.find('smileid-combobox-option[value="PASSPORT"]')
.click();

cy.getIFrameBody().find("#submitConfig").click();

Expand Down Expand Up @@ -429,6 +437,10 @@ describe("Preselected Country", () => {
});

describe("Preselected Country and ID Type", () => {
beforeEach(() => {
cy.loadIDOptions();
});

it("basic_kyc", () => {
cy.visit("/basic_kyc_pre_select_id_type");

Expand Down Expand Up @@ -556,9 +568,7 @@ describe("Preselected Country and ID Type", () => {

cy.loadIDOptions();

cy.getIFrameBody().find("#country").should("not.be.visible");

cy.getIFrameBody().find("#id_type").should("not.be.visible");
cy.getIFrameBody().find("#id_type").should("not.exist");

cy.getIFrameBody().find("smart-camera-web").should("be.visible");

Expand Down
1 change: 1 addition & 0 deletions cypress/tests/kra-verification.cy.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ describe("KRA PIN verification enhanced kyc", () => {
},
).as("submitIdVerification");

cy.loadIDOptions();
cy.visit("/kra-verification-ekyc");

cy.selectKRAType();
Expand Down
10 changes: 7 additions & 3 deletions cypress/tests/verification-method-selection.cy.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ describe("Verification Method Selection", () => {
});

describe("doc_verification", () => {
it("should redirect to the biometric kyc sequence in a nested iframe", () => {
cy.selectPASSPORTIDType();
it("should redirect to the document verification sequence in a nested iframe", () => {
cy.getIFrameBody().find("#country").select("NG");

cy.getIFrameBody().find("#id_type").select("PASSPORT");

cy.getIFrameBody().find("#submitConfig").click();

cy.getIFrameBody()
.find(
Expand All @@ -37,7 +41,7 @@ describe("Verification Method Selection", () => {
});

describe("enhanced_kyc", () => {
it("should redirect to the biometric kyc sequence in a nested iframe", () => {
it("should redirect to the enhanced kyc sequence in a nested iframe", () => {
cy.selectNINIDType();

cy.getIFrameBody()
Expand Down
Loading

0 comments on commit b9b077e

Please sign in to comment.