-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-2024-fall' into observation/FOUR-19658
- Loading branch information
Showing
1 changed file
with
93 additions
and
0 deletions.
There are no files selected for viewing
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,93 @@ | ||
describe("Encrypted Field", () => { | ||
const visitAndOpenAcordeon = () => { | ||
cy.visit("/"); | ||
cy.openAcordeon("collapse-2"); | ||
}; | ||
|
||
const dragFormInput = () => { | ||
cy.get("[data-cy=controls-FormInput]").drag("[data-cy=screen-drop-zone]", { | ||
position: "bottom", | ||
}); | ||
cy.get("[data-cy=screen-element-container]").click(); | ||
}; | ||
|
||
const enterPreviewMode = () => { | ||
cy.get("[data-cy=mode-preview]").click(); | ||
}; | ||
|
||
const secretValue = "Secret Value"; | ||
|
||
const uuid = "62abf17e-d1a6-4f68-a382-ed63872d29b0"; | ||
|
||
it("Encrypted field properties and config", () => { | ||
visitAndOpenAcordeon(); | ||
dragFormInput(); | ||
cy.get("[data-cy=accordion-Advanced]").click(); | ||
// Enable encrypted | ||
cy.get("[data-cy=inspector-encryptedConfig]") | ||
.children() | ||
.children(".custom-control") | ||
.each((control) => { | ||
// forced click over the control | ||
control.children("input").trigger("click"); | ||
}); | ||
// Display available users/groups | ||
cy.get('[data-cy="inspector-encryptedConfig"] .multiselect').click(); | ||
// Select a user | ||
cy.get('[data-cy="inspector-encryptedConfig"] #option-2-1').click(); | ||
// Display available users/groups | ||
cy.get('[data-cy="inspector-encryptedConfig"] .multiselect').click(); | ||
// Select a group | ||
cy.get('[data-cy="inspector-encryptedConfig"] #option-2-5').click(); | ||
// Remove first selection | ||
cy.get('[data-cy="inspector-encryptedConfig"] .multiselect__tags i').first().click(); | ||
// Display available users/groups | ||
cy.get('[data-cy="inspector-encryptedConfig"] .multiselect').click(); | ||
// Select another user | ||
cy.get('[data-cy="inspector-encryptedConfig"] #option-2-2').click(); | ||
}); | ||
|
||
it("Encrypted field in preview", () => { | ||
visitAndOpenAcordeon(); | ||
dragFormInput(); | ||
cy.get("[data-cy=accordion-Advanced]").click(); | ||
// Enable encrypted | ||
cy.get("[data-cy=inspector-encryptedConfig]") | ||
.children() | ||
.children(".custom-control") | ||
.each((control) => { | ||
// forced click over the control | ||
control.children("input").trigger("click"); | ||
}); | ||
// Display available users/groups | ||
cy.get('[data-cy="inspector-encryptedConfig"] .multiselect').click(); | ||
// Select a group | ||
cy.get('[data-cy="inspector-encryptedConfig"] #option-2-4').click(); | ||
// Go to preview mode | ||
enterPreviewMode(); | ||
// Click in "Conceal" without data | ||
cy.get('[data-cy=preview-content] [name=form_input_1]').siblings('button').click(); | ||
// Should have a validation error | ||
cy.shouldHaveValidationErrors("screen-field-form_input_1"); | ||
// Write text in encrypted data | ||
cy.get("[data-cy=preview-content] [name=form_input_1]").type(secretValue); | ||
// Click in "Conceal" with data | ||
cy.get('[data-cy=preview-content] [name=form_input_1]').siblings('button').click(); | ||
// Should not have a validation error | ||
cy.shouldNotHaveValidationErrors("screen-field-form_input_1"); | ||
// After conceal should be in read only mode | ||
cy.get("[data-cy=preview-content] [name=form_input_1]").should("have.attr", "readonly"); | ||
// After conceal the value should be different | ||
cy.get("[data-cy=preview-content] [name=form_input_1]").should("have.not.value", secretValue); | ||
// The value in data should be the uuid returned | ||
cy.assertPreviewData({ | ||
form_input_1: uuid, | ||
}); | ||
// Click in "Reveal" | ||
cy.get('[data-cy=preview-content] [name=form_input_1]').siblings('button').click(); | ||
// After reveal should not be in read only mode | ||
cy.get("[data-cy=preview-content] [name=form_input_1]").should("have.not.attr", "readonly"); | ||
// After conceal the value should be the same | ||
cy.get("[data-cy=preview-content] [name=form_input_1]").should("have.value", secretValue); | ||
}); | ||
}); |