Adding test for all types of credentials

This commit is contained in:
mildred 2024-03-25 12:31:43 +01:00
parent 994a56da39
commit d43f893c74
49 changed files with 1248 additions and 466 deletions

View File

@ -1,44 +1,71 @@
/*Constants for TEMPLATES testing*/
//JSON_SCHEMA_FVC: A string representing the filename of the financial vulnerability JSON schema.
export const JSON_SCHEMA_FVC = "financial-vulnerability.json"
//JSON_SCHEMA_ID_FVC: A URL pointing to the online location of the financial vulnerability JSON schema.
export const JSON_SCHEMA_ID_FVC = "https://idhub.pangea.org/vc_schemas/financial-vulnerability.json"
/*Files used in DATA IMPORT testing*/
//PATH_FILES_TO_IMPORT: A string representing the path to the directory where Excel files are located for data import testing.
export const PATH_FILES_TO_IMPORT = '/vc_excel/'
//Financial Vulnerability Credential
//JSON_SCHEMA: A string representing the filename of the credential JSON schema.
export const JSON_SCHEMA_FVC = "financial-vulnerability.json"
export const JSON_SCHEMA_MC = "membership-card.json"
export const JSON_SCHEMA_NGO_FM = "federation-membership.json"
export const JSON_SCHEMA_CC = "course-credential.json"
export const JSON_SCHEMA_EOC = "e-operator-claim.json"
//JSON_SCHEMA_ID: A URL pointing to the online location of the financial vulnerability JSON schema.
export const JSON_SCHEMA_ID_FVC = "https://idhub.pangea.org/vc_schemas/financial-vulnerability.json"
export const JSON_SCHEMA_ID_MC = "https://idhub.pangea.org/vc_schemas/membership-card.json"
export const JSON_SCHEMA_ID_NGO_FM = "https://idhub.pangea.org/vc_schemas/federation-membership.json"
export const JSON_SCHEMA_ID_CC = "https://idhub.pangea.org/vc_schemas/course-credential.json"
export const JSON_SCHEMA_ID_EOC = "https://idhub.pangea.org/vc_schemas/e-operator-claim.json"
//Excel testing files
//FVC
export const FILE_TO_IMPORT_FVC = 'financial-vulnerability.xlsx'
export const FILE_TO_IMPORT_FVC_EMPTY = 'financial-vulnerability-empty.xlsx'
export const FILE_TO_IMPORT_FVC_WITHOUT_REQUIRED_COLUMNS = 'financial-vulnerability-without-required-columns.xlsx'
export const FILE_TO_IMPORT_FVC_WITH_ALIEN_COLUMNS = 'financial-vulnerability-with-alien-columns.xlsx'
export const FILE_TO_IMPORT_FVC_WITH_REQUIRED_EMPTY = 'financial-vulnerability-with-required-empty.xlsx'
//"Schema name" as appears in the Idhub User interface for FVC
//MC
export const FILE_TO_IMPORT_MC = 'membership-card.xlsx'
export const FILE_TO_IMPORT_MC_2 = 'membership-card2.xlsx'
export const FILE_TO_IMPORT_MC_EMPTY = 'membership-card-empty.xlsx'
export const FILE_TO_IMPORT_MC_WITHOUT_REQUIRED_COLUMNS = 'membership-card-without-required-columns.xlsx'
export const FILE_TO_IMPORT_MC_WITH_ALIEN_COLUMNS = 'membership-card-with-alien-columns.xlsx'
export const FILE_TO_IMPORT_MC_WITH_REQUIRED_EMPTY = 'membership-card-with-required-empty.xlsx'
//NGO FEDERATION MEMBERSHIP
export const FILE_TO_IMPORT_NGO_FM = 'federation-membership.xlsx'
export const FILE_TO_IMPORT_NGO_FM_EMPTY = 'federation-membership-empty.xlsx'
export const FILE_TO_IMPORT_NGO_FM_WITHOUT_REQUIRED_COLUMNS = 'federation-membership-without-required-columns.xlsx'
export const FILE_TO_IMPORT_NGO_FM_WITH_ALIEN_COLUMNS = 'federation-membership-with-alien-columns.xlsx'
export const FILE_TO_IMPORT_NGO_FM_WITH_REQUIRED_EMPTY = 'federation-membership-with-required-empty.xlsx'
//CC
export const FILE_TO_IMPORT_CC = 'course-credential.xlsx'
export const FILE_TO_IMPORT_CC_EMPTY = 'course-credential-empty.xlsx'
export const FILE_TO_IMPORT_CC_WITHOUT_REQUIRED_COLUMNS = 'course-credential-without-required-columns.xlsx'
export const FILE_TO_IMPORT_CC_WITH_ALIEN_COLUMNS = 'course-credential-with-alien-columns.xlsx'
export const FILE_TO_IMPORT_CC_WITH_REQUIRED_EMPTY = 'course-credential-with-required-empty.xlsx'
//E-OPERATOR-CLAIM
export const FILE_TO_IMPORT_EOC = 'e-operator-claim.xlsx'
export const FILE_TO_IMPORT_EOC_EMPTY = 'e-operator-claim-empty.xlsx'
export const FILE_TO_IMPORT_EOC_WITHOUT_REQUIRED_COLUMNS = 'e-operator-claim-without-required-columns.xlsx'
export const FILE_TO_IMPORT_EOC_WITH_ALIEN_COLUMNS = 'e-operator-claim-with-alien-columns.xlsx'
export const FILE_TO_IMPORT_EOC_WITH_REQUIRED_EMPTY = 'e-operator-claim-with-required-empty.xlsx'
//"Schema name" as appears in the Idhub Admin interface Data->Import->combo schema
export const SCHEMA_FVC = 'Financial Vulnerability Credential'
//"Schema type" as appears in the Idhub User interface for FVC
export const SCHEMA_TYPE_FVC = 'FinancialVulnerabilityCredential'
//Membership Card
export const FILE_TO_IMPORT_MC = 'membership-card.xlsx';
export const SCHEMA_MC = 'Membership Card'
export const SCHEMA_TYPE_MC = 'MembershipCardCredential' //Revisar este valor en la interfaz
//NGOFederationMembership
export const FILE_TO_IMPORT_FM = 'federation-membership.xlsx';
export const SCHEMA_FM = 'Federation Membership'
export const SCHEMA_TYPE_FM = 'FederationMembership' //Revisar este valor en la interfaz (en Type)
//Course Credential
export const FILE_TO_IMPORT_CC = 'course-credential.xlsx';
export const SCHEMA_CC = 'Course Credential'
export const SCHEMA_TYPE_CC = 'CourseCredential' //Revisar este valor en la interfaz
export const SCHEMA_NGO_FM = 'NGO federation membership'
export const SCHEMA_CC = 'NGO Course Credential for participants'
export const SCHEMA_EOC = 'Product and waste electronics operator claim'
//"Schema type" as appears in the Idhub My wallet->My Credentials-> value on column 'type'
export const SCHEMA_TYPE_FVC = 'FinancialVulnerabilityCredential'
export const SCHEMA_TYPE_MC = 'MembershipCard'
export const SCHEMA_TYPE_NGO_FM = 'FederationMembership'
export const SCHEMA_TYPE_CC = 'CourseCredential'
export const SCHEMA_TYPE_EOC = 'EOperatorClaim'
//Messages
export const ALERT_FILE_IMPORTED_SUCCESSFULLY = "The file was imported successfully!"
@ -47,9 +74,17 @@ export const ALERT_FILE_TO_IMPORT_IS_EMPTY = "The file you try to import is empt
export const ALERT_FILE_NOT_CORRESPOND_SCHEMA = "This File does not correspond to this scheme!"
export const ALERT_FILE_IS_BADLY_FORMATTED = "This file is badly formatted!"
export const ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS = "line 2: 'email' is a required property"
export const ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_MC = "line 2: 'affiliatedSince' is a required property"
export const ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_NGO_FM = "line 2: 'legalName' is a required property"
export const ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_CC = "line 2: 'firstName' is a required property"
export const ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_EOC = "line 2: 'legalName' is a required property"
export const ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS = "line 2: Additional properties are not allowed ('alien1', 'alien2' were unexpected)"
export const ALERT_USER_CREATED_SUCESSFULLY_MESSAGE = 'The account was created successfully'
export const ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY = "line 3: 'firstName' is a required property"
export const ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY_NGO_FM = "line 5: 'postCode' is a required property"
export const ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY_EOC = "line 3: 'legalName' is a required property"
export const ALERT_USER_CREATED_SUCESSFULLY_MESSAGE = 'The account was created successfully'
export const ERROR_INCORRECT_EMAIL_PASSWORD = 'Please enter a correct Email address and password. Note that both fields may be case-sensitive.'

View File

@ -16,26 +16,71 @@ export const CREDENTIAL_TYPES_FIELDS_LIST = {
'assessmentDate'
] as string[],
// TODO Add other type credentials...
};
export const CREDENTIAL_TYPES_REQUIRED_FIELDS_LIST = {
"FinancialVulnerabilityCredential": [
"id",
"firstName",
"lastName",
"email",
"identityDocType",
"identityNumber",
"streetAddress",
"socialWorkerName",
"socialWorkerSurname",
"financialVulnerabilityScore",
"amountCoveredByOtherAids",
"assessmentDate"
"MembershipCard": [
'organisation',
'membershipType',
'membershipId',
'affiliatedSince',
'affiliatedUntil',
'typeOfPerson',
'identityDocType',
'identityNumber',
'firstName',
'lastName',
'role',
'email'
] as string[],
"FederationMembership": [
'federation',
'legalName',
'shortName',
'registrationIdentifier',
'publicRegistry',
'streetAddress',
'postCode',
'city',
'taxReference',
'membershipType',
'membershipStatus',
'membershipId',
'membershipSince',
'email',
'phone',
'website',
'evidence',
'certificationDate',
] as string[],
"CourseCredential": [
'firstName',
'lastName',
'email',
'personalIdentifier',
'issuedDate',
'modeOfInstruction',
'courseDuration',
'courseDays',
'courseName',
'courseDescription',
'gradingScheme',
'scoreAwarded',
'qualificationAwarded',
'courseLevel',
'courseFramework',
'courseCredits',
'dateOfAssessment',
'evidenceAssessment'
] as string[],
"EOperatorClaim": [
'legalName',
'role',
'email',
'accreditedBy',
'operatorNumber',
'limitJurisdiction',
'accreditedFor'
] as string[],
};
// TODO Add other type credentials...
};

View File

