134 lines
6.5 KiB
TypeScript
134 lines
6.5 KiB
TypeScript
|
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);
|
||
|
});
|
||
|
|
||
|
})
|
||
|
|