This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
IdHub_E2E_testing/tests/06-COMM-EnabledAndIssueNGO_...

134 lines
5.4 KiB
TypeScript

import { test} from '@playwright/test'
import { loginAsAdmin, loginAsUser, testImportDataFile_HappyPath, testImportDataFile_SadPath, test_RequestAndCheckIssuedCredentialByUser, test_ViewAndCheckEnabledCredentialbyUser } from '../src/steps';
import { URL_IDHUB, USER1_EMAIL, USER2_EMAIL, USER3_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';
/**
* Testing Admin->Data Section functionality with the NGO Federation Membership Credential (NGO_FM)
*/
test.describe('ADMIN-> DATA -> Import NGO_FM excel files', () => {
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.
* - the file appears in the imported files view.
*/
test('DATA -> ADMIN-> DATA -> Import NGO_FM excel file - Happy Path', 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('ADMIN-> DATA -> Import NGO_FM excel file - Sad path (file well formatted but empty', 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('ADMIN-> DATA -> Import NGO excel file - Sad path (bad formatted file, without required columns', 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('ADMIN-> DATA -> Import NGO_FM excel file - Sad path (bad formatted file, with alien columns)', 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('ADMIN-> DATA -> Import NGO_FM excel file - Sad path (file with required columns present but empty)', 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 -> My Credentials - enable and issue credentials', () => {
test.afterEach(async ({ page }) => { //este se ejecutará despues de cada test
await page.click('.logout');
await page.close();
})
/**
* PRE-CONDITIONS: the admin has enabled sucessfully a credential in the previous test (DATA -> Import data- HAPPY PATH has been passed sucessfully)
* SUMMARY:
* - Check if the user can visualize the credentials that has been enabled in "My Credentials"
* - Check that the fields displayed in "View" Credential are the expected ones
*/
test('USER -> My Credentials -> View NGO_FM enabled Credential for user1', async ({ page }) => {
let schemaType = SCHEMA_TYPE_NGO_FM;
let user = USER1_EMAIL;
await loginAsUser(page, user, URL_IDHUB);
await test_ViewAndCheckEnabledCredentialbyUser(page, schemaType, user);
});
test('USER -> My Credentials -> View NGO_FM enabled Credential for user2', async ({ page }) => {
let schemaType = SCHEMA_TYPE_NGO_FM;
let user = USER2_EMAIL;
await loginAsUser(page, user, URL_IDHUB);
await test_ViewAndCheckEnabledCredentialbyUser(page, schemaType, user);
});
test.fixme('USER -> My Credentials -> Request the issuance of a NGO_FM for user2', async ({ page }) => {
let schemaType = SCHEMA_TYPE_NGO_FM;
let user = USER2_EMAIL;
await loginAsUser(page, user, URL_IDHUB);
await test_RequestAndCheckIssuedCredentialByUser(page, schemaType, user);
});
})