Cypress: refactor for Redact and NoRedact tests (#656)

This commit is contained in:
Adam Kol
2022-01-17 10:43:39 +02:00
committed by GitHub
parent 5ca3107422
commit 6b4bcc8abd
10 changed files with 35 additions and 30 deletions

View File

@@ -0,0 +1,9 @@
export function isValueExistsInElement(shouldInclude, content, domPathToContainer){
it(`should ${shouldInclude ? '' : 'not'} include '${content}'`, function () {
cy.get(domPathToContainer).then(htmlText => {
const allTextString = htmlText.text();
if (allTextString.includes(content) !== shouldInclude)
throw new Error(`One of the containers part contains ${content}`)
});
});
}

View File

@@ -1,4 +1,4 @@
import {findLineAndCheck, getExpectedDetailsDict} from '../page_objects/StatusBar';
import {findLineAndCheck, getExpectedDetailsDict} from '../testHelpers/StatusBarHelper';
it('opening', function () {
cy.visit(Cypress.env('testUrl'));

View File

@@ -0,0 +1,8 @@
import {isValueExistsInElement, isValueExistsInElement} from '../testHelpers/TrafficHelper';
it('Loading Mizu', function () {
cy.visit(Cypress.env('testUrl'));
})
isValueExistsInElement(false, Cypress.env('redactHeaderContent'), '#tbody-Headers');
isValueExistsInElement(false, Cypress.env('redactBodyContent'), '.hljs');

View File

@@ -0,0 +1,8 @@
import {isValueExistsInElement, isValueExistsInElement} from '../testHelpers/TrafficHelper';
it('Loading Mizu', function () {
cy.visit(Cypress.env('testUrl'));
})
isValueExistsInElement(true, Cypress.env('redactHeaderContent'), '#tbody-Headers');
isValueExistsInElement(true, Cypress.env('redactBodyContent'), '.hljs');

View File

@@ -1,23 +0,0 @@
const inHeader = 'User-Header[REDACTED]';
const inBody = '{ "User": "[REDACTED]" }';
const shouldExist = Cypress.env('shouldExist');
it('Loading Mizu', function () {
cy.visit(Cypress.env('testUrl'));
})
it(`should ${shouldExist ? '' : 'not'} include ${inHeader}`, function () {
cy.get('.CollapsibleContainer', { timeout : 15 * 1000}).first().next().then(headerElements => { //TODO change the path and refactor the body and head functions
const allText = headerElements.text();
if (allText.includes(inHeader) !== shouldExist)
throw new Error(`The headers panel doesnt include ${inHeader}`);
});
});
it(`should ${shouldExist ? '' : 'not'} include ${inBody}`, function () {
cy.get('.hljs').then(bodyElement => {
const line = bodyElement.text();
if (line.includes(inBody) !== shouldExist)
throw new Error(`The body panel doesnt include ${inBody}`);
});
});

View File

@@ -1,4 +1,4 @@
import {getExpectedDetailsDict, checkLine} from '../page_objects/StatusBar';
import {getExpectedDetailsDict, checkLine} from '../testHelpers/StatusBarHelper';
it('opening', function () {