UNPKG

boldsign

Version:

NodeJS client for boldsign

954 lines 91.5 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const documentApi_1 = require("../../api/documentApi"); const brandingApi_1 = require("../../api/brandingApi"); const model_1 = require("../../model"); const fs = __importStar(require("fs")); const config_1 = __importDefault(require("../config")); function imageToBase64(imagePath) { const imageBuffer = fs.readFileSync(imagePath); const imageType = imagePath.substring(imagePath.lastIndexOf('.') + 1); return `data:image/${imageType};base64,${imageBuffer.toString('base64')}`; } describe('Document API Test Suite', () => { let brandingApi; let documentApi; let brandId; let createdDocumentId; let sendDocumentOnBehalfId; let senderEmail; const generateRandomEmail = () => { const randomNum = Math.floor(1000 + Math.random() * 9000); return `sdktesting${randomNum}@syncfusion.com`; }; beforeAll(() => { createdDocumentId = null; sendDocumentOnBehalfId = null; senderEmail = null; const apiKey = config_1.default.apiKey; const baseUrl = config_1.default.baseUrl; if (!apiKey || !baseUrl) { throw new Error("Environment variables 'API_KEY' or 'HOST_URL' are not set."); } documentApi = new documentApi_1.DocumentApi(baseUrl); documentApi.setApiKey(apiKey); brandingApi = new brandingApi_1.BrandingApi(baseUrl); brandingApi.setApiKey(apiKey); }); test('Test1: should fetch sender email details', () => __awaiter(void 0, void 0, void 0, function* () { var _a, _b, _c; try { const page = 1; const pageSize = 10; const listDocumentsResponse = yield documentApi.listDocuments(page, undefined, undefined, undefined, undefined, pageSize, undefined, undefined, undefined, undefined, undefined, undefined, undefined); senderEmail = (_c = (_b = (_a = listDocumentsResponse === null || listDocumentsResponse === void 0 ? void 0 : listDocumentsResponse.result) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.senderDetail) === null || _c === void 0 ? void 0 : _c.emailAddress; console.log("Sender email fetched:", senderEmail !== null && senderEmail !== void 0 ? senderEmail : 'Not available'); expect(listDocumentsResponse.result).toBeDefined(); } catch (error) { console.error("Error occurred while fetching sender details:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test2: should create a brand successfully with audit trail', () => __awaiter(void 0, void 0, void 0, function* () { const brandName = "NodeSDK"; const brandLogo = fs.createReadStream("tests/documents/logo.jpg"); const backgroundColor = "Blue"; const buttonColor = "Black"; const buttonTextColor = "White"; const emailDisplayName = "{SenderName} from Syncfusion"; const auditTrail = "true"; const disclaimerTitle = "Important Disclaimer"; try { const createBrandApiResponse = yield brandingApi.createBrand(brandName, brandLogo, backgroundColor, buttonColor, buttonTextColor, emailDisplayName, auditTrail, disclaimerTitle); console.log("Brand created successfully:", createBrandApiResponse.brandId); brandId = createBrandApiResponse.brandId; expect(createBrandApiResponse).toBeDefined(); } catch (error) { console.log("Error occurred while creating the brand:", error); expect(error).toBeUndefined(); } }), 20000); test('Test3: should send a document for signing successfully with existing brand ID and one signer', () => __awaiter(void 0, void 0, void 0, function* () { try { const signer1 = new model_1.DocumentSigner(); signer1.name = 'Test Signer'; signer1.emailAddress = 'mohammedmushraf.abuthakir+6@syncfusion.com'; signer1.signerOrder = 1; signer1.signerType = model_1.DocumentSigner.SignerTypeEnum.Signer; signer1.authenticationType = model_1.DocumentSigner.AuthenticationTypeEnum.AccessCode; signer1.authenticationCode = '123456'; signer1.authenticationSettings = { authenticationFrequency: model_1.AuthenticationSettings.AuthenticationFrequencyEnum.EveryAccess }; const formField1 = new model_1.FormField(); formField1.name = 'Sign'; formField1.fieldType = model_1.FormField.FieldTypeEnum.Signature; formField1.font = model_1.FormField.FontEnum.Helvetica; formField1.pageNumber = 1; formField1.isRequired = true; formField1.bounds = new model_1.Rectangle(); signer1.formFields = [formField1]; signer1.privateMessage = 'This is a private message for signer'; const sendDocumentRequest = new model_1.SendForSign(); sendDocumentRequest.title = 'Document SDK API'; sendDocumentRequest.files = [fs.createReadStream('tests/documents/agreement.pdf')]; sendDocumentRequest.enablePrintAndSign = true; sendDocumentRequest.signers = [signer1]; sendDocumentRequest.brandId = brandId; sendDocumentRequest.message = 'Please sign this document'; const sendDocumentResponse = yield documentApi.sendDocument(sendDocumentRequest); expect(sendDocumentResponse.documentId).toBeDefined(); const createdDocumentId = sendDocumentResponse.documentId; expect(sendDocumentResponse.documentId).toBeDefined(); } catch (error) { console.error('Error occurred while sending document for signing:', error); expect(error).toBeUndefined(); } }), 20000); test('Test4: should send a document for signing successfully', () => __awaiter(void 0, void 0, void 0, function* () { try { const signer1 = new model_1.DocumentSigner(); signer1.name = 'Test Signer'; signer1.emailAddress = 'mohammedmushraf.abuthakir+6@syncfusion.com'; signer1.signerOrder = 1; signer1.signerType = model_1.DocumentSigner.SignerTypeEnum.Signer; signer1.authenticationType = model_1.DocumentSigner.AuthenticationTypeEnum.AccessCode; signer1.authenticationCode = '123456'; signer1.authenticationSettings = { authenticationFrequency: model_1.AuthenticationSettings.AuthenticationFrequencyEnum.OncePerDocument }; const formField1 = new model_1.FormField(); formField1.name = 'Sign'; formField1.fieldType = model_1.FormField.FieldTypeEnum.Signature; formField1.font = model_1.FormField.FontEnum.Helvetica; formField1.pageNumber = 1; formField1.isRequired = true; formField1.bounds = new model_1.Rectangle(); signer1.formFields = [formField1]; signer1.privateMessage = 'This is private message for signer'; const signer2 = new model_1.DocumentSigner(); signer2.name = 'Test Reviewer'; signer2.emailAddress = 'mohammedmushraf.abuthakir+5@syncfusion.com'; signer2.signerOrder = 2; signer2.signerType = model_1.DocumentSigner.SignerTypeEnum.Reviewer; signer2.authenticationType = model_1.DocumentSigner.AuthenticationTypeEnum.EmailOtp; signer2.privateMessage = 'This is private message for Reviewer'; const sendDocumentRequest = new model_1.SendForSign(); sendDocumentRequest.title = 'Document SDK API'; sendDocumentRequest.files = [ fs.createReadStream('tests/documents/agreement.pdf'), ]; sendDocumentRequest.enablePrintAndSign = true; sendDocumentRequest.signers = [signer1, signer2]; const sendDocumentResponse = yield documentApi.sendDocument(sendDocumentRequest); expect(sendDocumentResponse.documentId).toBeDefined(); createdDocumentId = sendDocumentResponse.documentId; console.log('Created Document ID:', createdDocumentId); } catch (error) { console.error('Error occurred while sending document for signing:', error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test5: should send a document for signing successfully with inperson signer', () => __awaiter(void 0, void 0, void 0, function* () { try { console.log("Sender email fetched:", senderEmail); const signer1 = new model_1.DocumentSigner(); signer1.name = 'Test Signer'; signer1.emailAddress = 'mohammedmushraf.abuthakir+6@syncfusion.com'; signer1.signerOrder = 1; signer1.signerType = model_1.DocumentSigner.SignerTypeEnum.Signer; signer1.authenticationType = model_1.DocumentSigner.AuthenticationTypeEnum.AccessCode; signer1.authenticationCode = '123456'; signer1.authenticationSettings = { authenticationFrequency: model_1.AuthenticationSettings.AuthenticationFrequencyEnum.UntilSignCompleted }; const formField1 = new model_1.FormField(); formField1.name = 'Sign'; formField1.fieldType = model_1.FormField.FieldTypeEnum.Signature; formField1.font = model_1.FormField.FontEnum.Helvetica; formField1.pageNumber = 1; formField1.isRequired = true; formField1.bounds = new model_1.Rectangle(); signer1.formFields = [formField1]; signer1.privateMessage = 'This is private message for signer'; signer1.recipientNotificationSettings = { signatureRequest: true, declined: true, revoked: true, signed: true, completed: true, expired: true, reassigned: true, deleted: true, reminders: true, editRecipient: true }; const signer2 = new model_1.DocumentSigner(); signer2.name = 'Test Reviewer'; signer2.emailAddress = 'mohammedmushraf.abuthakir+5@syncfusion.com'; signer2.signerOrder = 2; signer2.signerType = model_1.DocumentSigner.SignerTypeEnum.Reviewer; signer2.authenticationType = model_1.DocumentSigner.AuthenticationTypeEnum.EmailOtp; signer2.authenticationSettings = { authenticationFrequency: model_1.AuthenticationSettings.AuthenticationFrequencyEnum.None }; signer2.privateMessage = 'This is private message for Reviewer'; signer2.phoneNumber = { countryCode: '+91', number: '6381261236' }; signer2.deliveryMode = model_1.DocumentSigner.DeliveryModeEnum.EmailAndSms; const signer3 = new model_1.DocumentSigner(); signer3.name = 'Test In-Person Signer'; signer3.emailAddress = 'mohammedmushraf.abuthakir+4@syncfusion.com'; signer3.signerOrder = 3; signer3.signerType = model_1.DocumentSigner.SignerTypeEnum.InPersonSigner; signer3.hostEmail = senderEmail; signer3.authenticationType = model_1.DocumentSigner.AuthenticationTypeEnum.EmailOtp; const formField2 = new model_1.FormField(); formField2.name = 'Sign'; formField2.fieldType = model_1.FormField.FieldTypeEnum.Signature; formField2.font = model_1.FormField.FontEnum.Helvetica; formField2.pageNumber = 1; formField2.isRequired = true; formField2.bounds = new model_1.Rectangle(); signer3.formFields = [formField2]; const sendDocumentRequest = new model_1.SendForSign(); sendDocumentRequest.title = 'Document SDK API'; sendDocumentRequest.files = [fs.createReadStream('tests/documents/agreement.pdf')]; sendDocumentRequest.enablePrintAndSign = true; sendDocumentRequest.hideDocumentId = true; sendDocumentRequest.enableReassign = false; sendDocumentRequest.signers = [signer1, signer2, signer3]; const sendDocumentResponse = yield documentApi.sendDocument(sendDocumentRequest); expect(sendDocumentResponse.documentId).toBeDefined(); const createdDocumentId = sendDocumentResponse.documentId; console.log('Created Document ID:', createdDocumentId); } catch (error) { console.error('Error occurred while sending document for signing:', error); expect(error).toBeUndefined(); } }), 20000); test('Test6: should send a document with multiple CCs successfully', () => __awaiter(void 0, void 0, void 0, function* () { try { const files = [ fs.createReadStream('tests/documents/agreement.pdf'), ]; const formFields = []; const signatureField = new model_1.FormField(); signatureField.pageNumber = 1; signatureField.bounds = new model_1.Rectangle(); signatureField.bounds.x = 100; signatureField.bounds.y = 100; signatureField.bounds.width = 100; signatureField.bounds.height = 50; formFields.push(signatureField); const signers = []; const signer1 = new model_1.DocumentSigner(); signer1.name = 'Mohammed'; signer1.emailAddress = 'mohammedmushraf.abuthakir+88@syncfusion.com'; signer1.signerRole = 'SIGNER'; signer1.formFields = formFields; signers.push(signer1); const signer2 = new model_1.DocumentSigner(); signer2.name = 'Mohammed'; signer2.emailAddress = 'mohammedmushraf.abuthakir+80@syncfusion.com'; signer2.signerRole = 'SIGNER'; signer2.formFields = formFields; signers.push(signer2); const ccList = []; for (let i = 1; i <= 20; i++) { const cc = new model_1.DocumentCC(); cc.emailAddress = `mohammedmushraf.abuthakir+${i + 2}@syncfusion.com`; ccList.push(cc); } const sendDocumentRequest = new model_1.SendForSign(); sendDocumentRequest.title = 'Agreement Document'; sendDocumentRequest.files = files; sendDocumentRequest.signers = signers; sendDocumentRequest.cc = ccList; const sendDocumentResponse = yield documentApi.sendDocument(sendDocumentRequest); expect(sendDocumentResponse.documentId).toBeDefined(); const hasSyncfusionCC = ccList.some(cc => cc.emailAddress.includes('@syncfusion.com')); const createdDocumentId = sendDocumentResponse.documentId; console.log('Document sent successfully with document ID:', createdDocumentId); } catch (error) { console.error('Error occurred while sending document for signing:', error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test7: should send a document with multiple files for signing successfully', () => __awaiter(void 0, void 0, void 0, function* () { try { const files = [ fs.createReadStream('tests/documents/agreement.pdf'), fs.createReadStream('tests/documents/agreement.pdf'), fs.createReadStream('tests/documents/agreement.pdf'), fs.createReadStream('tests/documents/agreement.pdf'), ]; const formFields = []; const signatureField = new model_1.FormField(); signatureField.pageNumber = 1; signatureField.bounds = new model_1.Rectangle(); signatureField.bounds.x = 100; signatureField.bounds.y = 100; signatureField.bounds.width = 100; signatureField.bounds.height = 50; formFields.push(signatureField); const signers = []; const signer1 = new model_1.DocumentSigner(); signer1.name = 'Signer1'; signer1.emailAddress = 'mohammedmushraf.abuthakir+5@syncfusion.com'; signer1.formFields = formFields; signers.push(signer1); const signer2 = new model_1.DocumentSigner(); signer2.name = 'Signer2'; signer2.emailAddress = 'mohammedmushraf.abuthakir+6@syncfusion.com'; signer2.formFields = formFields; signers.push(signer2); const sendDocumentRequest = new model_1.SendForSign(); sendDocumentRequest.title = 'Agreement with Multiple Files'; sendDocumentRequest.files = files; sendDocumentRequest.signers = signers; const sendDocumentResponse = yield documentApi.sendDocument(sendDocumentRequest); expect(sendDocumentResponse.documentId).toBeDefined(); const createdDocumentId = sendDocumentResponse.documentId; console.log('Created Document ID:', createdDocumentId); } catch (error) { console.error('Error occurred while sending document for signing:', error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test8: should send a document with many signers successfully', () => __awaiter(void 0, void 0, void 0, function* () { try { const files = [ fs.createReadStream('tests/documents/agreement.pdf'), ]; const formFields = []; const signatureField = new model_1.FormField(); signatureField.pageNumber = 1; signatureField.bounds = new model_1.Rectangle(); signatureField.bounds.x = 100; signatureField.bounds.y = 100; signatureField.bounds.width = 100; signatureField.bounds.height = 50; formFields.push(signatureField); const signers = []; for (let i = 0; i < 15; i++) { const signer = new model_1.DocumentSigner(); signer.name = `Signer${i}`; signer.emailAddress = `mohammedmushraf.abuthakir+${i}@syncfusion.com`; signer.formFields = formFields; signers.push(signer); } const sendDocumentRequest = new model_1.SendForSign(); sendDocumentRequest.title = 'Agreement'; sendDocumentRequest.files = files; sendDocumentRequest.signers = signers; const sendDocumentResponse = yield documentApi.sendDocument(sendDocumentRequest); expect(sendDocumentResponse.documentId).toBeDefined(); console.log('Created Document ID:', sendDocumentResponse.documentId); } catch (error) { console.error('Error occurred while sending document for signing:', error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test9: should fail to create document with no signers', () => __awaiter(void 0, void 0, void 0, function* () { try { const sendForSign = { title: 'Agreement', files: [ fs.createReadStream('tests/documents/agreement.pdf'), ], signers: [], }; const response = yield documentApi.sendDocument(sendForSign); console.error('Expected error for missing signers, but document was created:', response); } catch (error) { console.error('Error occurred while creating document:', error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test10: should fail to send a document for signing with an empty email address', () => __awaiter(void 0, void 0, void 0, function* () { try { const signer1 = new model_1.DocumentSigner(); signer1.name = 'Test Signer'; signer1.emailAddress = ''; signer1.signerOrder = 1; signer1.signerType = model_1.DocumentSigner.SignerTypeEnum.Signer; signer1.authenticationType = model_1.DocumentSigner.AuthenticationTypeEnum.AccessCode; signer1.authenticationCode = '123456'; const formField1 = new model_1.FormField(); formField1.name = 'Sign'; formField1.fieldType = model_1.FormField.FieldTypeEnum.Signature; formField1.font = model_1.FormField.FontEnum.Helvetica; formField1.pageNumber = 1; formField1.isRequired = true; formField1.bounds = new model_1.Rectangle(); signer1.formFields = [formField1]; signer1.privateMessage = 'This is private message for signer'; const sendDocumentRequest = new model_1.SendForSign(); sendDocumentRequest.title = 'Document SDK API'; sendDocumentRequest.files = [ fs.createReadStream('tests/documents/agreement.pdf'), ]; sendDocumentRequest.enablePrintAndSign = true; sendDocumentRequest.signers = [signer1]; const sendDocumentResponse = yield documentApi.sendDocument(sendDocumentRequest); console.log('Created Document ID:', createdDocumentId); } catch (error) { console.error('Error occurred while sending document for signing:', error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test11: should fail to send a document for signing with an invalid email address', () => __awaiter(void 0, void 0, void 0, function* () { try { const signer1 = new model_1.DocumentSigner(); signer1.name = 'Signer'; signer1.emailAddress = 'invalid-email.com'; signer1.signerType = model_1.DocumentSigner.SignerTypeEnum.Signer; const signer2 = new model_1.DocumentSigner(); signer2.name = 'Signer1'; signer2.emailAddress = 'mohammedmushraf.abuthakir+6@syncfusion.com'; signer2.signerOrder = 2; signer2.signerType = model_1.DocumentSigner.SignerTypeEnum.Signer; const formField1 = new model_1.FormField(); formField1.name = 'Sign'; formField1.fieldType = model_1.FormField.FieldTypeEnum.Signature; formField1.font = model_1.FormField.FontEnum.Helvetica; formField1.pageNumber = 1; formField1.isRequired = true; formField1.bounds = new model_1.Rectangle(); signer1.formFields = [formField1]; signer2.formFields = [formField1]; const sendDocumentRequest = new model_1.SendForSign(); sendDocumentRequest.title = 'Agreement'; sendDocumentRequest.files = [ fs.createReadStream('tests/documents/agreement.pdf'), ]; sendDocumentRequest.enablePrintAndSign = true; sendDocumentRequest.signers = [signer1, signer2]; const sendDocumentResponse = yield documentApi.sendDocument(sendDocumentRequest); expect(sendDocumentResponse).toBeUndefined(); } catch (error) { console.error('Error occurred while sending document for signing:', error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test12: should retrieve embedded sign link successfully', () => __awaiter(void 0, void 0, void 0, function* () { try { const documentId = createdDocumentId; const signerEmail = "mohammedmushraf.abuthakir+6@syncfusion.com"; const countryCode = "+91"; const phoneNumber = ""; const signLinkValidTill = new Date("2025-03-03T00:00:00+00:00"); const redirectUrl = "https://www.syncfusion.com/"; const response = yield documentApi.getEmbeddedSignLink(documentId, signerEmail, countryCode, phoneNumber, signLinkValidTill, redirectUrl); expect(response.signLink).toBeDefined(); } catch (error) { console.error('Error occurred while getting the embedded signing link:', error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test13: should fail to retrieve embedded sign link with invalid document id', () => __awaiter(void 0, void 0, void 0, function* () { try { const signerEmail = "divya.boopathy+30@syncfusion.com"; const countryCode = "+91"; const phoneNumber = ""; const signLinkValidTill = new Date("2023-01-01T00:00:00+00:00"); const redirectUrl = "https://www.syncfusion.com/"; const invalidDocumentId = "invalid-document-id"; const response = yield documentApi.getEmbeddedSignLink(invalidDocumentId, signerEmail, countryCode, phoneNumber, signLinkValidTill, redirectUrl); console.error('Test failed: Response should not have succeeded with invalid document ID'); expect(response).toBeUndefined(); } catch (error) { console.error('Error occurred while getting the embedded signing link:', error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test14: should fail to retrieve embedded sign link with invalid email id', () => __awaiter(void 0, void 0, void 0, function* () { try { const documentId = createdDocumentId; const invalidSignerEmail = "invalid-emailid"; const countryCode = "+91"; const phoneNumber = ""; const signLinkValidTill = new Date("2025-03-03T00:00:00+00:00"); const redirectUrl = "https://www.syncfusion.com/"; const response = yield documentApi.getEmbeddedSignLink(documentId, invalidSignerEmail, countryCode, phoneNumber, signLinkValidTill, redirectUrl); console.error('Test failed: Response should not have succeeded with invalid email ID'); } catch (error) { console.error('Error occurred while getting the embedded signing link:', error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test15: should throw an error for list document invalid page number and page size', () => __awaiter(void 0, void 0, void 0, function* () { const page = -1; const invalidPageSize = 250; try { yield documentApi.listDocuments(page, undefined, undefined, undefined, undefined, invalidPageSize, undefined, undefined, undefined, undefined, undefined, undefined, undefined); throw new Error("Expected an ApiException to be thrown due to invalid page number or page size."); } catch (error) { console.error("Error occurred while calling the API:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test16:should fetch behalf documents successfully', () => __awaiter(void 0, void 0, void 0, function* () { const page = 1; try { const behalfDocumentResponse = yield documentApi.behalfDocuments(page); console.log("Behalf Documents fetched successfully:", behalfDocumentResponse); expect(behalfDocumentResponse.result).toBeDefined; } catch (error) { console.error("Error occurred while calling the API:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test17:should fail to fetch behalf documents due to invalid page number', () => __awaiter(void 0, void 0, void 0, function* () { const invalidPage = -1; try { const behalfDocumentResponse = yield documentApi.behalfDocuments(invalidPage); console.error("Expected an error, but the response was:", behalfDocumentResponse); throw new Error("Expected an error, but got a response."); } catch (error) { console.log("Error occurred while calling the API:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test18:should fetch team documents successfully', () => __awaiter(void 0, void 0, void 0, function* () { const page = 1; try { const teamDocumentResponse = yield documentApi.teamDocuments(page); console.log("Team Documents fetched successfully:", teamDocumentResponse); expect(teamDocumentResponse.result).toBeDefined; } catch (error) { console.error("Error occurred while fetching team documents:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test19:should fail to fetch team documents with invalid page number', () => __awaiter(void 0, void 0, void 0, function* () { const invalidPage = -1; try { const teamDocumentResponse = yield documentApi.teamDocuments(invalidPage); throw new Error("Expected API call to fail but it succeeded"); } catch (error) { console.error("Error occurred while fetching team documents:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test20:should remove authentication successfully from the document', () => __awaiter(void 0, void 0, void 0, function* () { const documentId = createdDocumentId; const emailId = "mohammedmushraf.abuthakir+5@syncfusion.com"; const removeAuthentication = new model_1.RemoveAuthentication(); removeAuthentication.emailId = emailId; try { const response = yield documentApi.removeAuthentication(documentId, removeAuthentication); console.log("Authentication removed successfully:", response); } catch (error) { console.error("Error occurred while removing authentication:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test21:should fail to remove authentication from the document with invalid data', () => __awaiter(void 0, void 0, void 0, function* () { const documentId = "invalid-document-id"; const emailId = "mohammedmushraf.abuthakir+5@syncfusion.com"; const removeAuthentication = new model_1.RemoveAuthentication(); removeAuthentication.emailId = emailId; try { const response = yield documentApi.removeAuthentication(documentId, removeAuthentication); console.error("Authentication was unexpectedly removed:", response); } catch (error) { console.error("Expected error occurred while removing authentication:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test22:should add authentication to document successfully', () => __awaiter(void 0, void 0, void 0, function* () { const documentId = createdDocumentId; const accessCodeDetail = new model_1.AccessCodeDetail(); accessCodeDetail.authenticationType = model_1.AccessCodeDetail.AuthenticationTypeEnum.EmailOtp; accessCodeDetail.authenticationSettings = { authenticationFrequency: model_1.AuthenticationSettings.AuthenticationFrequencyEnum.EveryAccess }; accessCodeDetail.emailId = "mohammedmushraf.abuthakir+5@syncfusion.com"; try { const response = yield documentApi.addAuthentication(documentId, accessCodeDetail); console.log("Authentication added successfully:", response); } catch (error) { console.error("Error occurred while adding authentication:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test23:should fail to add authentication to document due to invalid documentId', () => __awaiter(void 0, void 0, void 0, function* () { const invalidDocumentId = "invalid-document-id"; const accessCodeDetail = new model_1.AccessCodeDetail(); accessCodeDetail.authenticationType = model_1.AccessCodeDetail.AuthenticationTypeEnum.EmailOtp; accessCodeDetail.emailId = "mohammedmushraf.abuthakir+5@syncfusion.com"; try { const response = yield documentApi.addAuthentication(invalidDocumentId, accessCodeDetail); } catch (error) { console.error("Expected error occurred while adding authentication:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test24:should fetch document properties', () => __awaiter(void 0, void 0, void 0, function* () { try { const response = yield documentApi.getProperties(createdDocumentId); expect(response.documentId).toBeDefined(); } catch (error) { console.error("Error occurred while fetching document properties:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test25:should fail to fetch document properties with invalid document ID', () => __awaiter(void 0, void 0, void 0, function* () { const invalidDocumentId = "invalid-document-id"; try { const response = yield documentApi.getProperties(invalidDocumentId); } catch (error) { console.error("Expected error occurred while fetching document properties:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test26:should fail to fetch document properties with invalid document ID', () => __awaiter(void 0, void 0, void 0, function* () { const invalidDocumentId = ""; try { const response = yield documentApi.getProperties(invalidDocumentId); } catch (error) { console.error("Expected error occurred while fetching document properties:", error); expect(error).toBeDefined(); expect(error.response.status).toBe(400); expect(error.response.statusText).toBe('Bad Request'); } }), 20000); test('Test27:should extend document expiry successfully', () => __awaiter(void 0, void 0, void 0, function* () { try { const currentDate = new Date(); const newExpiryDate = new Date(currentDate.setMonth(currentDate.getMonth() + 3)); const newExpiryDateStr = newExpiryDate.toISOString().split('T')[0]; const extendExpiry = new model_1.ExtendExpiry(); extendExpiry.newExpiryValue = newExpiryDateStr; const response = yield documentApi.extendExpiry(createdDocumentId, extendExpiry); } catch (error) { console.error("Error occurred while calling the API:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test28:should fail to extend document expiry due to invalid document ID', () => __awaiter(void 0, void 0, void 0, function* () { try { const currentDate = new Date(); const newExpiryDate = new Date(currentDate.setMonth(currentDate.getMonth() + 3)); const newExpiryDateStr = newExpiryDate.toISOString().split('T')[0]; const extendExpiry = new model_1.ExtendExpiry(); extendExpiry.newExpiryValue = newExpiryDateStr; const invalidDocumentId = "invalid-document-id"; yield documentApi.extendExpiry(invalidDocumentId, extendExpiry); } catch (error) { console.log("Error occurred as expected:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test29: should send a reminder successfully with valid document ID', () => __awaiter(void 0, void 0, void 0, function* () { const reminderMessage = new model_1.ReminderMessage(); reminderMessage.message = "Please sign this soon"; const documentId = createdDocumentId; const receiverEmails = ["mohammedmushraf.abuthakir+5@syncfusion.com"]; try { const response = yield documentApi.remindDocument(documentId, receiverEmails, reminderMessage); console.log("Reminder sent successfully:", response); } catch (error) { console.error("Error occurred while sending the reminder:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test30: should throw an error for invalid document ID while sending reminder', () => __awaiter(void 0, void 0, void 0, function* () { const reminderMessage = new model_1.ReminderMessage(); reminderMessage.message = "Please sign this soon"; const documentId = "invalid-document-id"; const receiverEmails = ["mohammedmushraf.abuthakir+5@syncfusion.com"]; try { yield documentApi.remindDocument(documentId, receiverEmails, reminderMessage); } catch (error) { console.error("Error occurred while sending the reminder:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test31: should download document successfully', () => __awaiter(void 0, void 0, void 0, function* () { try { const documentId = createdDocumentId; const onBehalfOf = "mohammedmushraf.abuthakir+6@syncfusion.com"; const response = yield documentApi.downloadDocument(documentId, onBehalfOf); console.log("Document downloaded successfully!"); } catch (error) { console.error("Error occurred while downloading the document:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test32:should fail to download document with invalid document ID', () => __awaiter(void 0, void 0, void 0, function* () { const invalidDocumentId = "invalid-document-id"; const onBehalfOf = "mohammedmushraf.abuthakir+6@syncfusion.com"; try { const response = yield documentApi.downloadDocument(invalidDocumentId, onBehalfOf); } catch (error) { console.error("Error occurred while downloading the document:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test33:should change document access code successfully', () => __awaiter(void 0, void 0, void 0, function* () { const accessCodeDetails = new model_1.AccessCodeDetails(); accessCodeDetails.accessCode = "12345"; const documentId = createdDocumentId; const email = "mohammedmushraf.abuthakir+6@syncfusion.com"; try { const response = yield documentApi.changeAccessCode(documentId, accessCodeDetails, email); console.log("Access code changed successfully:", response); } catch (error) { console.error("Error occurred while calling the API:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test34:should not change document access code due to invalid data', () => __awaiter(void 0, void 0, void 0, function* () { const accessCodeDetails = new model_1.AccessCodeDetails(); accessCodeDetails.accessCode = "123457"; const documentId = "invalidDocumentId"; const email = "mohammedmushraf.abuthakir+6@syncfusion.com"; try { const response = yield documentApi.changeAccessCode(documentId, accessCodeDetails, email); } catch (error) { console.error("Expected error occurred while calling the API:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test35:should successfully add tags to the document', () => __awaiter(void 0, void 0, void 0, function* () { const documentTags = new model_1.DocumentTags(); documentTags.documentId = createdDocumentId; documentTags.tags = ["test", "api"]; try { const response = yield documentApi.addTag(documentTags); console.log("Tags added successfully!", response); } catch (error) { console.error("Error occurred while calling the API:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test36:should fail to add tags to the document due to invalid data', () => __awaiter(void 0, void 0, void 0, function* () { const documentTags = new model_1.DocumentTags(); documentTags.documentId = 'invalidDocumentId'; documentTags.tags = ["test", "api"]; try { const response = yield documentApi.addTag(documentTags); } catch (error) { console.log("Error occurred as expected while calling the API:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test37: should fail to add tags with an empty tag array', () => __awaiter(void 0, void 0, void 0, function* () { const documentTags = new model_1.DocumentTags(); documentTags.documentId = createdDocumentId; documentTags.tags = ["", ""]; try { const response = yield documentApi.addTag(documentTags); } catch (error) { console.error("Error occurred while calling the API:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test38:should successfully delete tags from the document', function () { return __awaiter(this, void 0, void 0, function* () { const documentTags = new model_1.DocumentTags(); documentTags.documentId = createdDocumentId; documentTags.tags = ["test", "api"]; try { const response = yield documentApi.deleteTag(documentTags); console.log("Tags deleted successfully!"); } catch (error) { console.error("Error occurred while calling the API:", error.message); expect(error.message).toBeUndefined(); } }); }, 20000); test('Test39:should fail to delete tags from the document due to invalid document ID', function () { return __awaiter(this, void 0, void 0, function* () { const documentTags = new model_1.DocumentTags(); documentTags.documentId = "invalid-document-id"; documentTags.tags = ["test", "api"]; try { const response = yield documentApi.deleteTag(documentTags); } catch (error) { console.log("Error occurred as expected:", error.message); expect(error.message).toBeDefined(); } }); }, 20000); test('Test40: should fail to delete tags with an empty tag array', function () { return __awaiter(this, void 0, void 0, function* () { const documentTags = new model_1.DocumentTags(); documentTags.documentId = createdDocumentId; documentTags.tags = ["", ""]; try { const response = yield documentApi.deleteTag(documentTags); } catch (error) { console.error("Error occurred while calling the API:", error.message); expect(error.message).toBeDefined(); } }); }, 20000); test('Test41: should change the recipient successfully', () => __awaiter(void 0, void 0, void 0, function* () { try { const oldSignerEmail = "mohammedmushraf.abuthakir+6@syncfusion.com"; const reason = "Wrongly sent"; const newSignerName = "Test Signer"; const newSignerEmail = "mohammedmushraf.abuthakir+15@syncfusion.com"; const changeRecipient = { oldSignerEmail: oldSignerEmail, reason: reason, newSignerName: newSignerName, newSignerEmail: newSignerEmail }; const response = yield documentApi.changeRecipient(createdDocumentId, changeRecipient); console.log("Recipient change succeeded."); } catch (error) { console.error('Error occurred while changing the recipient:', error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test42: should fail to change the recipient with invalid document ID', () => __awaiter(void 0, void 0, void 0, function* () { try { const oldSignerEmail = "mohammedmushraf.abuthakir+6@syncfusion.com"; const reason = "Wrongly sent"; const newSignerName = "Test Signer"; const newSignerEmail = "mohammedmushraf.abuthakir+15@syncfusion.com"; const changeRecipient = { oldSignerEmail: oldSignerEmail, reason: reason, newSignerName: newSignerName, newSignerEmail: newSignerEmail }; const invalidDocumentId = "invalid-document-id"; const response = yield documentApi.changeRecipient(invalidDocumentId, changeRecipient); } catch (error) { console.error('Error occurred while changing the recipient:', error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test43:should revoke document successfully', () => __awaiter(void 0, void 0, void 0, function* () { const revokeDocumentRequest = new model_1.RevokeDocument(); revokeDocumentRequest.message = "This is document revoke message"; const documentId = createdDocumentId; try { const response = yield documentApi.revokeDocument(documentId, revokeDocumentRequest); console.log("Document revoked successfully:", response); } catch (error) { console.error("Error occurred while calling the API:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test44:should fail to revoke document due to invalid document ID', () => __awaiter(void 0, void 0, void 0, function* () { const revokeDocumentRequest = new model_1.RevokeDocument(); revokeDocumentRequest.message = "This is document revoke message"; const invalidDocumentId = 'invalidDocumentId'; try { const response = yield documentApi.revokeDocument(invalidDocumentId, revokeDocumentRequest); } catch (error) { console.log("Error occurred as expected while calling the API:", error.message); expect(error.message).toBeDefined(); } }), 20000); test('Test45:should delete document successfully', () => __awaiter(void 0, void 0, void 0, function* () { const validDocumentId = createdDocumentId; const deletePermanently = false; try { const response = yield documentApi.deleteDocument(validDocumentId, deletePermanently); console.log("Document deleted successfully:", response); } catch (error) { console.error("Error occurred while calling the API:", error.message); expect(error.message).toBeUndefined(); } }), 20000); test('Test46:should fail to delete