Skip to content

Commit

Permalink
Created UI automation cypress scripts for the Policies flow hashgraph…
Browse files Browse the repository at this point in the history
…#2266 :

-Edit
-Import (via file)
-Return to Edit
-Export
-Add tags

Created UI Automation scripts for import and delete Artifacts hashgraph#2270

Created UI automation scripts for the Module hashgraph#2272 :
-edit
-export
-import

Created UI automation scripts for Administration hashgraph#2273 :
-Settings
-Logs and Status

Created UI Automation scripts for Policy Editing hashgraph#2275 :

Signed-off-by: lozytskyiintellecteu <[email protected]>
  • Loading branch information
lozytskyiintellecteu committed Jul 5, 2023
1 parent d4f9fcd commit 72ef47c
Show file tree
Hide file tree
Showing 37 changed files with 1,423 additions and 42 deletions.
1 change: 0 additions & 1 deletion e2e-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules/
fixtures/
30 changes: 25 additions & 5 deletions e2e-tests/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,32 @@ const { verifyDownloadTasks } = require('cy-verify-downloads');


module.exports = defineConfig({

video: false,
watchForFileChanges: false,
defaultCommandTimeout: 10000,
e2e: {
env: {
"downloadFolder": "../e2e-tests/cypress/downloads/"
},
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
require('cypress-grep/src/plugin')(config);
return config;
},
experimentalRunAllSpecs : true,
setupNodeEvents(on, config) {
require('cypress-grep/src/plugin')(config);
return config;
},
setupNodeEvents(on, config) {
on('task', {
checkFile(partialName) {
const fs = require('fs');
const path = require('path');

const files = fs.readdirSync(config.env.downloadFolder);
const matchingFiles = files.filter(file => file.includes(partialName));
return matchingFiles.length > 0;
},
})
},
},
})

Expand All @@ -24,3 +39,8 @@ module.exports = defineConfig({
},
},
});





47 changes: 47 additions & 0 deletions e2e-tests/cypress/e2e/ui-tests/pages/artifacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import ASSERT from "../../../support/CustomHelpers/assertions";
import TIMEOUTS from "../../../support/CustomHelpers/timeouts";
import URL from "../../../support/GuardianUrls";

const ArtifactsPageLocators = {
modalWindow: 'mat-dialog-container[id*="mat-dialog"]',
uploadFileInput: '[dropzoneclassname="file-drop-zone"] input[type="file"]',
artifactsList: "/api/v1/artifacts?policyId=&pageIndex=0&pageSize=100",
dialogContainer: '.mat-dialog-container',
};

export class ArtifactsPage {

openArtifactsTab() {
cy.visit(URL.Root + URL.Artifacts);
}

static waitForArtifactsList(){
cy.intercept(ArtifactsPageLocators.artifactsList).as(
"waitForArtifactsList"
);
cy.wait("@waitForArtifactsList", { timeout: 300000 })
}

uploadFile(fileName) {
cy.get(ArtifactsPageLocators.modalWindow, { timeout: 30000 }).should('be.visible');
cy.fixture(fileName, { encoding: null }).as("myFixture");
cy.get(ArtifactsPageLocators.uploadFileInput).selectFile("@myFixture", { force: true });
}

checkArtifactsTableContains(text) {
cy.contains("td", text).should("be.visible");
}

checkArtifactsTableIsNotContains(text) {
cy.contains("td", text).should("not.exist");
}

deleteArtifact(name) {
cy.contains("td", name)
.siblings()
.contains("div", "delete")
.click({ force: true });
cy.get(ArtifactsPageLocators.dialogContainer).contains(new RegExp("^OK$", "g")).click({ force: true });
}

}
114 changes: 114 additions & 0 deletions e2e-tests/cypress/e2e/ui-tests/pages/logs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import URL from "../../../support/GuardianUrls";