@ -3,9 +3,15 @@ export const ENCRYPTION_KEY = "1234"
export const ADMIN_EMAIL = "idhub_admin@pangea.org"
export const ADMIN_K = "1234"
export const KO_ADMIN_K = "876"
//export const URL_IDHUB = "https://idhub-autotest.demo.pangea.org"
export const URL_IDHUB = "https://idhub1-autotest.demo.pangea.org"
//export const URL_IDHUB = "https://idhub1-nightly.demo.pangea.org"
//2fa enabled
//export const URL_IDHUB = "https://idhub-nightly.demo.pangea.org"
export const USER1_EMAIL = "user1@example.org"
export const USER2_EMAIL = "user2@example.org"
export const USER3_EMAIL = "user3@example.org"

View File

@ -1,12 +1,11 @@
import { CourseCredential_fields, FinancialVulnerabilityCredential_fields, MembershipCard_fields, NGOFederationMembership_fields } from "../interfaces/credential_interfaces";
// List of entries in data store for the different types of credentials
export const CREDENTIAL_TYPES_DATA_STORE = {
FinancialVulnerabilityCredential_data: [] as FinancialVulnerabilityCredential_fields[],
MembershipCard_data: [] as MembershipCard_fields[],
NGOFederationMembership_data: [] as NGOFederationMembership_fields[],
CourseCredential_data: [] as CourseCredential_fields[],
//TODO añadir otros tipos de credenciales
FinancialVulnerabilityCredential_data: [] as Record<string, any>,
MembershipCard_data: [] as Record<string, any>,
FederationMembership_data: [] as Record<string, any>,
CourseCredential_data: [] as Record<string, any>,
EOperatorClaim_data: [] as Record<string, any>
};
//Testing data for financialVulnerabilityCredential
@ -72,21 +71,252 @@ CREDENTIAL_TYPES_DATA_STORE.FinancialVulnerabilityCredential_data = [{
}
];
//Testing data for Membership Card
CREDENTIAL_TYPES_DATA_STORE.MembershipCard_data = [
//TODO: fill with data
{
organisation: "Pangea",
membershipType: "Employee",
membershipId: "1234",
affiliatedSince: "2019-01-01",
affiliatedUntil: "2025-01-01",
typeOfPerson: "natural",
identityDocType: "DNI",
identityNumber: "89898987A",
firstName: "Wolfgang Amadeus",
lastName: "Mozart",
role: "Conductor",
email: "user1@example.org"
},
{
organisation: "Pangea",
membershipType: "Employee",
membershipId: "2345",
affiliatedSince: "2020-01-01",
typeOfPerson: "natural",
identityDocType: "NIE",
identityNumber: "23456789P",
firstName: "Ludwing Van",
lastName: "Beethoven",
role: "Composer",
email: "user2@example.org"
},
{
organisation: "Pangea",
membershipType: "Employee",
membershipId: "2312",
affiliatedSince: "2021-01-01",
affiliatedUntil: "2026-01-01",
typeOfPerson: "natural",
identityDocType: "DNI",
identityNumber: "87665566D",
firstName: "Franz",
lastName: "Schubert",
role: "Chamber musician",
email: "user3@example.org"
},
{
organisation: "Pangea",
membershipType: "Employee",
membershipId: "3212",
affiliatedSince: "2021-01-01",
affiliatedUntil: "2026-01-01",
typeOfPerson: "natural",
identityDocType: "NIE",
identityNumber: "87654567",
firstName: "Barbara",
lastName: "Strozzi",
role: "Composer and Singer",
email: "user4@example.org"
},
{
organisation: "Pangea",
membershipType: "Employee",
membershipId: "4544",
affiliatedSince: "2021-01-02",
affiliatedUntil: "2026-01-01",
typeOfPerson: "natural",
identityDocType: "DNI",
identityNumber: "98765432",
firstName: "Clara",
lastName: "Schumann",
role: "Composer and Pianist",
email: "user5@example.org"
}
];
CREDENTIAL_TYPES_DATA_STORE.NGOFederationMembership_data = [
//TODO: fill with data
CREDENTIAL_TYPES_DATA_STORE.FederationMembership_data = [
{
federation: "Lafede",
legalName: "ACCIÓ CONTRA LA FAM",
shortName: "ACCIÓ CONTRA LA FAM",
registrationIdentifier: "28-0968",
publicRegistry: "Registro del Protectorado de Fundaciones del Ministerio de Asuntos Sociales",
streetAddress: "c/Diputació, 180, 3B",
postCode: "08011",
city: "Barcelona",
taxReference: "G-81164105",
membershipType: "full",
membershipStatus: "active",
membershipId: "1234",
membershipSince: "2010-01-01",
email: "user1@example.org",
phone: "93 254 03 81",
website: "https://www.acciocontralafam.org",
certificationDate: "2024-02-02",
},
{
federation: "Lafede",
legalName: "ACNUR CATALUNYA COMITÈ CATALÀ PER ALS REFUGIATS",
shortName: "UNHCR ACNUR",
registrationIdentifier: "130.446",
publicRegistry: "Registro del Protectorado de Fundaciones del Ministerio de Asuntos Sociales",
streetAddress: "c/ Trafalgar, 6. Principal 3ª",
postCode: "08001",
city: "Barcelona",
taxReference: "G80757560",
membershipType: "observer",
membershipStatus: "active",
membershipId: "2345",
membershipSince: "2010-01-01",
email: "user2@example.org",
website: "https://www.eacnur.org",
certificationDate: "2024-02-02",
},
{
federation: "Lafede",
legalName: "AMNISTIA INTERNACIONAL CATALUNYA",
shortName: "AMNISTIA INTERNACIONAL",
registrationIdentifier: "22729",
publicRegistry: "Registro del Protectorado de Fundaciones del Ministerio de Asuntos Sociales",
streetAddress: "Alfons XII, 19-21, pral. 1A",
postCode: "08006",
city: "Barcelona",
membershipType: "observer",
membershipStatus: "active",
membershipId: "2345",
membershipSince: "2010-01-01",
email: "user3@example.org",
website: "https://www.amnistiacatalunya.org",
certificationDate: "2024-02-02",
},
{
federation: "Lafede",
legalName: "ASSOCIACIÓ CATALANA DENGINYERIA SENSE FRONTERES",
shortName: "ENGINYERIA SENSE FRONTERES",
publicRegistry: "Registro del Protectorado de Fundaciones del Ministerio de Asuntos Sociales",
streetAddress: "Mandoni 4, Baixos,",
postCode: "08004",
city: "Barcelona",
membershipType: "full",
membershipStatus: "active",
membershipId: "4567",
membershipSince: "2010-01-01",
email: "user4@example.ort",
phone: "93 302 27 53",
website: "https://www.esf-cat.org",
certificationDate: "2024-02-02",
},
];
CREDENTIAL_TYPES_DATA_STORE.CourseCredential_data = [
//TODO: fill with data
{
firstName: "Wolfgang Amadeus",
lastName: "Mozart",
email: "user1@example.org",
personalIdentifier: "1234",
issuedDate: "2022-09-22",
modeOfInstruction: "online",
courseDuration: "20",
courseDays: "5",
courseName: "How to write a great sonata",
courseDescription: "This course provides an in-depth exploration of sonata form, a structural framework that has been central to the development of Western classical music, particularly in the first movements of sonatas, symphonies, and string quartets.",
gradingScheme: "Grade Point Average (GPA)",
scoreAwarded: "10",
qualificationAwarded: "A+",
courseLevel: "Postgraduate",
courseFramework: "European Qualifications Framework (EQF) Level 6",
courseCredits: "5",
dateOfAssessment: "2020-12-20",
evidenceAssessment: "final exam"
},
{
firstName: "Ludwing Van",
lastName: "Beethoven",
email: "user2@example.org",
personalIdentifier: "44334",
issuedDate: "2021-10-10",
modeOfInstruction: "onsite",
courseDuration: "10",
courseDays: "3",
courseName: "Modern piano",
courseDescription: "The Modern Piano course offers a comprehensive exploration of various styles of modern piano music, from the early 20th century to contemporary times.",
gradingScheme: "Grade Point Average (GPA)",
scoreAwarded: "9",
qualificationAwarded: "A",
courseLevel: "Undergraduate",
courseCredits: "7",
dateOfAssessment: "2020-12-20",
evidenceAssessment: "presence"
},
{
firstName: "Barbara",
lastName: "Strozzi",
email: "user4@example.org",
personalIdentifier: "45454K",
issuedDate: "2019-05-05",
modeOfInstruction: "online",
courseDuration: "20",
courseDays: "5",
courseName: "Opera",
courseDescription: "The Opera course offers a comprehensive exploration of opera as an art form, from its historical origins to its contemporary expressions.",
scoreAwarded: "9",
qualificationAwarded: "A",
courseLevel: "Postgraduate",
courseFramework: "Classical music",
courseCredits: "10",
dateOfAssessment: "2020-12-20",
evidenceAssessment: "presence"
}
];
CREDENTIAL_TYPES_DATA_STORE.EOperatorClaim_data = [
{
legalName: "Recicladors associats",
role: "Gestor de residus RAEE",
email: "user1@example.org",
accreditedBy: "Agència de residus de Catalunya",
operatorNumber: "E-1111.22",
limitJurisdiction: "Catalunya",
accreditedFor: "CLASSIFICACIÓ DE FERRALLA, RES. VOLUMINOSOS, DESMUNTATGE DE RAEE I PREPARACIÓ PER A LA REUTILITZACIÓ DE RESIDUS DE ROBA I DE RAEE. TRANSFERÈNCIA DE RESIDUS P I NP (INCLÒS RAEE)",
},
{
legalName: "GSP",
role: "Gestor de residus RAEE",
email: "user2@example.org",
accreditedBy: "Agència de residus de Catalunya",
operatorNumber: "E-1555.14",
limitJurisdiction: "Catalunya",
accreditedFor: "CLASSIF. FERRALLA, CARTRÓ PLÀSTIC I FUSTA, CLASSIF., TRITURACIÓ DE CABLE, CLASSIFICACIÓ, DESMUNTATGE RAEE (FR 2,3,4,5,6), PREPARACIO PER A LA REUTILITZACIÓ DE RAEE (FR 1,2,4,5,6,7) ALTRES ACTIVITATS SEGONS LLIC. AMBIENTAL DE 25/02/16 I DE 28/1/2022",
},
{
legalName: "Reutilitza",
role: "Gestor de residus RAEE",
email: "user3@example.org",
accreditedBy: "Agència de residus de Catalunya",
operatorNumber: "E-0000.12",
limitJurisdiction: "Catalunya",
accreditedFor: "RECUPERACIÓ DE RAEE NO PERILLOSOS MITJANÇANT CLASSIFICACIÓ I REPARACIÓ (PREPARACIÓ PER LA REUTILITZACIÓ) I TRANSFERÈNCIA DE RAEE PERILLOSOS I NO PERILLOSOS I ALTRES SEGONS RELACIÓ.",
}
];
export const CREDENTIAL_TYPE_DATASTORE_UNDEFINED = {
FinancialVulnerabilityCredential_data_undefined: {} as FinancialVulnerabilityCredential_fields
FinancialVulnerabilityCredential_data_undefined: {} as Record<string, any>,
MembershipCard_data_undefined: {} as Record<string, any>,
FederationMembership_data_undefined: {} as Record<string, any>,
CourseCredential_data_undefined: {} as Record<string, any>,
EOperatorClaim_data_undefined: {} as Record<string, any>
//TODO añadir otros tipos de credenciales
}
@ -104,6 +334,73 @@ CREDENTIAL_TYPE_DATASTORE_UNDEFINED.FinancialVulnerabilityCredential_data_undefi
financialVulnerabilityScore: 'undefined_data',
amountCoveredByOtherAids: 'undefined_data',
connectivityOptionList: 'undefined_data',
assessmentDate: 'undefined_data',
assessmentDate: 'undefined_data'
}
CREDENTIAL_TYPE_DATASTORE_UNDEFINED.MembershipCard_data_undefined = {
organisation: 'undefined_data',
membershipType: 'undefined_data',
membershipId: 'undefined_data',
affiliatedSince: 'undefined_data',
affiliatedUntil: 'undefined_data',
typeOfPerson: 'undefined_data',
identityDocType: 'undefined_data',
identityNumber: 'undefined_data',
firstName: 'undefined_data',
lastName: 'undefined_data',
role: 'undefined_data',
email: 'undefined_data'
}
CREDENTIAL_TYPE_DATASTORE_UNDEFINED.FederationMembership_data_undefined = {
federation: 'undefined_data',
legalName: 'undefined_data',
shortName: 'undefined_data',
registrationIdentifier: 'undefined_data',
publicRegistry: 'undefined_data',
streetAddress: 'undefined_data',
postCode: 'undefined_data',
city: 'undefined_data',
taxReference: 'undefined_data',
membershipType: 'undefined_data',
membershipStatus: 'undefined_data',
membershipId: 'undefined_data',
membershipSince: 'undefined_data',
email: 'undefined_data',
phone: 'undefined_data',
website: 'undefined_data',
evidence: 'undefined_data',
certificationDate: 'undefined_data'
}
CREDENTIAL_TYPE_DATASTORE_UNDEFINED.CourseCredential_data_undefined = {
firstName: 'undefined_data',
lastName: 'undefined_data',
email: 'undefined_data',
personalIdentifier: 'undefined_data',
issuedDate: 'undefined_data',
modeOfInstruction: 'undefined_data',
courseDuration: 'undefined_data',
courseDays: 'undefined_data',
courseName: 'undefined_data',
courseDescription: 'undefined_data',
gradingScheme: 'undefined_data',
scoreAwarded: 'undefined_data',
qualificationAwarded: 'undefined_data',
courseLevel: 'undefined_data',
courseFramework: 'undefined_data',
courseCredits: 'undefined_data',
dateOfAssessment: 'undefined_data',
evidenceAssessment: 'undefined_data',
}
CREDENTIAL_TYPE_DATASTORE_UNDEFINED.EOperatorClaim_data_undefined = {
legalName: 'undefined_data',
role: 'undefined_data',
email: 'undefined_data',
accreditedBy: 'undefined_data',
operatorNumber: 'undefined_data',
limitJurisdiction: 'undefined_data',
accreditedFor: 'undefined_data'
}

