Skip to content

Commit

Permalink
Merge pull request #616 from bcgov/dev
Browse files Browse the repository at this point in the history
Test automation updates
  • Loading branch information
ikethecoder committed Oct 25, 2022
2 parents d4be57f + df34c1b commit 7e4d1a9
Show file tree
Hide file tree
Showing 52 changed files with 427 additions and 182 deletions.
2 changes: 1 addition & 1 deletion e2e/cypress/fixtures/access-manager.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"user": {
"credentials": {
"username": "mark",
"username": "mark@idir",
"password": "mark"
}
},
Expand Down
3 changes: 2 additions & 1 deletion e2e/cypress/fixtures/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"members": [
{
"member": {
"username": "janis@idir"
"id": "janis@idir",
"email":"janis@testmail.com"
},
"roles": ["organization-admin"]
}
Expand Down
32 changes: 26 additions & 6 deletions e2e/cypress/fixtures/apiowner.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"user": {
"credentials": {
"username": "janis@idir",
"email":"janis@testmail.com",
"password": "awsummer"
}
},
Expand Down Expand Up @@ -54,10 +55,12 @@
"serviceName": "cc-service-for-platform",
"Mark": {
"userName": "mark",
"email":"mark@gmail.com",
"accessRole": ["Access.Manage"]
},
"Wendy": {
"userName": "wendy",
"email":"wendy@test.com",
"accessRole": ["CredentialIssuer.Admin"]
},
"jwtKeyPair": {
Expand Down Expand Up @@ -207,27 +210,33 @@
},
"grantPermission": {
"Mark": {
"userName": "mark",
"userName": "Mark F Mark L",
"email":"mark@gmail.com",
"accessRole": ["Access.Manage"]
},
"Mark_NV": {
"userName": "mark",
"userName": "Mark F Mark L",
"email":"mark@gmail.com",
"accessRole": ["Namespace.View"]
},
"Wendy": {
"userName": "wendy",
"userName": "Wendy F Wendy L",
"email":"wendy@test.com",
"accessRole": ["Namespace.Manage", "CredentialIssuer.Admin"]
},
"Wendy_CA": {
"userName": "wendy",
"userName": "Wendy F Wendy L",
"email":"wendy@test.com",
"accessRole": ["CredentialIssuer.Admin"]
},
"Wendy_GC": {
"userName": "wendy",
"userName": "Wendy F Wendy L",
"email":"wendy@test.com",
"accessRole": ["GatewayConfig.Publish", "Namespace.View"]
},
"Janis": {
"userName": "janis@idir",
"userName": "Janis Smith",
"email":"janis@testmail.com",
"accessRole": ["Namespace.Manage", "CredentialIssuer.Admin"]
}
},
Expand Down Expand Up @@ -256,7 +265,18 @@
"grantPermission": {
"Mark": {
"userName": "mark",
"email": "mark@gmail.com",
"accessRole": ["Access.Manage", "Namespace.View"]
},
"Janis": {
"userName": "janis@idir",
"email": "janis@testmail.com",
"accessRole": ["CredentialIssuer.Admin"]
},
"OldUser": {
"userName": "olduser@idir",
"email": "olduser@testmail.com",
"accessRole": ["Access.Manage", "Namespace.View","Namespace.Manage"]
}
},
"permission": {
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/fixtures/credential-issuer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"user": {
"credentials": {
"username": "wendy",
"username": "wendy@idir",
"password": "wendy"
}
},
Expand Down
15 changes: 15 additions & 0 deletions e2e/cypress/fixtures/usermigration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"oldUser": {
"credentials": {
"username": "olduser@idir",
"password": "awsummer"
}
},
"newUser": {
"credentials": {
"username": "220469e037c84a7abdfab15204a60701@olduser",
"password": "awsummer"
}
},
"namespace": "newplatform"
}
2 changes: 0 additions & 2 deletions e2e/cypress/pageObjects/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class ActivityPage {
this.setFilterCondition(filterCondition, value)
var filteredResponse: any
let result: any
debugger
if (value == "") {
filteredResponse = response
}
Expand All @@ -28,7 +27,6 @@ class ActivityPage {
cy.wrap($e1).find('p').invoke('text').then((text) => {
activityText = text
filteredResponse.forEach((record: any) => {
debugger
responseText = record.message
responseText = responseText.replaceAll("{", "${filteredResponse[index].params.")
const regexp = /\${([^{]+)}/g;
Expand Down
2 changes: 0 additions & 2 deletions e2e/cypress/pageObjects/apiDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ class ApiDirectoryPage {
isProductDisplay(productName: string): Boolean {
var flag = false;
cy.get('body', {timeout: 6000}).then(($body) => {
debugger
const pname: string = productName.toLowerCase().replaceAll(' ', '-')
var ele : string = `[data-testid=api-${pname}]`
debugger
cy.log('Body -> '+ $body)
if ($body.find(ele).length > 0) {
flag = true
Expand Down
1 change: 0 additions & 1 deletion e2e/cypress/pageObjects/applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class ApplicationPage {
checkDeletedApplication(appName: any) {
cy.get(this.applicationTbl).find('tr').each(($e1, index, $list) => {
let applicationName = $e1.find('td:nth-child(1)').text()
debugger
if (applicationName.toLowerCase() === appName.toLowerCase() ) {
assert.fail("Application is not deleted")
}
Expand Down
6 changes: 0 additions & 6 deletions e2e/cypress/pageObjects/consumers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export default class ConsumersPage {
// cy.wait(500)
cy.get(this.consumerDialogSaveBtn).click()
cy.get(this.consumerDialogSaveBtn, { timeout: 2000 }).should('not.exist')
debugger
cy.wait(3000)
}

Expand Down Expand Up @@ -180,7 +179,6 @@ export default class ConsumersPage {
});
cy.get(this.filterType).select(type).invoke('val')
cy.get(this.filterValue).select(value).invoke('val')
debugger
if (type == 'Labels') {
cy.get(this.labelValueInput).type(labelValue)
}
Expand All @@ -205,7 +203,6 @@ export default class ConsumersPage {
expect($e1.next().text().trim()).to.eq('Dev')
}
if ($e1.text() === 'Application') {
debugger
expect($e1.next().text().trim()).to.eq(applicationDetails.name)
}
if ($e1.text() === 'Instructions from the API Provider') {
Expand All @@ -219,7 +216,6 @@ export default class ConsumersPage {

addGroupLabels(groupLabels: any) {
Object.entries(groupLabels.labels).forEach((entry, index) => {
debugger
cy.get(this.labelsGroupSelection).select('[+] Add New Label Group...').invoke('val')
cy.get(this.labelName).type(entry[0])
cy.contains('Add').click()
Expand Down Expand Up @@ -287,9 +283,7 @@ export default class ConsumersPage {

addManageLabels() {
cy.wait(2000)
debugger
cy.get(this.manageLabelsBtn).parents('ul').find('li').then(($ele) => {
debugger
const index = $ele.length - 1
this.openManageLabelsWindow()
cy.get(this.labelsGroupSelection).select('[+] Add New Label Group...').invoke('val')
Expand Down
5 changes: 5 additions & 0 deletions e2e/cypress/pageObjects/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ class LoginPage {
usernameInput: string = '[id=username]'
passwordInput: string = '[id=password]'
loginSubmitButton: string = '[id=kc-login]'

checkUnsuccessfulSignIn(){
cy.contains('Account is disabled, contact your administrator.').should('be.visible')
cy.get(this.loginSubmitButton).should('be.visible')
}
}

export default LoginPage
6 changes: 3 additions & 3 deletions e2e/cypress/pageObjects/namespaceAccess.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class NamespaceAccessPage {

userNameInput: string = '[data-testid="nsa-gua-username-field"]'
userNameInput: string = '[data-testid="nsa-gua-email-field"]'
grantUserAccessBtn: string = '[data-testid="nsa-grant-access-btn"]'

grantPermission(accessRqst: any) {
cy.get(this.userNameInput,{ timeout: 2000 }).should('be.visible');
cy.get(this.userNameInput).type(accessRqst.userName);
cy.get(this.userNameInput).type(accessRqst.email);
let accessRole: Array<string> = accessRqst.accessRole
accessRole.forEach(function (accessName) {
cy.contains("Permissions").next().find('li').each(($el, index, $list) => {
Expand Down Expand Up @@ -36,7 +36,7 @@ class NamespaceAccessPage {

revokeAllPermission(user :string)
{
cy.contains(user.toLowerCase()).parents('tr').find('td:nth-child(3)').children('button').click()
cy.contains(user).parents('tr').find('td:nth-child(3)').children('button').click()
cy.get('[data-testid$="-revoke-btn"]').filter(':visible').first().click()
cy.wait(2000)
}
Expand Down
56 changes: 37 additions & 19 deletions e2e/cypress/pageObjects/products.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { checkElementExists } from "../support"

class Products {
path: string = '/manager/products'
newProductBtn: string = '[data-testid=prds-new-btn]'
Expand All @@ -8,20 +10,24 @@ class Products {
orgDropDown: string = '[data-testid=prd-edit-org-dd]'
orgUnitDropDown: string = '[data-testid=prd-edit-org-unit-dd]'
updateBtn: string = '[data-testid=prd-edit-update-btn]'
editPrdEnvConfigBtn: string = '[data-testid=prd-env-config-edit-btn]'
envCfgActivateRadio: string = '[data-testid=prd-env-config-activate-radio]'
envCfgApprovalCheckbox: string = '[data-testid=prd-env-config-approval-checkbox]'
editPrdEnvConfigBtn: string = '[data-testid="edit-env-active-checkbox"]'
// envCfgActivateRadio: string = '[data-testid=prd-env-config-activate-radio]'
envCfgActivateRadio: string = '[name="active"]'
envCfgApprovalCheckbox: string = '[data-testid="edit-env-approval-checkbox"]'
envCfgTermsDropdown: string = '[data-testid=legal-terms-dd]'
envCfgOptText: string = '[data-testid=prd-env-config-optional-text]'
envCfgAuthzDropdown: string = '[data-testid=prd-env-config-authz-dd]'
envCfgApplyChangesBtn: string = '[data-testid=prd-env-config-apply-btn]'
envCfgOptText: string = '[data-testid=edit-env-additional-details-textarea]'
envCfgAuthzDropdown: string = '[data-testid=edit-env-auth-flow-select]'
envCfgApplyChangesBtn: string = '[data-testid=edit-env-submit-button]'
envCfgApplyChangesContinueBtn: string = '[data-testid=edit-env-continue-button]'
catelogueDropDown: string = '[id=downshift-0-input]'
catelogueDropDownMenu: string = '[id=downshift-0-menu]'
deleteProductEnvBtn: string = '[data-testid="prd-env-delete-btn"]'
deleteProductBtn: string = '[data-testid="prd-edit-delete-btn"]'
deleteConfirmationBtn: string = '[data-testid="delete-env-confirmation-btn"]'
deleteProductConfirmationBtn: string = '[data-testid="confirm-delete-product-btn"]'
aclSwitch: string = '[data-testid="acls-switch"]'
viewTemplateBtn: string = '[data-testid="edit-env-view-plugin-template-btn"]'
configServiceTab: string = '[data-testid="edit-env-configure-services-tab"]'
config: string | undefined

getTestIdEnvName(env: string): string {
Expand All @@ -45,6 +51,7 @@ class Products {

editProduct(productName: string) {
const pname: string = productName.toLowerCase().replaceAll(' ', '-')
cy.get(`[data-testid=${pname}-more-options-btn]`).first().click()
cy.get(`[data-testid=${pname}-edit-btn]`).first().click()
// cy.get(this.updateBtn).click()
}
Expand All @@ -70,10 +77,6 @@ class Products {

editProductEnvironmentConfig(config: any, invalid = false) {

cy.get(this.editPrdEnvConfigBtn).click()
cy.get(this.envCfgActivateRadio).click()
cy.get(this.envCfgApprovalCheckbox).click()

cy.get(this.envCfgTermsDropdown).select(config.terms, { force: true }).invoke('val')

let authType = config.authorization
Expand All @@ -94,20 +97,23 @@ class Products {
})

cy.get(this.envCfgOptText).type(config.optionalInstructions)
cy.get(this.envCfgApprovalCheckbox).click()
cy.get(this.editPrdEnvConfigBtn).click()
cy.wait(3000)
// cy.get(`[data-testid=${config.serviceName}`).click()
// cy.wait(3000)
cy.get(this.envCfgApplyChangesContinueBtn).click()
cy.get(this.envCfgApplyChangesBtn).click()
cy.wait(3000)
if (invalid) {
// cy.verifyToastMessage("Environment updated")
}
else {
cy.verifyToastMessage("Environment updated")
cy.verifyToastMessage("Success")
}
}

generateKongPluginConfig(filename: string, flag?: boolean) {
generateKongPluginConfig(productName: string, envName: string, filename: string, flag?: boolean) {
this.editProductEnvironment(productName, envName)
cy.get(this.viewTemplateBtn).click()
cy.get('.language-yaml').then(($el) => {
cy.log($el.text())
cy.readFile('cypress/fixtures/' + filename).then((content: any) => {
Expand All @@ -121,6 +127,7 @@ class Products {
}
})
})
cy.contains('Close').click()
}

updateDatasetNameToCatelogue(productName: string, env: string) {
Expand All @@ -147,13 +154,16 @@ class Products {
deleteProductEnvironment(productName: string, envName: string) {
const pname: string = productName.toLowerCase().replaceAll(' ', '-')
let env = this.getTestIdEnvName(envName);
cy.get(`[data-testid=${pname}-${env}-edit-btn]`).siblings(this.deleteProductEnvBtn).click()
cy.get(`[data-testid=${pname}-${env}-more-options-btn]`).click()
cy.get(`[data-testid=${pname}-${env}-delete-btn]`).click()
cy.get(this.deleteConfirmationBtn).click()
}

deleteProduct(productName: string) {
this.editProduct(productName)
cy.get(this.deleteProductBtn).click()
// this.editProduct(productName)
const pname: string = productName.toLowerCase().replaceAll(' ', '-')
cy.get(`[data-testid=${pname}-edit-btn]`).first().click({force: true})
cy.get(`[data-testid=${pname}-delete-btn]`).first().click({force: true})
cy.get(this.deleteProductConfirmationBtn).click()
}

Expand All @@ -171,15 +181,23 @@ class Products {
})
}

activateService(config: any) {
activateService(productName: string, envName: string, config: any) {
this.editProductEnvironment(productName, envName)
cy.wait(2000)
cy.get(this.configServiceTab).click()
cy.wait(2000)
cy.get(`[data-testid=${config.serviceName}`).click()
cy.get(this.envCfgApplyChangesBtn).click()
}

getKongPluginConfig() {
getKongPluginConfig(productName: string, envName: string) {
this.editProductEnvironment(productName, envName)
cy.get(this.viewTemplateBtn).click()
cy.get('.language-yaml').then(($el) => {
this.config = $el.text()
cy.wait(1000)
})
cy.contains('Close').click()
}
}

Expand Down
Loading

0 comments on commit 7e4d1a9

Please sign in to comment.