const LogsPageLocators = {
LogModal: '.cdk-overlay-pane',
detailsBtn: '.btn-settings',
apllyBtn: 'button[type="submit"]',
messageField: '[formcontrolname="message"]',
messageColumn: '.cdk-column-message .long-message',
typeSelect: '[formcontrolname="type"]',
typeDefaultOption: '[formcontrolname="type"] .mat-select-min-line',
typeOption: '.mat-option-text',
logType: '.log-type',
tableBody: 'tbody tr',
calendarIcon: '[aria-label="Open calendar"]',
todayDate: '.mat-calendar-body-today',
attributesSelect: '[formcontrolname="attributes"]',
attributesInput: '[ng-reflect-placeholder="Attributes"]',
attributesOption: '[role="option"]',
attributeReflect: '[ng-reflect-name="attributes"]',
startDate: '[formcontrolname="startDate"]',
endDate: '[formcontrolname="endDate"]',
};

export class LogsPage {

openLogsTab() {
cy.visit(URL.Root + URL.Logs);
}

openDetailsModal() {
cy.get(LogsPageLocators.detailsBtn).first().click();
}

verifyLogModalIsDisplayed() {
cy.get(LogsPageLocators.LogModal).should('be.visible');
cy.contains("Log Details").should('be.visible');
cy.get('[formcontrolname="type"]').should('be.visible');
cy.get('[formcontrolname="datetime"]').should('be.visible');
cy.get('[formcontrolname="message"]').should('be.visible');
cy.get('[formcontrolname="attributes"]').should('be.visible');
}

fillMessageField(message) {
cy.get(LogsPageLocators.messageField).type(message);
}

clickOnApplyButton() {
cy.get(LogsPageLocators.apllyBtn).click();
cy.wait(500);
}

verifyIfMessageColumnContains(message) {
cy.get(LogsPageLocators.messageColumn).each(($el) => {
cy.wrap($el).contains(message);
});
}

selectMessageType(type) {
cy.get(LogsPageLocators.typeSelect).click();
cy.get(LogsPageLocators.typeOption).contains(type).click();
}

verifyIfTypeColumnContains(type) {
cy.get("tbody").then($tbody => {
if ($tbody.find("tr").length > 0) {
cy.get(LogsPageLocators.logType).each(($el) => {
cy.wrap($el).contains(type);
});
}
});
}

openDateRangePicker() {
cy.get(LogsPageLocators.calendarIcon).click();
}

selectTodayDate() {
cy.get(LogsPageLocators.todayDate).click();
cy.get(LogsPageLocators.todayDate).click();
}

selectFirstOptionInAttributes() {
cy.get(LogsPageLocators.attributesSelect).click();
cy.get(LogsPageLocators.attributesOption).first().click();
}

verifyThatLogsTableIsNotEmpty() {
cy.get(LogsPageLocators.tableBody).should('not.be.empty');
}

clickOnButton(buttonName) {
cy.contains(buttonName).click();
}

verifyIfMessageFieldIsEmpty() {
cy.get(LogsPageLocators.messageField).should('have.value', '');
}

verifyIfTypeFieldHasDefaultValue() {
cy.get(LogsPageLocators.typeDefaultOption).contains('All').should("be.visible");
}

verifyIfDateRangeFieldIsEmpty() {
cy.get(LogsPageLocators.startDate).should('have.value', '');
cy.get(LogsPageLocators.endDate).should('have.value', '');
}

verifyIfAttributeFieldIsEmpty() {
cy.get(LogsPageLocators.attributeReflect).should(($element) => {
expect($element).not.to.have.attr('role', 'listbox');
});
}

}
6 changes: 4 additions & 2 deletions e2e-tests/cypress/e2e/ui-tests/pages/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ export class ModulesPage {
cy.contains(ModulesPageLocators.exportIPFSLabel).click();
}



addTag(tagName) {
cy.intercept(ModulesPageLocators.tagsListRequest).as(
"waitForTags"
Expand Down Expand Up @@ -193,4 +191,8 @@ export class ModulesPage {
cy.contains("OK").click();
cy.contains(moduleName).should("not.exist")
}

checkTheTextIsPresentInModule(text) {
cy.contains(text).should("exist");
}
}
Loading

0 comments on commit 72ef47c

Please sign in to comment.