Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 172 additions & 0 deletions tests/functional/cypress/e2e/template.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands'

describe("To Validate & get list of template via API call", function () {

// Define a variable for the environment
const environment = Cypress.env("CYPRESS_ENV");

// Import the appropriate configuration based on the environment
let appConfig;
if (environment === 'dev') {
appConfig = require('../appConfig/config.dev.ts').appConfig;
} else if (environment === 'production') {
appConfig = require('../appConfig/config.production.ts').appConfig;
}

//Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/template
const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4`;
const claGroupId=appConfig.claGroupId; //project name: easyAutom foundation
let templateId="";

let bearerToken: string = null;
before(() => {
if(bearerToken==null){
getTokenKey(bearerToken);
cy.window().then((win) => {
bearerToken = win.localStorage.getItem('bearerToken');
});
}
});

it("Endpoint to return the list of available templates", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}/template`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
let list=response.body;
templateId=list[0].ID;
expect(list[0].Name).to.eql('Apache Style');
expect(list[1].Name).to.eql('ASWF 2020 v2.1');
//To validate schema of response
validateApiResponse("templates/getTemplates.json",response)
});
});

it("Create new templates for a CLA Group", function () {
cy.request({
method: 'POST',
url: `${claEndpoint}/clagroup/${claGroupId}/template`,
auth: {
'bearer': bearerToken,
},body:{
"MetaFields": [
{
"description": "Project's Full Name.",
"name": "Project Name",
"templateVariable": "PROJECT_NAME",
"value" : "Test"
},
{
"description": "The Full Entity Name of the Project.",
"name": "Project Entity Name",
"templateVariable": "PROJECT_ENTITY_NAME",
"value" : "Test"
},
{
"description": "The E-Mail Address of the Person managing the CLA. ",
"name": "Contact Email Address",
"templateVariable": "CONTACT_EMAIL",
"value" : "veerendrat@proximabiz.com"
}
],
"TemplateID": templateId
},
failOnStatusCode: false
}).then((response) => {
validate_200_Status(response);
expect(response.body.corporatePDFURL);
expect(response.body.individualPDFURL);
});
});

it("Preview ICLA templates for CLA Group", function () {
cy.request({
method: 'POST',
url: `${claEndpoint}/template/preview?template_for=icla`,
auth: {
'bearer': bearerToken,
},body:{
"MetaFields": [
{
"description": "Project's Full Name.",
"name": "Project Name",
"templateVariable": "PROJECT_NAME",
"value" : "Test"
},
{
"description": "The Full Entity Name of the Project.",
"name": "Project Entity Name",
"templateVariable": "PROJECT_ENTITY_NAME",
"value" : "Test"
},
{
"description": "The E-Mail Address of the Person managing the CLA. ",
"name": "Contact Email Address",
"templateVariable": "CONTACT_EMAIL",
"value" : "veerendrat@proximabiz.com"
}
],
"TemplateID": templateId
},
failOnStatusCode: false
}).then((response) => {
validate_200_Status(response);
expect(response.body.corporatePDFURL);
expect(response.body.individualPDFURL);
});
});

it("Preview CCLA templates for CLA Group", function () {
cy.request({
method: 'POST',
url: `${claEndpoint}/template/preview?template_for=ccla`,
auth: {
'bearer': bearerToken,
},body:{
"MetaFields": [
{
"description": "Project's Full Name.",
"name": "Project Name",
"templateVariable": "PROJECT_NAME",
"value" : "Test"
},
{
"description": "The Full Entity Name of the Project.",
"name": "Project Entity Name",
"templateVariable": "PROJECT_ENTITY_NAME",
"value" : "Test"
},
{
"description": "The E-Mail Address of the Person managing the CLA. ",
"name": "Contact Email Address",
"templateVariable": "CONTACT_EMAIL",
"value" : "veerendrat@proximabiz.com"
}
],
"TemplateID": templateId
},
failOnStatusCode: false
}).then((response) => {
validate_200_Status(response);
expect(response.body.corporatePDFURL);
expect(response.body.individualPDFURL);
});
});

it("Preview CLA Group Template PDF", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}/template/${claGroupId}/preview?claType=ccla&watermark=false`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
});
});

})
172 changes: 172 additions & 0 deletions tests/functional/cypress/fixtures/templates/getTemplates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": [
{
"type": "object",
"properties": {
"ID": {
"type": "string"
},
"Name": {
"type": "string"
},
"cclaFields": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"anchorString": {
"type": "string"
},
"fieldType": {
"type": "string"
},
"height": {
"type": "integer"
},
"id": {
"type": "string"
},
"isEditable": {
"type": "boolean"
},
"isOptional": {
"type": "boolean"
},
"name": {
"type": "string"
},
"offsetX": {
"type": "integer"
},
"offsetY": {
"type": "integer"
},
"width": {
"type": "integer"
}
},
"required": [
"anchorString",
"fieldType",
"height",
"id",
"isEditable",
"isOptional",
"name",
"offsetX",
"offsetY",
"width"
]
}
]
},
"cclaHtmlBody": {
"type": "string"
},
"description": {
"type": "string"
},
"iclaFields": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"anchorString": {
"type": "string"
},
"fieldType": {
"type": "string"
},
"height": {
"type": "integer"
},
"id": {
"type": "string"
},
"isEditable": {
"type": "boolean"
},
"isOptional": {
"type": "boolean"
},
"name": {
"type": "string"
},
"offsetX": {
"type": "integer"
},
"offsetY": {
"type": "integer"
},
"width": {
"type": "integer"
}
},
"required": [
"anchorString",
"fieldType",
"id",
"isEditable",
"isOptional",
"name",
"offsetX",
"offsetY",
"width"
]
}
]
},
"iclaHtmlBody": {
"type": "string"
},
"metaFields": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"description": {
"type": "string"
},
"name": {
"type": "string"
},
"templateVariable": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"description",
"name",
"templateVariable",
"value"
]
}
]
},
"templateMajorVersion": {
"type": "integer"
},
"templateMinorVersion": {
"type": "integer"
}
},
"required": [
"ID",
"Name",
"cclaFields",
"description",
"iclaFields",
"metaFields",
"templateMajorVersion"
]
}
]
}