View File

@ -1,80 +0,0 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://idhub.pangea.org/credentials/base/v1",
"https://idhub.pangea.org/credentials/financial-vulnerability/v1"
],
"id": "https://http://idhub-autotest.demo.pangea.org/credentials/1",
"type": [
"VerifiableCredential",
"VerifiableAttestation",
"FinancialVulnerabilityCredential"
],
"credentialSubject": {
"id": "did:web:idhub-autotest.demo.pangea.org:did-registry:z6Mkr4s4CSK3t52CXaw9inx2cxUhB8BNT7P5Dj3kK5ySz758",
"connectivityOptionList": "Fibra",
"identityNumber": "45678900V",
"assessmentDate": "2024-01-01",
"phoneNumber": "678567456",
"streetAddress": "C/ Tallers 1",
"lastName": "Mozart",
"email": "user1@example.org",
"identityDocType": "DNI",
"socialWorkerName": "Ana",
"socialWorkerSurname": "Fernández",
"amountCoveredByOtherAids": "0",
"firstName": "Wolfgang Amadeus",
"financialVulnerabilityScore": "4"
},
"issuer": {
"id": "did:web:idhub-autotest.demo.pangea.org:did-registry:z6MktKKrgWJne5ZQkj5uVyHkdrPfRZGC7HEiaR9LrfjPhEP8",
"name": "idhub-autotest.demo.pangea.org"
},
"issuanceDate": "2024-03-06T22:15:20Z",
"proof": {
"type": "Ed25519Signature2018",
"proofPurpose": "assertionMethod",
"verificationMethod": "did:web:idhub-autotest.demo.pangea.org:did-registry:z6MktKKrgWJne5ZQkj5uVyHkdrPfRZGC7HEiaR9LrfjPhEP8#owner",
"created": "2024-03-06T22:15:20.778Z",
"jws": "eyJhbGciOiJFZERTQSIsImNyaXQiOlsiYjY0Il0sImI2NCI6ZmFsc2V9..HiLXLoMlwkhfHd5Ha20AP8Mgtgna_JaTpg-UZvobYEZcGJLrWEY-MntnCglHyQ6oXCNRlc-DCpG9JdsWf8boDg"
},
"credentialStatus": {
"id": "did:web:idhub-autotest.demo.pangea.org:did-registry:z6MktKKrgWJne5ZQkj5uVyHkdrPfRZGC7HEiaR9LrfjPhEP8",
"type": "RevocationBitmap2022",
"revocationBitmapIndex": "1"
},
"credentialSchema": {
"id": "https://idhub.pangea.org/vc_schemas/financial-vulnerability.json",
"type": "FullJsonSchemaValidator2021"
},
"validFrom": "2024-03-06T22:15:20Z",
"description": [
{
"lang": "en",
"value": "The Financial Vulnerability Credential is issued to individuals or families to prove their financial vulnerability based on various factors, with the objective of presenting it to a third party to receive benefits or services."
},
{
"lang": "ca_ES",
"value": "La Credencial de Vulnerabilitat Financera és emesa a persones o famílies per acreditar la seva vulnerabilitat financera sobre la base de diversos factors, amb l'objectiu que la presentin a una tercera part per rebre beneficis o serveis."
},
{
"lang": "es",
"value": "La Credencial de Vulnerabilidad Financiera es emitida a personas o familias para acreditar su vulnerabilidad financiera con base en diversos factores, con el objetivo de que la presenten a una tercera parte para recibir beneficios o servicios."
}
],
"issued": "2024-03-06T22:15:20Z",
"name": [
{
"lang": "en",
"value": "Financial Vulnerability Credential"
},
{
"lang": "ca_ES",
"value": "Credencial de Vulnerabilitat Financera"
},
{
"lang": "es",
"value": "Credencial de Vulnerabilidad Financiera"
}
]
}

View File

@ -1,69 +0,0 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://idhub.pangea.org/credentials/base/v1",
"https://idhub.pangea.org/credentials/financial-vulnerability/v1"
],
"id": "https://idhub.pangea.org/credentials/987654321",
"type": [
"VerifiableCredential",
"VerifiableAttestation",
"FinancialVulnerabilityCredential"
],
"issuer": {
"id": "did:example:5678",
"name": "Fundació Pare Manel"
},
"issuanceDate": "2023-12-06T19:23:24Z",
"issued": "2023-12-06T19:23:24Z",
"validFrom": "2023-12-06T19:23:24Z",
"validUntil": "2024-12-06T19:23:24Z",
"name": [
{
"value": "Financial Vulnerability Credential",
"lang": "en"
},
{
"value": "Credencial de Vulnerabilitat Financera",
"lang": "ca_ES"
},
{
"value": "Credencial de Vulnerabilidad Financiera",
"lang": "es"
}
],
"description": [
{
"value": "The Financial Vulnerability Credential is issued to individuals or families to prove their financial vulnerability based on various factors, with the objective of presenting it to a third party to receive benefits or services.",
"lang": "en"
},
{
"value": "La Credencial de Vulnerabilitat Financera és emesa a persones o famílies per acreditar la seva vulnerabilitat financera sobre la base de diversos factors, amb l'objectiu que la presentin a una tercera part per rebre beneficis o serveis.",
"lang": "ca_ES"
},
{
"value": "La Credencial de Vulnerabilidad Financiera es emitida a personas o familias para acreditar su vulnerabilidad financiera con base en diversos factores, con el objetivo de que la presenten a una tercera parte para recibir beneficios o servicios.",
"lang": "es"
}
],
"credentialSubject": {
"id": "did:example:1234",
"firstName": "Joan",
"lastName": "Pera",
"email": "joan.pera@pangea.org",
"identityDocType": "DNI",
"identityNumber": "12345678A",
"phoneNumber": "1234567890",
"streetAddress": "Tallers 19 2-1 Barcelona",
"socialWorkerName": "Mireia",
"socialWorkerSurname": "Pujol",
"financialVulnerabilityScore": "5",
"amountCoveredByOtherAids": "20",
"connectivityOptionList": "fibre, mobile",
"assessmentDate": "2023-12-06"
},
"credentialSchema": {
"id": "https://idhub.pangea.org/vc_schemas/financial-vulnerability.json",
"type": "FullJsonSchemaValidator2021"
}
}

View File

@ -71,4 +71,14 @@ export interface FinancialVulnerabilityCredential_fields {
evidenceAssessment: string;
}
//TODO complete
export interface EOperatorClaim_fields{
legalName: string;
role: string;
email: string;
accreditedBy: string;
operatorNumber: string;
limitJurisdiction: string;
accreditedFor: string;
}

View File

