using DataProtectionPage in loginAsUser
This commit is contained in:
parent
e0771c1f3f
commit
3936eb29ce
12
src/steps.ts
12
src/steps.ts
|
@ -60,6 +60,8 @@ export async function loginAsUser(page: Page, userEmail: string, url: string) {
|
|||
|
||||
try {
|
||||
const loginPage = new LogInPage(page);
|
||||
const dataProtectionPage = new DataProtectionPage(page);
|
||||
|
||||
await loginPage.visit(url);
|
||||
await loginPage.login(userEmail, USER_K);
|
||||
|
||||
|
@ -67,10 +69,10 @@ export async function loginAsUser(page: Page, userEmail: string, url: string) {
|
|||
|
||||
if (currentTitle === 'Data Protection – IdHub') {
|
||||
// Code to accept terms and conditions
|
||||
await page.click('#id_accept_privacy');
|
||||
await page.click('#id_accept_legal');
|
||||
await page.click('#id_accept_cookies');
|
||||
await page.click('a[type="button"]');
|
||||
await dataProtectionPage.checkAcceptPrivacyCheckBox();
|
||||
await dataProtectionPage.checkAcceptCookiesCheckBox();
|
||||
await dataProtectionPage.checkAcceptLegalCheckBox();
|
||||
await dataProtectionPage.clickConfirmButton();
|
||||
}
|
||||
await expect(page).toHaveTitle('Dashboard – IdHub');
|
||||
} catch (error) {
|
||||
|
@ -240,7 +242,7 @@ export async function gotoBasicInfoPageOfTheUser(page: Page, user: User) {
|
|||
export async function gotoViewEnabledCredential(page: Page, credentialType: string) {
|
||||
const myCredentialsPage = new ViewMyCredentialsPage(page)
|
||||
|
||||
//Access the specific enabled credential
|
||||
//Access the specific enabled credential that is expected to be in the user wallet!
|
||||
const { myCredentialsLink } = await clickMyCredentialsOnLeftMenu(page);
|
||||
try {
|
||||
expect(await myCredentialsPage.enabledCredentialExistInMyCredentials(credentialType)).toBeTruthy();
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
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 { JSON_SCHEMA_FVC, JSON_SCHEMA_ID_FVC } from '../src/constants/constants';
|
||||
|
||||
/**
|
||||
* Checking template section: view the lists of templates, import schema, delete schema, view json
|
||||
*/
|
||||
test.describe('TEMPLATES Section Tests ', () => {
|
||||
|
||||
test.beforeEach(async ({ page }) => { //este se ejecutará antes de cada test
|
||||
await loginAsAdmin(page, URL_IDHUB);
|
||||
})
|
||||
|
||||
/**
|
||||
* For every row in the templates view,
|
||||
* extract the name of the template schema (second cell) and compare it against the
|
||||
* las element of the $id in the corresponding json file.
|
||||
*/
|
||||
|
||||
test('TEMPLATES -> View credential templates -> compare each template name against last element of $id in JSON', async ({ page }) => {
|
||||
// Navigate to the page with the table
|
||||
const templatesPage = new TemplatesPage(page);
|
||||
await clickTemplatesOnLeftMenu(page);
|
||||
expect(await templatesPage.checkSchemaNamesAgainstCorrespondingJSON(page)).toBeTruthy();
|
||||
})
|
||||
|
||||
/**
|
||||
* Check a specific template in the list of templates
|
||||
* If the template schema is not available, the schema is imported
|
||||
* Once the template schema is in the list, verify the element id in the json file
|
||||
*/
|
||||
test('TEMPLATES -> View schema/import for Financial Vulnerability Credential', async ({ page }) => {
|
||||
const templatesPage = new TemplatesPage(page);
|
||||
//Load the schema if it is not loaded
|
||||
await loadIfJsonSchemaNotAvailable(page, JSON_SCHEMA_FVC);
|
||||
|
||||
//validate $id in the json template
|
||||
await templatesPage.gotoViewSchemaPage(JSON_SCHEMA_FVC);
|
||||
const jsonContent = await page.evaluate(() => JSON.parse(document.body.innerText));
|
||||
// Check if the JSON elements exist
|
||||
expect(jsonContent["$id"]).toBe(JSON_SCHEMA_ID_FVC);
|
||||
})
|
||||
|
||||
/**
|
||||
* Check a specific template in the list of templates
|
||||
* If the template schema is not available, the schema is imported and verify the operation
|
||||
* Try to delete the schema, but cancel the operation
|
||||
* Try to delete the schema, confirm the operation and verify the operation
|
||||
*/
|
||||
test('TEMPLATES -> Delete schema', async ({ page }) => {
|
||||
//Access the specific template schema
|
||||
const templatesPage = new TemplatesPage(page);
|
||||
|
||||
//check if the schema is imported
|
||||
await loadIfJsonSchemaNotAvailable(page, JSON_SCHEMA_FVC);
|
||||
|
||||
/*Try to delete the schema and then cancel in the modal*/
|
||||
await templatesPage.gotoDeleteAndCancelInModal(JSON_SCHEMA_FVC);
|
||||
/*Verify the schema was imported*/
|
||||
expect(await templatesPage.schemaIsAvailableInView(JSON_SCHEMA_FVC)).toBeTruthy();
|
||||
|
||||
/*Try to delete the schema and then confirm the operation*/
|
||||
let wasDeleted = await templatesPage.gotoDeleteAndConfirmInModal(JSON_SCHEMA_FVC);
|
||||
|
||||
/*Verify the schema was deleted*/
|
||||
if (wasDeleted) {
|
||||
expect(await templatesPage.schemaIsAvailableInView(JSON_SCHEMA_FVC)).toBeFalsy();
|
||||
}
|
||||
})
|
||||
})
|
|
@ -1,86 +1,18 @@
|
|||
import { test, expect } from '@playwright/test'
|
||||
import { TemplatesPage } from '../src/page-objects/AD_TemplatesPage'
|
||||
import { ViewImportedDataPage } from '../src/page-objects/AD_ViewImportedDataPage'
|
||||
import { ImportDataPage } from '../src/page-objects/AD_ImportDataPage'
|
||||
import { checkFileName, clickDataOnLeftMenu, clickTemplatesOnLeftMenu, loadIfJsonSchemaNotAvailable, loginAsAdmin, loginAsUser, gotoViewEnabledCredential, expectedCredentialSubjectForUser } from '../src/steps';
|
||||
import { checkFileName, clickDataOnLeftMenu, loadIfJsonSchemaNotAvailable, loginAsAdmin, loginAsUser, gotoViewEnabledCredential, expectedCredentialSubjectForUser } from '../src/steps';
|
||||
import { ViewCredentialPage } from '../src/page-objects/US_ViewCredentialPage.js'
|
||||
import { fail } from 'assert'
|
||||
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, 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, JSON_SCHEMA_ID_FVC, PATH_FILES_TO_IMPORT, SCHEMA_FVC, SCHEMA_TYPE_FVC } from '../src/constants/constants';
|
||||
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';
|
||||
|
||||
/**
|
||||
* Checking template section: view the lists of templates, import schema, delete schema, view json
|
||||
*/
|
||||
test.describe('TEMPLATES Section Tests ', () => {
|
||||
|
||||
test.beforeEach(async ({ page }) => { //este se ejecutará antes de cada test
|
||||
await loginAsAdmin(page, URL_IDHUB);
|
||||
})
|
||||
|
||||
/**
|
||||
* For every row in the templates view,
|
||||
* extract the name of the template schema (second cell) and compare it against the
|
||||
* las element of the $id in the corresponding json file.
|
||||
*/
|
||||
|
||||
test('TEMPLATES -> View credential templates -> compare each template name against last element of $id in JSON', async ({ page }) => {
|
||||
// Navigate to the page with the table
|
||||
const templatesPage = new TemplatesPage(page);
|
||||
await clickTemplatesOnLeftMenu(page);
|
||||
expect(await templatesPage.checkSchemaNamesAgainstCorrespondingJSON(page)).toBeTruthy();
|
||||
})
|
||||
|
||||
/**
|
||||
* Check a specific template in the list of templates
|
||||
* If the template schema is not available, the schema is imported
|
||||
* Once the template schema is in the list, verify the element id in the json file
|
||||
*/
|
||||
test('TEMPLATES -> View schema/import for Financial Vulnerability Credential', async ({ page }) => {
|
||||
const templatesPage = new TemplatesPage(page);
|
||||
//Load the schema if it is not loaded
|
||||
await loadIfJsonSchemaNotAvailable(page, JSON_SCHEMA_FVC);
|
||||
|
||||
//validate $id in the json template
|
||||
await templatesPage.gotoViewSchemaPage(JSON_SCHEMA_FVC);
|
||||
const jsonContent = await page.evaluate(() => JSON.parse(document.body.innerText));
|
||||
// Check if the JSON elements exist
|
||||
expect(jsonContent["$id"]).toBe(JSON_SCHEMA_ID_FVC);
|
||||
})
|
||||
|
||||
/**
|
||||
* Check a specific template in the list of templates
|
||||
* If the template schema is not available, the schema is imported and verify the operation
|
||||
* Try to delete the schema, but cancel the operation
|
||||
* Try to delete the schema, confirm the operation and verify the operation
|
||||
*/
|
||||
test('TEMPLATES -> Delete schema', async ({ page }) => {
|
||||
//Access the specific template schema
|
||||
const templatesPage = new TemplatesPage(page);
|
||||
|
||||
//check if the schema is imported
|
||||
await loadIfJsonSchemaNotAvailable(page, JSON_SCHEMA_FVC);
|
||||
|
||||
/*Try to delete the schema and then cancel in the modal*/
|
||||
await templatesPage.gotoDeleteAndCancelInModal(JSON_SCHEMA_FVC);
|
||||
/*Verify the schema was imported*/
|
||||
expect(await templatesPage.schemaIsAvailableInView(JSON_SCHEMA_FVC)).toBeTruthy();
|
||||
|
||||
/*Try to delete the schema and then confirm the operation*/
|
||||
let wasDeleted = await templatesPage.gotoDeleteAndConfirmInModal(JSON_SCHEMA_FVC);
|
||||
|
||||
/*Verify the schema was deleted*/
|
||||
if (wasDeleted) {
|
||||
expect(await templatesPage.schemaIsAvailableInView(JSON_SCHEMA_FVC)).toBeFalsy();
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* Checking data section: view the lists of files imported, import data, delete...
|
||||
*/
|
||||
|
||||
test.describe('DATA Section Tests', () => {
|
||||
test.describe('ADMIN-> DATA Section Tests - Testing with Financial Vulnerability Credential', () => {
|
||||
|
||||
test.beforeEach(async ({ page }) => { //este se ejecutará antes de cada test
|
||||
await loginAsAdmin(page, URL_IDHUB);
|
||||
|
@ -282,20 +214,22 @@ test.describe('DATA Section Tests', () => {
|
|||
|
||||
}) //end describe
|
||||
|
||||
test.describe('USER Credentials Section Tests', () => {
|
||||
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
|
||||
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
|
||||
})
|
||||
|
||||
/**
|
||||
* Check if the user1 can visualize the credentials that has been enabled in "My Credentials"
|
||||
* Check the fields displayed when user click "View" Credential
|
||||
* 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
|
||||
*/
|
||||
|
||||
test('USER Credentials -> My Credentials -> View enabled Financial Vulnerability Credential', async ({ page }) => {
|
||||
// View the Financial Vulnerabilty Credential in status 'Enabled' for the user
|
||||
const credentialStatus = "Enabled"
|
||||
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
|
||||
|
@ -309,4 +243,3 @@ test.describe('USER Credentials Section Tests', () => {
|
|||
|
||||
}) //end describe
|
||||
|
||||
//Añadir test con otros tipos de credenciales
|
Reference in New Issue