2024-03-25 11:31:43 +00:00
|
|
|
import { test, expect} from '@playwright/test'
|
|
|
|
import { loginAsAdmin, loginAsUser, gotoViewEnabledCredential, expectedCredentialSubjectForUser, testImportDataFile_SadPath, testImportDataFile_HappyPath } from '../src/steps';
|
2024-03-04 19:57:54 +00:00
|
|
|
import { ViewCredentialPage } from '../src/page-objects/US_ViewCredentialPage.js'
|
2024-03-25 11:31:43 +00:00
|
|
|
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';
|
2024-03-04 19:57:54 +00:00
|
|
|
|
|
|
|
/**
|
2024-03-25 11:31:43 +00:00
|
|
|
* Checking Admin Data Section: view the lists of files imported, import data, ...
|
2024-03-04 19:57:54 +00:00
|
|
|
*/
|
|
|
|
|
2024-03-09 12:35:44 +00:00
|
|
|
test.describe('ADMIN-> DATA Section Tests - Testing with Financial Vulnerability Credential', () => {
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
test.beforeEach(async ({ page }) => {
|
2024-03-04 19:57:54 +00:00
|
|
|
await loginAsAdmin(page, URL_IDHUB);
|
|
|
|
})
|
2024-03-25 11:31:43 +00:00
|
|
|
test.afterEach(async ({ page }) => {
|
|
|
|
await page.click('.logout');
|
|
|
|
await page.close();
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
})
|
2024-03-04 19:57:54 +00:00
|
|
|
/**
|
2024-03-25 11:31:43 +00:00
|
|
|
* Load an excel file - Happy Path
|
2024-03-04 19:57:54 +00:00
|
|
|
* 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 }) => {
|
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
const fileToImport = FILE_TO_IMPORT_FVC;
|
|
|
|
const jsonSchema = JSON_SCHEMA_FVC;
|
|
|
|
const schema = SCHEMA_FVC;
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
await testImportDataFile_HappyPath(page, fileToImport, jsonSchema, schema);
|
2024-03-04 19:57:54 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
/**
|
|
|
|
* Load an excel file - Sad Path:
|
2024-03-04 19:57:54 +00:00
|
|
|
* 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 }) => {
|
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
const fileToImport = FILE_TO_IMPORT_FVC_EMPTY;
|
|
|
|
const jsonSchema = JSON_SCHEMA_FVC;
|
|
|
|
const schema = SCHEMA_FVC;
|
|
|
|
const unsuccessAlertMessage = ALERT_FILE_TO_IMPORT_IS_EMPTY;
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
});
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
/**
|
|
|
|
* Load an excel file - Sad Path:
|
|
|
|
* Try to load a bad formatted file, without required data.
|
|
|
|
*/
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
test('DATA -> Import data file - Sad path (bad formatted file, without required columns) - Financial Vulnerability Credential ', async ({ page }) => {
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
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;
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
|
2024-03-04 19:57:54 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
/**
|
|
|
|
* 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)"
|
|
|
|
*/
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
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;
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
});
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
/**
|
|
|
|
* 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"
|
|
|
|
*/
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
test('DATA -> Import data file - Sad path (file with required columns present but empty) - Financial Vulnerability Credential ', async ({ page }) => {
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
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;
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
await testImportDataFile_SadPath(page, fileToImport, jsonSchema, schema, unsuccessAlertMessage);
|
2024-03-04 19:57:54 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}) //end describe
|
|
|
|
|
2024-03-09 12:35:44 +00:00
|
|
|
test.describe('USER -> Credentials Section Tests - testing with USER1_EMAIL AND FINANCIAL VULNERABILITY CRED', () => {
|
2024-03-04 19:57:54 +00:00
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
test.beforeEach(async ({ page }) => {
|
2024-03-04 19:57:54 +00:00
|
|
|
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
|
|
|
|
})
|
2024-03-25 11:31:43 +00:00
|
|
|
test.afterEach(async ({ page }) => {
|
|
|
|
await page.click('.logout');
|
|
|
|
await page.close();
|
|
|
|
|
|
|
|
})
|
2024-03-04 19:57:54 +00:00
|
|
|
|
|
|
|
/**
|
2024-03-09 12:35:44 +00:00
|
|
|
* PRE-CONDITIONS: the admin has enabled a credential of type 'Financial Vulnerabitity' 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
|
2024-03-04 19:57:54 +00:00
|
|
|
*/
|
|
|
|
|
2024-03-08 18:13:55 +00:00
|
|
|
test('USER Credentials -> My Credentials -> View enabled Financial Vulnerability Credential', async ({ page }) => {
|
2024-03-04 19:57:54 +00:00
|
|
|
// View the Financial Vulnerabilty Credential in status 'Enabled' for the user
|
|
|
|
await gotoViewEnabledCredential(page, SCHEMA_TYPE_FVC);
|
|
|
|
const enabledCredentialView = new ViewCredentialPage(page);
|
|
|
|
//Check that required fields exist and have a valid value in the current enabled credential
|
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
//Get the credential subject values of the credential visualized on the screen and compare to the model
|
2024-03-04 19:57:54 +00:00
|
|
|
let actualCredential = await enabledCredentialView.buildACredentialFromInputValues(SCHEMA_TYPE_FVC);
|
|
|
|
let expectedCredential = await expectedCredentialSubjectForUser(USER1_EMAIL, SCHEMA_TYPE_FVC);
|
|
|
|
expect(actualCredential).toEqual(expectedCredential);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2024-03-25 11:31:43 +00:00
|
|
|
})
|