Skip to content

Commit

Permalink
tests: add tests for eSignature product
Browse files Browse the repository at this point in the history
  • Loading branch information
tams sokari committed Dec 4, 2023
1 parent 765df6b commit 89a6c00
Show file tree
Hide file tree
Showing 7 changed files with 267 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/embed/cypress/fixtures/e_signature_documents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"documents": [
{
"id": "07ef4595-aaed-4597-b6af-444986ae4565",
"link": "https://smile-signable-document-development.s3.us-west-2.amazonaws.com/development/921/SINGLE_USE/caa31f97-0056-4672-99de-2e1b1c439e82-privacy%20policy.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=ASIA4OAOFXPAHPEZQXW5%2F20231202%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20231202T190423Z&X-Amz-Expires=900&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEMv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIQDx6xxYPXeC6Nm1O6NkDRWNskY6jpWnTo0rhGsSq%2FhLpQIgP3rVKh1%2B0Mm8tceD%2BXXRPeyRCZHysxZNw6YFxhN0EXQqpwMINBADGgw4NTQ3MjgyMjc3NzYiDBIuWCw54%2BS8bXD4iiqEAygeRz2MdUibORe2HlZ7I53MftfqQdqtUZ6CCzSee%2F53ERKuFuQ59SfeEX6KwEpfDsgKxAJsSE%2B5DWdFz3F4KLXeaVb9Ri9EHl7%2BYfYFbFUe25eCk1r0%2FewDpEgDlYr7KSuV84oNCJDmHxxa%2BsMcG6PvfBJ26UNUk5MhHfYBaqhjLTHSlFODgu%2FwYalDEcEcyK5oiJfr3%2BUx8KcNlpQVx2ep%2BbNidaVX30K2lIGqkQ9BFTjYGGzXlJ2JuNoTQjNdobptZdL8lawO1MuXaBJLdFy3AMSbcB8Bp4v39N1HA5q5aVd3odt0JEBpJ0H9pf%2BBa%2BNsS5kaMXwO0w0xjc7SLDHSClMexzwf4vXqLHMW6oPbGvUMIwmqpkYVSkhPPBBDOpEO%2FezO1Eco5shWXBByJjLrAC8wyQcWxX7TS7M9dZAjKSNSAl6D0aHYTgDhCkyJiWFfMHFF4AAR0TurBZO7LMiPoU97D7CvI7lCT0%2FTSFF1c5%2B%2B5fD7vP0PKlDF%2B4o5bqp7%2Bs8wtP%2BtqwY6nQFJodwV1R2DKbSt%2BkrCRHKB8AsdRa2mw8r59BO7ZE3x7m%2FVl61yKoqq5F0G5VW1vr7rT3OHdrUP9aOQaLHtWpKpUby4H5LGAjSZzYkBEO6MunuQ79L6lZVBe23zE2NMxGdxkWCuuj5SNP12ewlslnC1aJBN38StdO520j%2Fs9ayIvtgsmZWkLC99Wv8Sb4xpAz2paN7a%2FTwFPqAnkZVD&X-Amz-Signature=d157d3439c22a5832038af7a63928b4dec62b4326742184f88323556ebcf2fe7&X-Amz-SignedHeaders=host&x-id=GetObject",
"name": "privacy policy",
"size": 186790
},
{
"id": "6df1ceb5-72e5-4e38-9eef-66ee085aec17",
"link": "https://smile-signable-document-development.s3.us-west-2.amazonaws.com/development/921/SINGLE_USE/fbedce72-58f7-45c6-9e47-240e278719a7-terms%20and%20conditions.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=ASIA4OAOFXPAHPEZQXW5%2F20231202%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20231202T190423Z&X-Amz-Expires=900&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEMv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIQDx6xxYPXeC6Nm1O6NkDRWNskY6jpWnTo0rhGsSq%2FhLpQIgP3rVKh1%2B0Mm8tceD%2BXXRPeyRCZHysxZNw6YFxhN0EXQqpwMINBADGgw4NTQ3MjgyMjc3NzYiDBIuWCw54%2BS8bXD4iiqEAygeRz2MdUibORe2HlZ7I53MftfqQdqtUZ6CCzSee%2F53ERKuFuQ59SfeEX6KwEpfDsgKxAJsSE%2B5DWdFz3F4KLXeaVb9Ri9EHl7%2BYfYFbFUe25eCk1r0%2FewDpEgDlYr7KSuV84oNCJDmHxxa%2BsMcG6PvfBJ26UNUk5MhHfYBaqhjLTHSlFODgu%2FwYalDEcEcyK5oiJfr3%2BUx8KcNlpQVx2ep%2BbNidaVX30K2lIGqkQ9BFTjYGGzXlJ2JuNoTQjNdobptZdL8lawO1MuXaBJLdFy3AMSbcB8Bp4v39N1HA5q5aVd3odt0JEBpJ0H9pf%2BBa%2BNsS5kaMXwO0w0xjc7SLDHSClMexzwf4vXqLHMW6oPbGvUMIwmqpkYVSkhPPBBDOpEO%2FezO1Eco5shWXBByJjLrAC8wyQcWxX7TS7M9dZAjKSNSAl6D0aHYTgDhCkyJiWFfMHFF4AAR0TurBZO7LMiPoU97D7CvI7lCT0%2FTSFF1c5%2B%2B5fD7vP0PKlDF%2B4o5bqp7%2Bs8wtP%2BtqwY6nQFJodwV1R2DKbSt%2BkrCRHKB8AsdRa2mw8r59BO7ZE3x7m%2FVl61yKoqq5F0G5VW1vr7rT3OHdrUP9aOQaLHtWpKpUby4H5LGAjSZzYkBEO6MunuQ79L6lZVBe23zE2NMxGdxkWCuuj5SNP12ewlslnC1aJBN38StdO520j%2Fs9ayIvtgsmZWkLC99Wv8Sb4xpAz2paN7a%2FTwFPqAnkZVD&X-Amz-Signature=889ccd4c0be2eb3fdc868b534c31c51c2c084542b44a89f37a4738203bff5d52&X-Amz-SignedHeaders=host&x-id=GetObject",
"name": "terms and conditions",
"size": 384244
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"error": "File not found for ID(s) 6df1ceb5-72e5-4e38-9eef-66ee085aec19"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"code": "2413",
"error": "\"ids\" does not contain 1 required value(s)"
}
57 changes: 57 additions & 0 deletions packages/embed/cypress/pages/e_signature.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!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>
function displayError(error) {
const errorDiv = document.createElement("div");
errorDiv.setAttribute("class", "validation-message");
errorDiv.textContent = error;
document.body.appendChild(errorDiv);
}

SmileIdentity({
token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXJ0bmVyX3BhcmFtcyI6eyJ1c2VyX2lkIjoid2ViLXRva2VuLXRlc3QtdXNlci0wMDEiLCJqb2JfaWQiOiJ3ZWItdG9rZW4tam9iLTEyMyIsImpvYl90eXBlIjo1fSwiY2FsbGJhY2tfdXJsIjoiaHR0cHM6Ly93ZWJob29rLnNpdGUvMWFhYTdhN2ItYWNjYi00MGFjLTg2NDMtZmQ4YTg3MDNlOWJlIiwiaWF0IjoxNjQ2OTQxNTQ5LCJleHAiOjE2NDg1ODg0ODN9.D83B4jSgQGJfSnQ5xALKea48okutLpbTcqojJTk4iGI",
product: "e_signature",
document_ids: ['07ef4595-aaed-4597-b6af-444986ae4565', '6df1ceb5-72e5-4e38-9eef-66ee085aec17'],
callback_url:
"https://webhook.site/1aaa7a7b-accb-40ac-8643-fd8a8703e9be",
environment: "development",
partner_details: {
name: "Test Org",
logo_url: "https://portal.smileidentity.com/favicon.ico",
partner_id: "212",
policy_url: "https://smileidentity.com/privacy-policy",
theme_color: "#000",
},
onSuccess: () => {},
onClose: () => {
displayError("User triggered this close action");
},
onError: (data) => {
displayError(JSON.stringify(data, null, 2));
},
});
</script>
</body>
</html>
58 changes: 58 additions & 0 deletions packages/embed/cypress/pages/e_signature_no_file.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!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>
function displayError(error) {
const errorDiv = document.createElement("div");
errorDiv.setAttribute("class", "validation-message");
errorDiv.textContent = error;
document.body.appendChild(errorDiv);
}

SmileIdentity({
token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXJ0bmVyX3BhcmFtcyI6eyJ1c2VyX2lkIjoid2ViLXRva2VuLXRlc3QtdXNlci0wMDEiLCJqb2JfaWQiOiJ3ZWItdG9rZW4tam9iLTEyMyIsImpvYl90eXBlIjo1fSwiY2FsbGJhY2tfdXJsIjoiaHR0cHM6Ly93ZWJob29rLnNpdGUvMWFhYTdhN2ItYWNjYi00MGFjLTg2NDMtZmQ4YTg3MDNlOWJlIiwiaWF0IjoxNjQ2OTQxNTQ5LCJleHAiOjE2NDg1ODg0ODN9.D83B4jSgQGJfSnQ5xALKea48okutLpbTcqojJTk4iGI",
product: "e_signature",
document_ids: ['07ef4595-aaed-4597-b6af-444986ae4565', '6df1ceb5-72e5-4e38-9eef-66ee085aec17'],
callback_url:
"https://webhook.site/1aaa7a7b-accb-40ac-8643-fd8a8703e9be",
environment: "development",
partner_details: {
name: "Test Org",
logo_url: "https://portal.smileidentity.com/favicon.ico",
partner_id: "212",
policy_url: "https://smileidentity.com/privacy-policy",
theme_color: "#000",
},
onSuccess: () => {},
onClose: () => {
displayError("User triggered this close action");
},
onError: (data) => {
console.log(data);
displayError(JSON.stringify(data, null, 2));
},
});
</script>
</body>
</html>
56 changes: 56 additions & 0 deletions packages/embed/cypress/pages/e_signature_no_ids.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!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>
function displayError(error) {
const errorDiv = document.createElement("div");
errorDiv.setAttribute("class", "validation-message");
errorDiv.textContent = error;
document.body.appendChild(errorDiv);
}

SmileIdentity({
token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXJ0bmVyX3BhcmFtcyI6eyJ1c2VyX2lkIjoid2ViLXRva2VuLXRlc3QtdXNlci0wMDEiLCJqb2JfaWQiOiJ3ZWItdG9rZW4tam9iLTEyMyIsImpvYl90eXBlIjo1fSwiY2FsbGJhY2tfdXJsIjoiaHR0cHM6Ly93ZWJob29rLnNpdGUvMWFhYTdhN2ItYWNjYi00MGFjLTg2NDMtZmQ4YTg3MDNlOWJlIiwiaWF0IjoxNjQ2OTQxNTQ5LCJleHAiOjE2NDg1ODg0ODN9.D83B4jSgQGJfSnQ5xALKea48okutLpbTcqojJTk4iGI",
product: "e_signature",
callback_url:
"https://webhook.site/1aaa7a7b-accb-40ac-8643-fd8a8703e9be",
environment: "sandbox",
partner_details: {
name: "Test Org",
logo_url: "https://portal.smileidentity.com/favicon.ico",
partner_id: "212",
policy_url: "https://smileidentity.com/privacy-policy",
theme_color: "#000",
},
onSuccess: () => {},
onClose: () => {
displayError("User triggered this close action");
},
onError: (data) => {
displayError(JSON.stringify(data, null, 2));
},
});
</script>
</body>
</html>
73 changes: 73 additions & 0 deletions packages/embed/cypress/tests/e-signature.cy.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
describe('eSignature', () => {
describe('with no document ids passed', () => {
beforeEach(() => {
cy.visit('/e_signature_no_ids');
});

it('should show an error message', () => {
cy.get("iframe").should("not.exist");
cy.get(".validation-message").should("be.visible");
cy.get(".validation-message").should("contain", "`document_ids` field is required for `e_signature` ");
});
});

describe('with no file found', () => {
beforeEach(() => {
cy.intercept(
{
method: "OPTIONS",
url: "*v1/documents**",
},
{
statusCode: 204,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'OPTIONS,GET,POST',
'Access-Control-Allow-Headers': '*',
},
},
);

cy.intercept(
{
method: "GET",
url: "*v1/documents**",
},
{
statusCode: 400,
fixture: 'e_signature_documents_no_file.json',
}
);

cy.visit('/e_signature_no_file');
});

it('should show an error message', () => {
cy.get("iframe").should("not.exist");
cy.get(".validation-message").should("be.visible");
cy.get(".validation-message").should("contain", "File not found");
});
});

describe.only('with both document ids valid', () => {
beforeEach(() => {
cy.intercept(
{
method: "GET",
url: "*v1/documents**",
},
{
statusCode: 200,
fixture: 'e_signature_documents.json',
}
);
cy.visit('/e_signature');
});

it('should proceed to upload a signature', () => {
cy.get("iframe").should("exist");

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

0 comments on commit 89a6c00

Please sign in to comment.