@ -89,7 +89,6 @@ export class BasicUserInfoSectionPage {
async addUserBasicInfo(newFirstname: string, newLastname: string, newEmail: string, isAdmin: boolean) {
try {
console.log("Adding user with email: ", newEmail);
await this.firstName.fill(newFirstname);
await this.lastName.fill(newLastname);
await this.email.fill(newEmail);
@ -107,7 +106,6 @@ export class BasicUserInfoSectionPage {
async updateUserBasicInfo(newFirstname: string, newLastname: string, newEmail: string, isAdmin: boolean) {
try {
console.log("Modifying user with email: ", newEmail);
await this.firstName.fill(newFirstname);
await this.lastName.fill(newLastname);
await this.email.fill(newEmail);

View File

@ -88,7 +88,6 @@ export class ImportDataPage {
}
async importFile(schema: string, fileToImport: string, did: string) {
try {
console.log('Importing the file from the current working directory: ${process.cwd()}');
await (await this.getDropdownDID()).selectOption({ label: did });
await (await this.getDropdownSchema()).selectOption({ label: schema });
await (await this.getFileToImport()).click();

View File

@ -45,7 +45,6 @@ export class ImportTemplatePage {
async schemaIsAvailableToImport(schemaName: string): Promise<boolean> {
try {
console.log(`Checking if template ${schemaName} exists`);
// Wait for the table to appear and contain at least one row
await this.page.waitForFunction(() => document.querySelectorAll('tr').length > 0, { timeout: 10000 });

View File

@ -98,13 +98,9 @@ export class TemplatesPage {
for (let i = 0; i < rowCount; i++) {
// Get the second cell (file schema name) of the current row
console.log("Checking schema name against JSON for element: ", i);
const fileSchemaCell = page.locator(`table tbody tr:nth-child(${i + 1}) td:nth-child(2)`);
const fileSchemaValue = await fileSchemaCell.innerText();
// Print the value of the second cell
console.log('Name of the schema: ' + fileSchemaValue);
// Click the corresponding element in the fifth cell (eye icon)
await clickViewSchemaOnLeftMenu(page, fileSchemaValue)
@ -114,7 +110,6 @@ export class TemplatesPage {
// Extract the last component of the $id path
const idUrl = new URL(jsonContent["$id"]);
const lastPathSegment = idUrl.pathname.split("/").pop();
console.log('lastPathSegment', lastPathSegment);
// Check if the last component of the $id path matches the second cell value (File schema)
expect(lastPathSegment).toBe(fileSchemaValue);
@ -129,8 +124,6 @@ export class TemplatesPage {
async schemaIsAvailableInView(schemaName: string): Promise<boolean> {
try {
console.log('Checking if template ${schemaName} exists');
// Wait for the table to appear and contain at least one row
await this.page.waitForFunction(() => document.querySelectorAll('tr').length > 0, { timeout: 10000 });

View File

@ -60,9 +60,6 @@ export class UserPersonalInformationPage {
const toDateElement = await this.page.$$eval('tr > td:nth-of-type(3)', elements => elements.map(el => el.textContent ? el.textContent.trim() : ''));
const toDate = toDateElement[0];
console.log(fn, ' ', ln, ' ', em, ' ', mst, ' ', fromDate, ' ', toDate);
console.log(user.firstName, ' ', user.lastName, ' ', user.email, ' ', getMembershipTypeById(user.membershipType), ' ', formatDate(user.startDate), ' ', formatDate(user.endDate));
if (user.firstName === fn && user.lastName === ln && user.email === em && getMembershipTypeById(user.membershipType) === mst && formatDate(user.startDate) === fromDate && formatDate(user.endDate) === toDate) {
return true
}

View File

@ -93,7 +93,6 @@ export class ViewImportedDataPage {
async fileIsAvailableInView(fileName: string): Promise<boolean> {
try {
console.log(`Checking if file ${fileName} was previously loaded`);
// Wait for the table to appear and contain at least one row
await this.page.waitForFunction(() => document.querySelectorAll('tr').length > 0, { timeout: 10000 });

View File

@ -43,7 +43,6 @@ export class ViewUsersPage {
async userExists(email: string): Promise<boolean> {
try {
console.log('Checking the user with email', email);
// Wait for the table to appear and contain at least one row
await this.page.waitForFunction(() => document.querySelectorAll('tr').length > 0, { timeout: 10000 });

View File

@ -3,56 +3,63 @@ import { initialize_with_undefined_values, setCredentialValues } from "../steps"
export class ViewCredentialPage {
readonly page: Page
readonly primaryTitle: Locator
readonly secondaryTitle: Locator
readonly page: Page
readonly primaryTitle: Locator
readonly secondaryTitle: Locator
constructor(page: Page) {
this.page = page;
this.primaryTitle = page.getByRole('heading', { name: 'My wallet' });
this.secondaryTitle = page.getByRole('heading', { name: ' Credential' });
constructor(page: Page) {
this.page = page;
this.primaryTitle = page.getByRole('heading', { name: 'My wallet' });
this.secondaryTitle = page.getByRole('heading', { name: ' Credential' });
}
async getPrimaryTitle() {
try {
return await this.primaryTitle.innerText();
} catch (error) {
console.error("Failed to get primary title:", error);
throw error;
}
async getPrimaryTitle() {
try {
return await this.primaryTitle.innerText();
} catch (error) {
console.error("Failed to get primary title:", error);
throw error;
}
}
async getSecondaryTitle() {
try {
return await this.secondaryTitle.innerText();
} catch (error) {
console.error("Failed to get secondary title:", error);
throw error;
}
async getSecondaryTitle() {
try {
return await this.secondaryTitle.innerText();
} catch (error) {
console.error("Failed to get secondary title:", error);
throw error;
}
}
async buildACredentialFromInputValues(credentialType: string) {
try {
const elementsWithLabel = await this.page.locator('.col-3 strong').all();
const elementsWithValue = await this.page.locator('.col.bg-light.text-secondary').all();
let credential = initialize_with_undefined_values(credentialType);
let labels: string[] = [];
let values: string[] = [];
for (let i = 0; i < elementsWithLabel.length; i++) {
let label = await elementsWithLabel[i].textContent()
if (label) label = label.trim().replace(/:$/, '');
let value = await elementsWithValue[i].textContent()
if (value) value = value.trim();
if (value != null && label != null && label != 'Id' && label != "Issuance date" && label != "Status") {
labels.push(label);
values.push(value);
}
}
async buildACredentialFromInputValues(credentialType: string) {
const elementsWithLabel = await this.page.locator('.col-3 strong').all();
const elementsWithValue = await this.page.locator('.col.bg-light.text-secondary').all();
let credential = initialize_with_undefined_values(credentialType);
let labels: string[] = [];
let values: string[] = [];
for (let i = 0; i < elementsWithLabel.length; i++) {
let label = await elementsWithLabel[i].textContent()
if (label) label = label.trim().replace(/:$/, '');
let value = await elementsWithValue[i].textContent()
if (value) value = value.trim();
if (value != null && label != null && label != 'Id' && label != "Issuance date" && label != "Status") {
labels.push(label);
values.push(value);
}
}
credential = setCredentialValues(labels, values, credentialType);
return credential;
credential = setCredentialValues(labels, values, credentialType);
return credential;
} catch (error) {
console.error("Failed to build the credential from input values:", error);
throw error;
}
}//end function
}

View File

@ -1,10 +1,9 @@
import { expect, Page } from '@playwright/test'
import { appendRandomNumberToFilename, copyFile } from './utils'
import { appendRandomNumberToFilename, copyFile, deleteFile } from './utils'
import { CREDENTIAL_TYPE_DATASTORE_UNDEFINED, CREDENTIAL_TYPES_DATA_STORE } from './data_stores/credentials_data_store'
import { FinancialVulnerabilityCredential_fields } from './interfaces/credential_interfaces'
import { CREDENTIAL_TYPES_FIELDS_LIST, CREDENTIAL_TYPES_REQUIRED_FIELDS_LIST } from './constants/credential_fields'
import { CREDENTIAL_TYPES_FIELDS_LIST} from './constants/credential_fields'
import { LogInPage } from './page-objects/COMM_LoginPage'
import { ADMIN_EMAIL, ADMIN_K, ENCRYPTION_KEY, USER_K } from './constants/env_constants'
import { LeftMenuAdminPage } from './page-objects/AD_LeftMenuAdminPage'
@ -18,6 +17,9 @@ import { ViewImportedDataPage } from './page-objects/AD_ViewImportedDataPage'
import { User } from './interfaces/User'
import { EncryptionKeyPage } from './page-objects/AD_EncryptionKeyPage'
import { DataProtectionPage } from './page-objects/COMM_DataProtectionPage'
import { ImportDataPage } from './page-objects/AD_ImportDataPage'
import { PATH_FILES_TO_IMPORT } from './constants/constants'
import { fail } from 'assert'
export async function loginAsAdmin(page: Page, url: string) {
@ -30,7 +32,6 @@ export async function loginAsAdmin(page: Page, url: string) {
await loginPage.login(ADMIN_EMAIL, ADMIN_K);
let currentTitle = await page.title();
console.log("current title: ", currentTitle);
if (currentTitle === 'Encryption Key IdHub') {
//code to set Encription Key
@ -253,7 +254,6 @@ export async function gotoViewEnabledCredential(page: Page, credentialType: stri
}
export async function checkIfTheInformationIsValid(page: Page, user: User) {
console.log(user.firstName, "membership: ", user.membershipType, "sd: ", user.startDate)
const userPersonalInformationPage = new UserPersonalInformationPage(page)
try {
@ -264,16 +264,17 @@ export async function checkIfTheInformationIsValid(page: Page, user: User) {
}
export function expectedCredentialSubjectForUser<T extends FinancialVulnerabilityCredential_fields, MembershipCard_fields>(email: string, credentialType: string): FinancialVulnerabilityCredential_fields | MembershipCard_fields | undefined {
export function expectedCredentialSubjectForUser(email: string, credentialType: string){
//export function expectedCredentialSubjectForUser<T extends FinancialVulnerabilityCredential_fields, MembershipCard_fields, NGOFederationMembership_fields>(email: string, credentialType: string): FinancialVulnerabilityCredential_fields | MembershipCard_fields | NGOFederationMembership_fields | undefined {
try {
const testingDataForCredential = CREDENTIAL_TYPES_DATA_STORE[credentialType + '_data'] as T[];
const testingDataForCredential = CREDENTIAL_TYPES_DATA_STORE[credentialType + '_data'];
if (!testingDataForCredential) {
console.error(`No testing data found for credential type: ${credentialType}`);
return undefined;
}
console.log("testing Data: ", testingDataForCredential);
let credentialSubject = testingDataForCredential.find(user => user.email.toLowerCase() === email.toLowerCase());
return credentialSubject;
} catch (error) {
@ -324,20 +325,19 @@ export async function loadIfJsonSchemaNotAvailable(page: Page, jsonSchema: strin
}
export function setCredentialValues(labels: string[], values: string[], credentialType: string): any {
// Get the interface type associated with the credentialType
try {
const listOfFields = CREDENTIAL_TYPES_FIELDS_LIST[credentialType];
const listOfRequiredFields = CREDENTIAL_TYPES_REQUIRED_FIELDS_LIST[credentialType];
// Initialize an empty object to store the credential
let credential: any = {};
try {
// Iterate over labels and values
for (let i = 0; i < labels.length; i++) {
let label = labels[i];
let value = values[i];
// Check if the label exists in the interface type
// Check if the label exists in the list of fields
label = label.charAt(0).toLowerCase() + label.slice(1);
if (listOfFields.includes(label)) {
credential[label] = value;
@ -355,4 +355,103 @@ export function setCredentialValues(labels: string[], values: string[], credenti
export function initialize_with_undefined_values(credentialType: string) {
return (CREDENTIAL_TYPE_DATASTORE_UNDEFINED[credentialType + '_data_undefined'])
}
}
/* Load of an excel file - Happy Path:
* Check if file was loaded before. If yes, copy the original file (ie., financial-vulnerability-credential.xlxs) with a new valid with a random name
* If the template schema (associated with the type of credential to be enabled) is not available, import it and verify the operation
* Load the associated data file (xls) and check that appears in the list of imported data files
* Expected behavior: the file is loaded, the message:"The file was imported successfully!" is displayed,
* and the file appears in the imported files view.
*/
export async function testImportDataFile_HappyPath(page: Page, fileToImport: string, jsonSchema: string, schema: string) {
const viewImportedDataPage = new ViewImportedDataPage(page);
const importDataPage = new ImportDataPage(page);
await clickDataOnLeftMenu(page);
// If a file with a FILE_TO_IMPORT was previouly loaded, rename it
let fileName = fileToImport;
fileName = await checkFileName(page, fileName);
// Check if the json schema associated with the file is loaded to be used
// If not, load it in templates
await loadIfJsonSchemaNotAvailable(page, jsonSchema);
//Go to the Data option on leftmenu
await clickDataOnLeftMenu(page);
//Select the import button and go to the import data page
await viewImportedDataPage.gotoImportDataPage();
//Import excel file to enable a 'Financial vulnerability credential'for testing users
await importDataPage.importFile(schema, PATH_FILES_TO_IMPORT + fileName, "Default");
let actual = await viewImportedDataPage.alertFileImportedSuccessfully();
//Rename the default excel file with the original name FILE_TO_IMPORT in the directoy PATH_FILES_TO_IMPORT
if (fileName != fileToImport) {
await deleteFile(fileName);
}
if (actual) {
//Check if the file is in the list of imported files sucessfully
await clickDataOnLeftMenu(page);
await page.getByRole('link', { name: 'Date' }).click();
await page.getByRole('link', { name: 'Date' }).click();
expect(await viewImportedDataPage.fileIsAvailableInView(fileName)).toBeTruthy();
expect(await viewImportedDataPage.isFileSuccessfullyLoaded(fileName)).toBeTruthy();
} else {
console.log("Unexpected result loading the file. Test failed.")
fail();
}
}
/**
* Load of an excel file - Sad Path:
* Check if file was loaded before. If yes, copy the original to the new one with random name.
* If the template schema (associated with the type of credential to be enabled) is not available, import it and verify the operation
*/
export async function testImportDataFile_SadPath(page: Page, fileToImport: string, jsonSchema: string, schema: string, unsuccessAlertMessage: string) {
const viewImportedDataPage = new ViewImportedDataPage(page);
const importDataPage = new ImportDataPage(page);
await clickDataOnLeftMenu(page);
// If a file with a FILE_TO_IMPORT was previously loaded, rename it
let fileName = await checkFileName(page, fileToImport);
// Check if the json schema associated with the file is loaded to be used
// If not, load it in templates
await loadIfJsonSchemaNotAvailable(page, jsonSchema);
//Go to the Data option on leftmenu
await clickDataOnLeftMenu(page);
//Select the import button and go to the import data page
await viewImportedDataPage.gotoImportDataPage();
//Import excel file to enable a 'Financial vulnerability credential'. The file has no data.
await importDataPage.importFile(schema, PATH_FILES_TO_IMPORT + fileName, "Default");
let actual = await importDataPage.alertFileImportedUnsuccessfully(unsuccessAlertMessage);
//Rename the default excel file with the original name FILE_TO_IMPORT in the directoy PATH_FILES_TO_IMPORT
if (fileName != fileToImport) {
await deleteFile(fileName);
}
if (actual) {
//Check if the file is in the list of imported files as failed
await clickDataOnLeftMenu(page);
await page.getByRole('link', { name: 'Date' }).click();
await page.getByRole('link', { name: 'Date' }).click();
expect(await viewImportedDataPage.fileIsAvailableInView(fileName)).toBeTruthy();
expect(await viewImportedDataPage.isFileSuccessfullyLoaded(fileName)).toBeFalsy();
} else {
console.log("Unexpected result loading an empty file. Test failed.");
fail();
}
}

View File

@ -14,6 +14,10 @@ test.describe('Leftside Menu navigation test', () => {
test.beforeEach(async ({ page }) => {
await loginAsAdmin(page, URL_IDHUB);
})
test.afterEach(async ({ page }) => { //este se ejecutará despues de cada test
await page.click('.logout');
await page.close();
})
test('LEFTMENU -> Dashboard', async ({ page }) => {
await clickDashboardOnLeftMenu(page)

View File

@ -5,7 +5,7 @@ import { ViewUsersPage } from '../src/page-objects/AD_ViewUsersPage'
import { AddMembershipPage } from '../src/page-objects/AD_AddMembershipPage'
import { UserPersonalInformationPage } from '../src/page-objects/AD_UserPersonalInformationPage'
import { MembershipSectionPage } from '../src/page-objects/AD_MembershipSectionPage'
import { testingUsers, users } from '../src/data_stores/usersDataInitialization'
import { testingUsers, users } from '../src/data_stores/users_data_store'
import { createUsersRandomList } from '../src/utils'
import { URL_IDHUB } from '../src/constants/env_constants'
import { checkIfTheInformationIsValid, clickAddUserOnLeftMenu, clickViewUsersOnLeftMenu, gotoBasicInfoPageOfTheUser, loginAsAdmin } from '../src/steps'
@ -21,6 +21,10 @@ test.describe('USER Section Tests', () => {
await loginAsAdmin(page, URL_IDHUB);
(await leftMenu.getUsersLink()).click()
})
test.afterEach(async ({ page }) => { //este se ejecutará despues de cada test
await page.click('.logout');
await page.close();
})
/**
* UPDATE the basic data for default testing users user1..user5
*/

View File

@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test'
import { TemplatesPage } from '../src/page-objects/AD_TemplatesPage'
import { clickTemplatesOnLeftMenu, loadIfJsonSchemaNotAvailable, loginAsAdmin } from '../src/steps';
import { URL_IDHUB } from '../src/constants/env_constants';
import { URL_IDHUB, URL_SCHEMAS } from '../src/constants/env_constants';
import { JSON_SCHEMA_FVC, JSON_SCHEMA_ID_FVC } from '../src/constants/constants';
/**
@ -12,6 +12,10 @@ test.describe('TEMPLATES Section Tests ', () => {
test.beforeEach(async ({ page }) => { //este se ejecutará antes de cada test
await loginAsAdmin(page, URL_IDHUB);
})
test.afterEach(async ({ page }) => { //este se ejecutará despues de cada test
await page.click('.logout');
await page.close();
})
/**
* For every row in the templates view,
@ -41,6 +45,8 @@ test.describe('TEMPLATES Section Tests ', () => {
const jsonContent = await page.evaluate(() => JSON.parse(document.body.innerText));
// Check if the JSON elements exist
expect(jsonContent["$id"]).toBe(JSON_SCHEMA_ID_FVC);
await page.goto(URL_SCHEMAS);
})
/**

View File

@ -1,214 +1,102 @@
import { test, expect } from '@playwright/test'
import { ViewImportedDataPage } from '../src/page-objects/AD_ViewImportedDataPage'
import { ImportDataPage } from '../src/page-objects/AD_ImportDataPage'
import { checkFileName, clickDataOnLeftMenu, loadIfJsonSchemaNotAvailable, loginAsAdmin, loginAsUser, gotoViewEnabledCredential, expectedCredentialSubjectForUser } from '../src/steps';
import { test, expect} from '@playwright/test'
import { loginAsAdmin, loginAsUser, gotoViewEnabledCredential, expectedCredentialSubjectForUser, testImportDataFile_SadPath, testImportDataFile_HappyPath } from '../src/steps';
import { ViewCredentialPage } from '../src/page-objects/US_ViewCredentialPage.js'
import { fail } from 'assert'
import { URL_IDHUB, USER1_EMAIL, USER2_EMAIL } from '../src/constants/env_constants';
import { ALERT_FILE_TO_IMPORT_IS_EMPTY, ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS, ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS, FILE_TO_IMPORT_FVC, FILE_TO_IMPORT_FVC_EMPTY, FILE_TO_IMPORT_FVC_WITHOUT_REQUIRED_COLUMNS, FILE_TO_IMPORT_FVC_WITH_ALIEN_COLUMNS, JSON_SCHEMA_FVC, PATH_FILES_TO_IMPORT, SCHEMA_FVC, SCHEMA_TYPE_FVC } from '../src/constants/constants';
import { deleteFile } from '../src/utils';
import { URL_IDHUB, USER1_EMAIL } from '../src/constants/env_constants';
import { ALERT_FILE_TO_IMPORT_IS_EMPTY, ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS, ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS, ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY, FILE_TO_IMPORT_FVC, FILE_TO_IMPORT_FVC_EMPTY, FILE_TO_IMPORT_FVC_WITHOUT_REQUIRED_COLUMNS, FILE_TO_IMPORT_FVC_WITH_ALIEN_COLUMNS, FILE_TO_IMPORT_FVC_WITH_REQUIRED_EMPTY, JSON_SCHEMA_FVC, SCHEMA_FVC, SCHEMA_TYPE_FVC } from '../src/constants/constants';
/**
* Checking data section: view the lists of files imported, import data, delete...
* Checking Admin Data Section: view the lists of files imported, import data, ...
*/
test.describe('ADMIN-> DATA Section Tests - Testing with Financial Vulnerability Credential', () => {
test.beforeEach(async ({ page }) => { //este se ejecutará antes de cada test
test.beforeEach(async ({ page }) => {
await loginAsAdmin(page, URL_IDHUB);
})
test.afterEach(async ({ page }) => {
await page.click('.logout');
await page.close();
})
/**
* Load of an excel file - Happy Path:
* Check if file was loaded before. If yes, copy the original file (financial-vulnerability-credential.xlxs) to a new valid with random name
* If the template schema (associated with the type of credential to be enabled) is not available, import it and verify the operation
* Load the associated data file (xls) and check that appears in the list of imported data files
* Load an excel file - Happy Path
* Expected behavior: the file is loaded, the message:"The file was imported successfully!" is displayed,
* and the file appears in the imported files view.
*/
test('DATA -> Import data file - Happy path - Financial Vulnerability Credential ', async ({ page }) => {
const viewImportedDataPage = new ViewImportedDataPage(page);
const importDataPage = new ImportDataPage(page);
const fileToImport = FILE_TO_IMPORT_FVC;
const jsonSchema = JSON_SCHEMA_FVC;
const schema = SCHEMA_FVC;
await clickDataOnLeftMenu(page);
// If a file with a FILE_TO_IMPORT was previouly loaded, rename it
let fileName = FILE_TO_IMPORT_FVC;
fileName = await checkFileName(page, fileName);
// Check if the json schema associated with the file is loaded to be used
// If not, load it in templates
await loadIfJsonSchemaNotAvailable(page, JSON_SCHEMA_FVC);
//Go to the Data option on leftmenu
await clickDataOnLeftMenu(page);
//Select the import button and go to the import data page
await viewImportedDataPage.gotoImportDataPage();
//Import excel file to enable a 'Financial vulnerability credential'for testing users
console.log("File to import: ", fileName, " with schema: ", SCHEMA_FVC);
await importDataPage.importFile(SCHEMA_FVC, PATH_FILES_TO_IMPORT + fileName, "Default");
let actual = await viewImportedDataPage.alertFileImportedSuccessfully();
//Rename the default excel file with the original name FILE_TO_IMPORT in the directoy PATH_FILES_TO_IMPORT
if (fileName != FILE_TO_IMPORT_FVC) {
await deleteFile(fileName);
}
if (actual) {
//Check if the file is in the list of imported files sucessfully
await clickDataOnLeftMenu(page);
await page.getByRole('link', { name: 'Date' }).click();
await page.getByRole('link', { name: 'Date' }).click();
expect(await viewImportedDataPage.fileIsAvailableInView(fileName)).toBeTruthy();
expect(await viewImportedDataPage.isFileSuccessfullyLoaded(fileName)).toBeTruthy();
} else {
console.log("Unexpected result loading the file. Test failed.")
fail();
}
await testImportDataFile_HappyPath(page, fileToImport, jsonSchema, schema);
});
/**
* Load of an excel file - Sad Path:
* Check if file was loaded before. If yes, copy the original to the new one with random name.
* If the template schema (associated with the type of credential to be enabled) is not available, import it and verify the operation
/**
* Load an excel file - Sad Path:
* Try to load a well-formatted excel file but without data.
* Expected behavior: The error message: "The file you try to import is empty"
*/
test('DATA -> Import data file - Sad path (file well formatted but empty) - Financial Vulnerability Credential ', async ({ page }) => {
const viewImportedDataPage = new ViewImportedDataPage(page);
const importDataPage = new ImportDataPage(page);
const fileToImport = FILE_TO_IMPORT_FVC_EMPTY;
const jsonSchema = JSON_SCHEMA_FVC;
const schema = SCHEMA_FVC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_IS_EMPTY;
await clickDataOnLeftMenu(page);
// If a file with a FILE_TO_IMPORT was previously loaded, rename it
let fileName = await checkFileName(page, FILE_TO_IMPORT_FVC_EMPTY);
// Check if the json schema associated with the file is loaded to be used
// If not, load it in templates
await loadIfJsonSchemaNotAvailable(page, JSON_SCHEMA_FVC);
//Go to the Data option on leftmenu
await clickDataOnLeftMenu(page);
//Select the import button and go to the import data page
await viewImportedDataPage.gotoImportDataPage();
//Import excel file to enable a 'Financial vulnerability credential'. The file has no data.
console.log("File to import: ", fileName, " with schema: ", SCHEMA_FVC);
await importDataPage.importFile(SCHEMA_FVC, PATH_FILES_TO_IMPORT + fileName, "Default");
let actual = await importDataPage.alertFileImportedUnsuccessfully(ALERT_FILE_TO_IMPORT_IS_EMPTY);
//Rename the default excel file with the original name FILE_TO_IMPORT in the directoy PATH_FILES_TO_IMPORT
if (fileName != FILE_TO_IMPORT_FVC_EMPTY) {
await deleteFile(fileName);
}
if (actual) {
//Check if the file is in the list of imported files as failed
await clickDataOnLeftMenu(page);
await page.getByRole('link', { name: 'Date' }).click();
await page.getByRole('link', { name: 'Date' }).click();
expect(await viewImportedDataPage.fileIsAvailableInView(fileName)).toBeTruthy();
expect(await viewImportedDataPage.isFileSuccessfullyLoaded(fileName)).toBeFalsy();
} else {
console.log("Unexpected result loading an empty file. Test failed.");
fail();
}
});
test('DATA -> Import data file - Sad path (file bad formatted, without required columns) - Financial Vulnerability Credential ', async ({ page }) => {
const viewImportedDataPage = new ViewImportedDataPage(page);
const importDataPage = new ImportDataPage(page);
await clickDataOnLeftMenu(page);
// If a file with a FILE_TO_IMPORT was previously loaded, rename it
let fileName = await checkFileName(page, FILE_TO_IMPORT_FVC_WITHOUT_REQUIRED_COLUMNS);
// Check if the json schema associated with the file is loaded to be used
// If not, load it in templates
await loadIfJsonSchemaNotAvailable(page, JSON_SCHEMA_FVC);
//Go to the Data option on leftmenu
await clickDataOnLeftMenu(page);
//Select the import button and go to the import data page
await viewImportedDataPage.gotoImportDataPage();
//Import excel file to enable a 'Financial vulnerability credential'. The file has no data.
console.log("File to import: ", fileName, " with schema: ", SCHEMA_FVC);
await importDataPage.importFile(SCHEMA_FVC, PATH_FILES_TO_IMPORT + fileName, "Default");
let actual = await importDataPage.alertFileImportedUnsuccessfully(ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS);
//Rename the default excel file with the original name FILE_TO_IMPORT in the directoy PATH_FILES_TO_IMPORT
if (fileName != FILE_TO_IMPORT_FVC_WITHOUT_REQUIRED_COLUMNS) {
await deleteFile(fileName);
}
if (actual) {
//Check if the file is in the list of imported files as failed
await clickDataOnLeftMenu(page);
await page.getByRole('link', { name: 'Date' }).click();
await page.getByRole('link', { name: 'Date' }).click();
expect(await viewImportedDataPage.fileIsAvailableInView(fileName)).toBeTruthy();
expect(await viewImportedDataPage.isFileSuccessfullyLoaded(fileName)).toBeFalsy();
} else {
console.log("Unexpected result loading an empty file. Test failed.");
fail();
}
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (file bad formatted, with alien columns) - Financial Vulnerability Credential ', async ({ page }) => {
/**
* Load an excel file - Sad Path:
* Try to load a bad formatted file, without required data.
*/
const viewImportedDataPage = new ViewImportedDataPage(page);
const importDataPage = new ImportDataPage(page);
test('DATA -> Import data file - Sad path (bad formatted file, without required columns) - Financial Vulnerability Credential ', async ({ page }) => {
await clickDataOnLeftMenu(page);
const fileToImport = FILE_TO_IMPORT_FVC_WITHOUT_REQUIRED_COLUMNS;
const jsonSchema = JSON_SCHEMA_FVC;
const schema = SCHEMA_FVC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS;
// If a file with a FILE_TO_IMPORT was previously loaded, rename it
let fileName = await checkFileName(page, FILE_TO_IMPORT_FVC_WITH_ALIEN_COLUMNS);
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
// Check if the json schema associated with the file is loaded to be used
// If not, load it in templates
await loadIfJsonSchemaNotAvailable(page, JSON_SCHEMA_FVC);
});
//Go to the Data option on leftmenu
await clickDataOnLeftMenu(page);
/**
* Load an excel file - Sad Path:
* Try to load a bad formatted file, with alien columns.
* Expected behavior: The error message: "line 2: Additional properties are not allowed ('alien1', 'alien2' were unexpected)"
*/
//Select the import button and go to the import data page
await viewImportedDataPage.gotoImportDataPage();
test('DATA -> Import data file - Sad path (bad formatted file, with alien columns) - Financial Vulnerability Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_FVC_WITH_ALIEN_COLUMNS;
const jsonSchema = JSON_SCHEMA_FVC;
const schema = SCHEMA_FVC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS;
//Import excel file to enable a 'Financial vulnerability credential'. The file has no data.
console.log("File to import: ", fileName, " with schema: ", SCHEMA_FVC);
await importDataPage.importFile(SCHEMA_FVC, PATH_FILES_TO_IMPORT + fileName, "Default");
let actual = await importDataPage.alertFileImportedUnsuccessfully(ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS);
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
//Rename the default excel file with the original name FILE_TO_IMPORT in the directoy PATH_FILES_TO_IMPORT
if (fileName != FILE_TO_IMPORT_FVC_WITH_ALIEN_COLUMNS) {
await deleteFile(fileName);
}
if (actual) {
//Check if the file is in the list of imported files as failed
await clickDataOnLeftMenu(page);
await page.getByRole('link', { name: 'Date' }).click();
await page.getByRole('link', { name: 'Date' }).click();
});
expect(await viewImportedDataPage.fileIsAvailableInView(fileName)).toBeTruthy();
expect(await viewImportedDataPage.isFileSuccessfullyLoaded(fileName)).toBeFalsy();
} else {
console.log("Unexpected result loading an empty file. Test failed.");
fail();
}
/**
* Load an excel file - Sad Path:
* Try to load a file bad formatted, with alien columns.
* Expected behavior: The error message: "line 3: 'firstName' is a required property"
*/
test('DATA -> Import data file - Sad path (file with required columns present but empty) - Financial Vulnerability Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_FVC_WITH_REQUIRED_EMPTY;
const jsonSchema = JSON_SCHEMA_FVC;
const schema = SCHEMA_FVC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
@ -216,9 +104,14 @@ test.describe('ADMIN-> DATA Section Tests - Testing with Financial Vulnerability
test.describe('USER -> Credentials Section Tests - testing with USER1_EMAIL AND FINANCIAL VULNERABILITY CRED', () => {
test.beforeEach(async ({ page }) => { //este se ejecutará antes de cada test
test.beforeEach(async ({ page }) => {
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
})
test.afterEach(async ({ page }) => {
await page.click('.logout');
await page.close();
})
/**
* PRE-CONDITIONS: the admin has enabled a credential of type 'Financial Vulnerabitity' for USER1_EMAIL
@ -234,12 +127,11 @@ test.describe('USER -> Credentials Section Tests - testing with USER1_EMAIL AND
const enabledCredentialView = new ViewCredentialPage(page);
//Check that required fields exist and have a valid value in the current enabled credential
//Get the credential subject values of the credential visualized in the screen and compare to the model
//Get the credential subject values of the credential visualized on the screen and compare to the model
let actualCredential = await enabledCredentialView.buildACredentialFromInputValues(SCHEMA_TYPE_FVC);
let expectedCredential = await expectedCredentialSubjectForUser(USER1_EMAIL, SCHEMA_TYPE_FVC);
expect(actualCredential).toEqual(expectedCredential);
});
}) //end describe
})

View File

@ -0,0 +1,140 @@
import { test, expect } from '@playwright/test'
import { ViewCredentialPage } from '../src/page-objects/US_ViewCredentialPage.js'
import { URL_IDHUB, USER1_EMAIL, USER2_EMAIL } from '../src/constants/env_constants';
import { ALERT_FILE_TO_IMPORT_IS_EMPTY, ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_MC, ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS, ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY, FILE_TO_IMPORT_MC, FILE_TO_IMPORT_MC_2, FILE_TO_IMPORT_MC_EMPTY, FILE_TO_IMPORT_MC_WITHOUT_REQUIRED_COLUMNS, FILE_TO_IMPORT_MC_WITH_ALIEN_COLUMNS, FILE_TO_IMPORT_MC_WITH_REQUIRED_EMPTY, JSON_SCHEMA_MC, SCHEMA_MC, SCHEMA_TYPE_MC } from '../src/constants/constants';
import { expectedCredentialSubjectForUser, gotoViewEnabledCredential, loginAsAdmin, loginAsUser, testImportDataFile_HappyPath, testImportDataFile_SadPath } from '../src/steps.js';
/**
* Checking data section: view the lists of files imported, import data, delete...
*/
test.describe('ADMIN-> DATA Section Tests - Testing with Membership Credential', () => {
test.beforeEach(async ({ page }) => {
await loginAsAdmin(page, URL_IDHUB);
})
test.afterEach(async ({ page }) => {
await page.click('.logout');
await page.close();
})
/**
* Load of an excel file - Happy Path:
* Expected behavior: the file is loaded, the message:"The file was imported successfully!" is displayed,
* and the file appears in the imported files view.
*/
test('DATA -> Import data file - Happy path - Membership Card Credential - membership_card.xlsx ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_MC;
const jsonSchema = JSON_SCHEMA_MC;
const schema = SCHEMA_MC;
await testImportDataFile_HappyPath(page, fileToImport, jsonSchema, schema);
});
test('DATA -> Import data file - Happy path - Membership Card Credential - membership_card2.xlsx ', async ({ page }) => {
//test with a second excel file
const fileToImport = FILE_TO_IMPORT_MC_2;
const jsonSchema = JSON_SCHEMA_MC;
const schema = SCHEMA_MC;
await testImportDataFile_HappyPath(page, fileToImport, jsonSchema, schema);
});
/**
* Load of an excel file - Sad Path:
* Try to load a well-formatted excel file but without data.
* Expected behavior: The error message: "The file you try to import is empty"
*/
test('DATA -> Import data file - Sad path (file well formatted but empty) - Membership Card Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_MC_EMPTY;
const jsonSchema = JSON_SCHEMA_MC;
const schema = SCHEMA_MC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_IS_EMPTY;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (bad formatted file, without required columns) - Membership Card Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_MC_WITHOUT_REQUIRED_COLUMNS;
const jsonSchema = JSON_SCHEMA_MC;
const schema = SCHEMA_MC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_MC;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (bad formatted file, with alien columns) - Membership Card Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_MC_WITH_ALIEN_COLUMNS;
const jsonSchema = JSON_SCHEMA_MC;
const schema = SCHEMA_MC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (file with required columns present but empty) - Membership Card Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_MC_WITH_REQUIRED_EMPTY;
const jsonSchema = JSON_SCHEMA_MC;
const schema = SCHEMA_MC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
})
test.describe('USER -> Credentials Section Tests - testing with USER1_EMAIL AND Membership Card Credential', () => {
test.afterEach(async ({ page }) => {
await page.click('.logout');
await page.close();
})
/**
* PRE-CONDITIONS: the admin has enabled a credential of type 'Membership Card' for USER1_EMAIL
* This is true, if the before test (DATA -> Import data- HAPPY PATH has been passed sucessfully)
* SUMMARY:
* - Check if the user1 can visualize the credentials that has been enabled in "My Credentials"
* - Check the fields displayed when user click "View" Credential
*/
test('USER Credentials -> My Credentials -> View enabled Membership Card - for user1@example.org', async ({ page }) => {
// View the Membership Card Credential in status 'Enabled' for the user
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
await gotoViewEnabledCredential(page, SCHEMA_TYPE_MC);
const enabledCredentialView = new ViewCredentialPage(page);
//Check that required fields exist and have a valid value in the current enabled credential
//Get the credential subject values of the credential visualized in the screen and compare to the model
let actualCredential = await enabledCredentialView.buildACredentialFromInputValues(SCHEMA_TYPE_MC);
let expectedCredential = await expectedCredentialSubjectForUser(USER1_EMAIL, SCHEMA_TYPE_MC);
expect(actualCredential).toEqual(expectedCredential);
});
test('USER Credentials -> My Credentials -> View enabled Membership Card - for user2@example.org', async ({ page }) => {
// View the Membership Card Credential in status 'Enabled' for the user
await loginAsUser(page, USER2_EMAIL, URL_IDHUB);
await gotoViewEnabledCredential(page, SCHEMA_TYPE_MC);
const enabledCredentialView = new ViewCredentialPage(page);
//Check that required fields exist and have a valid value in the current enabled credential
//Get the credential subject values of the credential visualized in the screen and compare to the model
let actualCredential = await enabledCredentialView.buildACredentialFromInputValues(SCHEMA_TYPE_MC);
let expectedCredential = await expectedCredentialSubjectForUser(USER2_EMAIL, SCHEMA_TYPE_MC);
expect(actualCredential).toEqual(expectedCredential);
});
})

View File

@ -0,0 +1,133 @@
import { test, expect } from '@playwright/test'
import { loginAsAdmin, loginAsUser, gotoViewEnabledCredential, expectedCredentialSubjectForUser, testImportDataFile_HappyPath, testImportDataFile_SadPath } from '../src/steps';
import { ViewCredentialPage } from '../src/page-objects/US_ViewCredentialPage.js'
import { URL_IDHUB, USER1_EMAIL, USER2_EMAIL } from '../src/constants/env_constants';
import { ALERT_FILE_TO_IMPORT_IS_EMPTY, ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_NGO_FM, ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS, ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY_NGO_FM, FILE_TO_IMPORT_NGO_FM, FILE_TO_IMPORT_NGO_FM_EMPTY, FILE_TO_IMPORT_NGO_FM_WITHOUT_REQUIRED_COLUMNS, FILE_TO_IMPORT_NGO_FM_WITH_ALIEN_COLUMNS, FILE_TO_IMPORT_NGO_FM_WITH_REQUIRED_EMPTY, JSON_SCHEMA_NGO_FM, SCHEMA_NGO_FM, SCHEMA_TYPE_NGO_FM } from '../src/constants/constants';
/**
* Checking data section: view the lists of files imported, import data, delete...
*/
test.describe('ADMIN-> DATA Section Tests - Testing with NGO Federation Membership', () => {
test.beforeEach(async ({ page }) => {
await loginAsAdmin(page, URL_IDHUB);
})
test.afterEach(async ({ page }) => {
await page.click('.logout');
await page.close();
})
/**
* Load an excel file - Happy Path
* Expected behavior: the file is loaded, the message:"The file was imported successfully!" is displayed,
* and the file appears in the imported files view.
*/
test('DATA -> Import data file - Happy path - NGO Federation Membership Credential - federation-membership.xlsx ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_NGO_FM;
const jsonSchema = JSON_SCHEMA_NGO_FM;
const schema = SCHEMA_NGO_FM;
await testImportDataFile_HappyPath(page, fileToImport, jsonSchema, schema);
});
/**
* Load an excel file - Sad Path:
* Try to load a well-formatted excel file but without data.
* Expected behavior: The error message: "The file you try to import is empty"
*/
test('DATA -> Import data file - Sad path (file well formatted but empty) - NGO Federation Membership Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_NGO_FM_EMPTY;
const jsonSchema = JSON_SCHEMA_NGO_FM;
const schema = SCHEMA_NGO_FM;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_IS_EMPTY;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (file bad formatted, without required columns) - NGO Federation Membership Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_NGO_FM_WITHOUT_REQUIRED_COLUMNS;
const jsonSchema = JSON_SCHEMA_NGO_FM;
const schema = SCHEMA_NGO_FM;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_NGO_FM;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (file bad formatted, with alien columns) - NGO Federation Membership Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_NGO_FM_WITH_ALIEN_COLUMNS;
const jsonSchema = JSON_SCHEMA_NGO_FM;
const schema = SCHEMA_NGO_FM;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (file with required columns present but empty) - NGO Federation Membership Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_NGO_FM_WITH_REQUIRED_EMPTY;
const jsonSchema = JSON_SCHEMA_NGO_FM;
const schema = SCHEMA_NGO_FM;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY_NGO_FM;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
}) //end describe
test.describe('USER -> Credentials Section Tests - testing with USER1_EMAIL AND NGO Federation Membership Credential', () => {
test.afterEach(async ({ page }) => { //este se ejecutará despues de cada test
await page.click('.logout');
await page.close();
})
/**
* PRE-CONDITIONS: the admin has enabled a credential of type 'NGO Federation Membership' for USER1_EMAIL
* This is true, if the before test (DATA -> Import data- HAPPY PATH has been passed sucessfully)
* SUMMARY:
* - Check if the user1 can visualize the credentials that has been enabled in "My Credentials"
* - Check the fields displayed when user click "View" Credential
*/
test('USER Credentials -> My Credentials -> View enabled NGO Federation Membership Credential - for user1@example.org', async ({ page }) => {
// View the NGO Federation Membership Credential in status 'Enabled' for the user
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
await gotoViewEnabledCredential(page, SCHEMA_TYPE_NGO_FM);
const enabledCredentialView = new ViewCredentialPage(page);
//Check that required fields exist and have a valid value in the current enabled credential
//Get the credential subject values of the credential visualized in the screen and compare to the model
let actualCredential = await enabledCredentialView.buildACredentialFromInputValues(SCHEMA_TYPE_NGO_FM);
let expectedCredential = await expectedCredentialSubjectForUser(USER1_EMAIL, SCHEMA_TYPE_NGO_FM);
expect(actualCredential).toEqual(expectedCredential);
});
test('USER Credentials -> My Credentials -> View enabled NGO Federation Membership Credential - for user2@example.org', async ({ page }) => {
// View the NGO Federation Membership Credential in status 'Enabled' for the user
await loginAsUser(page, USER2_EMAIL, URL_IDHUB);
await gotoViewEnabledCredential(page, SCHEMA_TYPE_NGO_FM);
const enabledCredentialView = new ViewCredentialPage(page);
//Check that required fields exist and have a valid value in the current enabled credential
//Get the credential subject values of the credential visualized in the screen and compare to the model
let actualCredential = await enabledCredentialView.buildACredentialFromInputValues(SCHEMA_TYPE_NGO_FM);
let expectedCredential = await expectedCredentialSubjectForUser(USER2_EMAIL, SCHEMA_TYPE_NGO_FM);
expect(actualCredential).toEqual(expectedCredential);
});
})

View File

@ -0,0 +1,133 @@
import { test, expect } from '@playwright/test'
import { loginAsAdmin, loginAsUser, gotoViewEnabledCredential, expectedCredentialSubjectForUser, testImportDataFile_HappyPath, testImportDataFile_SadPath } from '../src/steps';
import { ViewCredentialPage } from '../src/page-objects/US_ViewCredentialPage.js'
import { URL_IDHUB, USER1_EMAIL, USER2_EMAIL } from '../src/constants/env_constants';
import { ALERT_FILE_TO_IMPORT_IS_EMPTY, ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_CC, ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS, ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY, FILE_TO_IMPORT_CC, FILE_TO_IMPORT_CC_EMPTY, FILE_TO_IMPORT_CC_WITHOUT_REQUIRED_COLUMNS, FILE_TO_IMPORT_CC_WITH_ALIEN_COLUMNS, FILE_TO_IMPORT_CC_WITH_REQUIRED_EMPTY, JSON_SCHEMA_CC, SCHEMA_CC, SCHEMA_TYPE_CC } from '../src/constants/constants';
/**
* Checking data section: view the lists of files imported, import data, delete...
*/
test.describe('ADMIN-> DATA Section Tests - Testing with Course Credential', () => {
test.beforeEach(async ({ page }) => {
await loginAsAdmin(page, URL_IDHUB);
})
test.afterEach(async ({ page }) => {
await page.click('.logout');
await page.close();
})
/**
* Load of an excel file - Happy Path:
* Expected behavior: the file is loaded, the message:"The file was imported successfully!" is displayed,
* and the file appears in the imported files view.
*/
test('DATA -> Import data file - Happy path - Course Credential - course-credential.xlsx ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_CC;
const jsonSchema = JSON_SCHEMA_CC;
const schema = SCHEMA_CC;
await testImportDataFile_HappyPath(page, fileToImport, jsonSchema, schema);
});
/**
* Load of an excel file - Sad Path:
* Try to load a well-formatted excel file but without data.
* Expected behavior: The error message: "The file you try to import is empty"
*/
test('DATA -> Import data file - Sad path (file well formatted but empty) - Course Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_CC_EMPTY;
const jsonSchema = JSON_SCHEMA_CC;
const schema = SCHEMA_CC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_IS_EMPTY;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (bad formatted file, without required columns) - Course Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_CC_WITHOUT_REQUIRED_COLUMNS;
const jsonSchema = JSON_SCHEMA_CC;
const schema = SCHEMA_CC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_CC;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (bad formatted file, with alien columns) - Course Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_CC_WITH_ALIEN_COLUMNS;
const jsonSchema = JSON_SCHEMA_CC;
const schema = SCHEMA_CC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (file with required columns present but empty) - Course Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_CC_WITH_REQUIRED_EMPTY;
const jsonSchema = JSON_SCHEMA_CC;
const schema = SCHEMA_CC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
})
test.describe('USER -> Credentials Section Tests - testing with USER1_EMAIL AND Course Credential', () => {
test.afterEach(async ({ page }) => {
await page.click('.logout');
await page.close();
})
/**
* PRE-CONDITIONS: the admin has enabled a credential of type 'Course' for USER1_EMAIL
* This is true, if the before test (DATA -> Import data- HAPPY PATH has been passed sucessfully)
* SUMMARY:
* - Check if the user1 can visualize the credentials that has been enabled in "My Credentials"
* - Check the fields displayed when user click "View" Credential
*/
test('USER Credentials -> My Credentials -> View enabled Course Credential - for user1@example.org', async ({ page }) => {
// View the Course Credential in status 'Enabled' for the user
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
await gotoViewEnabledCredential(page, SCHEMA_TYPE_CC);
const enabledCredentialView = new ViewCredentialPage(page);
//Check that required fields exist and have a valid value in the current enabled credential
//Get the credential subject values of the credential visualized in the screen and compare to the model
let actualCredential = await enabledCredentialView.buildACredentialFromInputValues(SCHEMA_TYPE_CC);
let expectedCredential = await expectedCredentialSubjectForUser(USER1_EMAIL, SCHEMA_TYPE_CC);
expect(actualCredential).toEqual(expectedCredential);
});
test('USER Credentials -> My Credentials -> View enabled Course Credential - for user2@example.org', async ({ page }) => {
// View the Course Credential in status 'Enabled' for the user
await loginAsUser(page, USER2_EMAIL, URL_IDHUB);
await gotoViewEnabledCredential(page, SCHEMA_TYPE_CC);
const enabledCredentialView = new ViewCredentialPage(page);
//Check that required fields exist and have a valid value in the current enabled credential
//Get the credential subject values of the credential visualized in the screen and compare to the model
let actualCredential = await enabledCredentialView.buildACredentialFromInputValues(SCHEMA_TYPE_CC);
let expectedCredential = await expectedCredentialSubjectForUser(USER2_EMAIL, SCHEMA_TYPE_CC);
expect(actualCredential).toEqual(expectedCredential);
});
})

View File

@ -0,0 +1,136 @@
import { test, expect } from '@playwright/test'
import { loginAsAdmin, loginAsUser, gotoViewEnabledCredential, expectedCredentialSubjectForUser, testImportDataFile_HappyPath, testImportDataFile_SadPath } from '../src/steps';
import { ViewCredentialPage } from '../src/page-objects/US_ViewCredentialPage.js'
import { URL_IDHUB, USER1_EMAIL, USER2_EMAIL } from '../src/constants/env_constants';
import { ALERT_FILE_TO_IMPORT_IS_EMPTY, ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_EOC, ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS, ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY_EOC, FILE_TO_IMPORT_EOC, FILE_TO_IMPORT_EOC_EMPTY, FILE_TO_IMPORT_EOC_WITHOUT_REQUIRED_COLUMNS, FILE_TO_IMPORT_EOC_WITH_ALIEN_COLUMNS, FILE_TO_IMPORT_EOC_WITH_REQUIRED_EMPTY, JSON_SCHEMA_EOC, SCHEMA_EOC, SCHEMA_TYPE_EOC } from '../src/constants/constants';
/**
* Checking data section: view the lists of files imported, import data, delete...
*/
test.describe('ADMIN-> DATA Section Tests - Testing with E-Operator Claim Credential', () => {
test.beforeEach(async ({ page }) => {
await loginAsAdmin(page, URL_IDHUB);
})
test.afterEach(async ({ page }) => {
await page.click('.logout');
await page.close();
})
/**
* Load an excel file - Happy Path
* Expected behavior: the file is loaded, the message:"The file was imported successfully!" is displayed,
* and the file appears in the imported files view.
*/
test('DATA -> Import data file - Happy path - E-Operator Claim Credential - e-operator-claim.xlsx ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_EOC;
const jsonSchema = JSON_SCHEMA_EOC;
const schema = SCHEMA_EOC;
await testImportDataFile_HappyPath(page, fileToImport, jsonSchema, schema);
});
/**
* Load an excel file - Sad Path:
* Expected behavior: The error message: "The file you try to import is empty"
*/
test('DATA -> Import data file - Sad path (file well formatted but empty) - E-Operator Claim Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_EOC_EMPTY;
const jsonSchema = JSON_SCHEMA_EOC;
const schema = SCHEMA_EOC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_IS_EMPTY;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
/**
* Load an excel file - Sad Path:
* Try to load a bad formatted file, without required data.
*/
test('DATA -> Import data file - Sad path (bad formatted file, without required columns) - E-Operator Claim Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_EOC_WITHOUT_REQUIRED_COLUMNS;
const jsonSchema = JSON_SCHEMA_EOC;
const schema = SCHEMA_EOC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITHOUT_REQUIRED_COLUMS_EOC;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (file bad formatted, with alien columns) - E-Operator Claim Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_EOC_WITH_ALIEN_COLUMNS;
const jsonSchema = JSON_SCHEMA_EOC;
const schema = SCHEMA_EOC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITH_ALIEN_COLUMS;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
test('DATA -> Import data file - Sad path (file with required columns present but empty) - E-Operator Claim Credential ', async ({ page }) => {
const fileToImport = FILE_TO_IMPORT_EOC_WITH_REQUIRED_EMPTY;
const jsonSchema = JSON_SCHEMA_EOC;
const schema = SCHEMA_EOC;
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_WITH_REQUIRED_COLUMS_EMPTY_EOC;
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
});
})
test.describe('USER -> Credentials Section Tests - testing with USER1_EMAIL AND E-Operator Claim Credential', () => {
test.afterEach(async ({ page }) => { //este se ejecutará despues de cada test
await page.click('.logout');
await page.close();
})
/**
* PRE-CONDITIONS: the admin has enabled a credential of type 'E-Operator Claim' for USER1_EMAIL
* This is true, if the before test (DATA -> Import data- HAPPY PATH has been passed sucessfully)
* SUMMARY:
* - Check if the user1 can visualize the credentials that has been enabled in "My Credentials"
* - Check the fields displayed when user click "View" Credential
*/
test('USER Credentials -> My Credentials -> View enabled E-Operator Claim Credential - for user1@example.org' , async ({ page }) => {
// View the E-Operator Claim Credential in status 'Enabled' for the user
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
await gotoViewEnabledCredential(page, SCHEMA_TYPE_EOC);
const enabledCredentialView = new ViewCredentialPage(page);
//Check that required fields exist and have a valid value in the current enabled credential
//Get the credential subject values of the credential visualized in the screen and compare to the model
let actualCredential = await enabledCredentialView.buildACredentialFromInputValues(SCHEMA_TYPE_EOC);
let expectedCredential = await expectedCredentialSubjectForUser(USER1_EMAIL, SCHEMA_TYPE_EOC);
expect(actualCredential).toEqual(expectedCredential);
});
test('USER Credentials -> My Credentials -> View enabled E-Operator Claim Credential - for user2@example.org' , async ({ page }) => {
// View the E-Operator Claim Credential in status 'Enabled' for the user
await loginAsUser(page, USER2_EMAIL, URL_IDHUB);
await gotoViewEnabledCredential(page, SCHEMA_TYPE_EOC);
const enabledCredentialView = new ViewCredentialPage(page);
//Check that required fields exist and have a valid value in the current enabled credential
//Get the credential subject values of the credential visualized in the screen and compare to the model
let actualCredential = await enabledCredentialView.buildACredentialFromInputValues(SCHEMA_TYPE_EOC);
let expectedCredential = await expectedCredentialSubjectForUser(USER2_EMAIL, SCHEMA_TYPE_EOC);
expect(actualCredential).toEqual(expectedCredential);
});
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.