-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34330 from Progi1984/test7634
Functional Tests : BO - Advanced Parameter - Authorization Server : Edit API Access
- Loading branch information
Showing
2 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
115 changes: 115 additions & 0 deletions
115
.../campaigns/functional/BO/14_advancedParameters/12_authorizationServer/03_editAPIAccess.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// Import utils | ||
import helper from '@utils/helpers'; | ||
import testContext from '@utils/testContext'; | ||
|
||
// Import commonTests | ||
import loginCommon from '@commonTests/BO/loginBO'; | ||
import createAPIAccessTest from '@commonTests/BO/advancedParameters/authServer'; | ||
import {setFeatureFlag} from '@commonTests/BO/advancedParameters/newFeatures'; | ||
|
||
// Import pages | ||
import apiAccessPage from 'pages/BO/advancedParameters/APIAccess'; | ||
import addNewApiAccessPage from '@pages/BO/advancedParameters/APIAccess/add'; | ||
import featureFlagPage from '@pages/BO/advancedParameters/featureFlag'; | ||
import dashboardPage from '@pages/BO/dashboard'; | ||
|
||
// Import data | ||
import APIAccessData from '@data/faker/APIAccess'; | ||
|
||
import {expect} from 'chai'; | ||
import type {BrowserContext, Page} from 'playwright'; | ||
|
||
const baseContext: string = 'functional_BO_advancedParameters_authorizationServer_editAPIAccess'; | ||
|
||
describe('BO - Advanced Parameter - Authorization Server : Edit API Access', async () => { | ||
let browserContext: BrowserContext; | ||
let page: Page; | ||
|
||
const createAPIAccess: APIAccessData = new APIAccessData({ | ||
clientName: 'API Access XYZ', | ||
clientId: 'api-access-xyz', | ||
description: 'Description ABC', | ||
}); | ||
const editAPIAccess: APIAccessData = new APIAccessData({ | ||
clientName: 'API Access UVW', | ||
clientId: 'api-access-uvw', | ||
description: 'Description DEF', | ||
}); | ||
|
||
// Pre-condition: Enable experimental feature : Authorization server | ||
setFeatureFlag(featureFlagPage.featureFlagAuthorizationServer, true, `${baseContext}_enableAuthorizationServer`); | ||
|
||
// Pre-condition: Create an API Access | ||
createAPIAccessTest(createAPIAccess, `${baseContext}_preTest_0`); | ||
|
||
// before and after functions | ||
before(async function () { | ||
browserContext = await helper.createBrowserContext(this.browser); | ||
page = await helper.newTab(browserContext); | ||
}); | ||
|
||
after(async () => { | ||
await helper.closeBrowserContext(browserContext); | ||
}); | ||
|
||
describe('BO - Advanced Parameter - API Access : Edit API Access', async () => { | ||
it('should login in BO', async function () { | ||
await loginCommon.loginBO(this, page); | ||
}); | ||
|
||
it('should go to \'Advanced Parameters > API Access\' page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToAuthorizationServerPage', baseContext); | ||
|
||
await dashboardPage.goToSubMenu( | ||
page, | ||
dashboardPage.advancedParametersLink, | ||
dashboardPage.authorizationServerLink, | ||
); | ||
|
||
const pageTitle = await apiAccessPage.getPageTitle(page); | ||
expect(pageTitle).to.eq(apiAccessPage.pageTitle); | ||
}); | ||
|
||
it('should go to edit API Access page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToEditAPIAccessPage', baseContext); | ||
|
||
await apiAccessPage.goToEditAPIAccessPage(page, 1); | ||
|
||
const pageTitle = await addNewApiAccessPage.getPageTitle(page); | ||
expect(pageTitle).to.eq(addNewApiAccessPage.pageTitleEdit(createAPIAccess.clientName)); | ||
}); | ||
|
||
it('should edit API Access', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'editAPIAccess', baseContext); | ||
|
||
const textResult = await addNewApiAccessPage.addAPIAccess(page, editAPIAccess); | ||
expect(textResult).to.equal(addNewApiAccessPage.successfulUpdateMessage); | ||
}); | ||
|
||
it('should return to the list', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'returnToList', baseContext); | ||
|
||
// Go back to list to get number of elements because edition form redirects to itself | ||
await dashboardPage.goToSubMenu( | ||
page, | ||
dashboardPage.advancedParametersLink, | ||
dashboardPage.authorizationServerLink, | ||
); | ||
const numElements = await apiAccessPage.getNumberOfElementInGrid(page); | ||
expect(numElements).to.equal(1); | ||
}); | ||
|
||
it('should delete API Access', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'deleteAPIAccess', baseContext); | ||
|
||
const textResult = await apiAccessPage.deleteAPIAccess(page, 1); | ||
expect(textResult).to.equal(addNewApiAccessPage.successfulDeleteMessage); | ||
|
||
const numElements = await apiAccessPage.getNumberOfElementInGrid(page); | ||
expect(numElements).to.equal(0); | ||
}); | ||
}); | ||
|
||
// Post-condition: Disable experimental feature : Authorization server | ||
setFeatureFlag(featureFlagPage.featureFlagAuthorizationServer, false, `${baseContext}_disableAuthorizationServer`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import helper from '@utils/helpers'; | ||
import testContext from '@utils/testContext'; | ||
|
||
import loginCommon from '@commonTests/BO/loginBO'; | ||
|
||
import dashboardPage from '@pages/BO/dashboard'; | ||
import apiAccessPage from '@pages/BO/advancedParameters/APIAccess'; | ||
import addNewApiAccessPage from '@pages/BO/advancedParameters/APIAccess/add'; | ||
|
||
import APIAccessData from '@data/faker/APIAccess'; | ||
|
||
import {expect} from 'chai'; | ||
import type {BrowserContext, Page} from 'playwright'; | ||
|
||
/** | ||
* Function to create API Access | ||
* @param apiAccess {APIAccessData} Data to set in API Access form | ||
* @param baseContext {string} String to identify the test | ||
*/ | ||
function createAPIAccessTest(apiAccess: APIAccessData, baseContext: string = 'commonTests-createAPIAccessTest'): void { | ||
let browserContext: BrowserContext; | ||
let page: Page; | ||
let numberOfAPIAccess: number = 0; | ||
|
||
describe('PRE-TEST: Create an API Access', async () => { | ||
// before and after functions | ||
before(async function () { | ||
browserContext = await helper.createBrowserContext(this.browser); | ||
page = await helper.newTab(browserContext); | ||
}); | ||
|
||
after(async () => { | ||
await helper.closeBrowserContext(browserContext); | ||
}); | ||
|
||
it('should login in BO', async function () { | ||
await loginCommon.loginBO(this, page); | ||
}); | ||
|
||
it('should go to \'Advanced Parameters > API Access\' page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToAuthorizationServerPage', baseContext); | ||
|
||
await dashboardPage.goToSubMenu( | ||
page, | ||
dashboardPage.advancedParametersLink, | ||
dashboardPage.authorizationServerLink, | ||
); | ||
|
||
const pageTitle = await apiAccessPage.getPageTitle(page); | ||
expect(pageTitle).to.eq(apiAccessPage.pageTitle); | ||
|
||
numberOfAPIAccess = await apiAccessPage.getNumberOfElementInGrid(page); | ||
expect(numberOfAPIAccess).to.gte(0); | ||
}); | ||
|
||
it('should check that no records found', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'checkThatNoRecordFound', baseContext); | ||
|
||
const noRecordsFoundText = await apiAccessPage.getTextForEmptyTable(page); | ||
expect(noRecordsFoundText).to.contains('warning No records found'); | ||
}); | ||
|
||
it('should go to add New API Access page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToNewAPIAccessPage', baseContext); | ||
|
||
await apiAccessPage.goToNewAPIAccessPage(page); | ||
|
||
const pageTitle = await addNewApiAccessPage.getPageTitle(page); | ||
expect(pageTitle).to.eq(addNewApiAccessPage.pageTitleCreate); | ||
}); | ||
|
||
it('should create API Access', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'createAPIAccess', baseContext); | ||
|
||
const textResult = await addNewApiAccessPage.addAPIAccess(page, apiAccess); | ||
expect(textResult).to.equal(addNewApiAccessPage.successfulCreationMessage); | ||
|
||
// Go back to list to get number of elements because creation form redirects to edition form | ||
await dashboardPage.goToSubMenu( | ||
page, | ||
dashboardPage.advancedParametersLink, | ||
dashboardPage.authorizationServerLink, | ||
); | ||
const numElements = await apiAccessPage.getNumberOfElementInGrid(page); | ||
expect(numElements).to.equal(numberOfAPIAccess + 1); | ||
}); | ||
}); | ||
} | ||
|
||
export default createAPIAccessTest; |