Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FORMS-17559: fix rule-editor test #1492

Merged
merged 19 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,25 @@ describe('Test UpdateEnum, UpdateEnumName for Checkbox', () => {
let enums = ["one", "two", "three"],
enumNames = ["India", "US", "Singapore"];

let toggle_array = [];
before(() => {
cy.fetchFeatureToggles().then((response) => {
if (response.status === 200) {
toggle_array = response.body.enabled;
}
});
});

/**
* initialization of form container before every test
* */
beforeEach(() => {
beforeEach(function() {
if (!toggle_array.includes("FT_FORMS-11269") || !toggle_array.includes("FT_FORMS-11541")) {
this.skip();
}
cy.previewForm(pagePath).then(p => {
formContainer = p;
})
});
});

describe('Checkbox with no options', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,25 @@ describe('Test UpdateEnum, UpdateEnumName for dropdown', () => {
/**
* initialization of form container before every test
* */
beforeEach(() => {
let toggle_array = [];
before(() => {
cy.fetchFeatureToggles().then((response) => {
if (response.status === 200) {
toggle_array = response.body.enabled;
}
});
});

/**
* initialization of form container before every test
* */
beforeEach(function() {
if (!toggle_array.includes("FT_FORMS-11269") || !toggle_array.includes("FT_FORMS-11541")) {
this.skip();
}
cy.previewForm(pagePath).then(p => {
formContainer = p;
})
});
});

describe('Dropdown with no options', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,25 @@ describe('Test UpdateEnum, UpdateEnumName for RadioButton', () => {
/**
* initialization of form container before every test
* */
beforeEach(() => {
let toggle_array = [];
before(() => {
cy.fetchFeatureToggles().then((response) => {
if (response.status === 200) {
toggle_array = response.body.enabled;
}
});
});

/**
* initialization of form container before every test
* */
beforeEach(function() {
if (!toggle_array.includes("FT_FORMS-11269") || !toggle_array.includes("FT_FORMS-11541")) {
this.skip();
}
cy.previewForm(pagePath).then(p => {
formContainer = p;
})
});
});

describe('Radiobutton with no options', () => {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,24 @@ describe('Form with custom functions configured in client lib', () => {
let formContainer = null;
let toggle_array = [];

before(() => {
cy.fetchFeatureToggles().then((response) => {
if (response.status === 200) {
toggle_array = response.body.enabled;
}
});
});

/**
* initialization of form container before every test
* */
beforeEach(() => {
beforeEach(function() {
if (!toggle_array.includes("FT_FORMS-11541")) {
this.skip();
}
cy.previewForm(formPath).then(p => {
formContainer = p;
});
cy.fetchFeatureToggles().then((response) => {
if (response.status === 200) {
toggle_array = response.body.enabled;
}
});
});

it('should have custom function definition loaded in the window object', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,23 @@ describe('Rule editor runtime sanity for core-components',function(){
});

it("should have merged custom function list registered in FunctionRuntime from both clientlibs", () => {
expect(formContainer, "formcontainer is initialized").to.not.be.null;
let func;
cy.window().then(win => {
func = win.FormView.FunctionRuntime.customFunctions.testFunction1; // from corecomponent.it.customfunction
expect(func).to.not.be.null;
expect(func).to.not.be.undefined;

func = win.FormView.FunctionRuntime.customFunctions.testSubmitFormPreprocessor; // from corecomponent.it.customfunction
expect(func).to.not.be.null;
expect(func).to.not.be.undefined;

func = win.FormView.FunctionRuntime.customFunctions.testSetProperty; // from corecomponent.it.customfunction2
expect(func).to.not.be.null;
expect(func).to.not.be.undefined;
})
if (toggle_array.includes("FT_FORMS-11269") && toggle_array.includes("FT_FORMS-11541")) {
expect(formContainer, "formcontainer is initialized").to.not.be.null;
let func;
cy.window().then(win => {
func = win.FormView.FunctionRuntime.customFunctions.testFunction1; // from corecomponent.it.customfunction
expect(func).to.not.be.null;
expect(func).to.not.be.undefined;

func = win.FormView.FunctionRuntime.customFunctions.testSubmitFormPreprocessor; // from corecomponent.it.customfunction
expect(func).to.not.be.null;
expect(func).to.not.be.undefined;

func = win.FormView.FunctionRuntime.customFunctions.testSetProperty; // from corecomponent.it.customfunction2
expect(func).to.not.be.null;
expect(func).to.not.be.undefined;
})
}
})

if (cy.af.isLatestAddon()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
describe('Form with custom functions containing ui change action configured in client lib', () => {
const formPath = "content/forms/af/core-components-it/samples/ruleeditor/uichange.html";
let formContainer = null;
let toggle_array = [];

before(() => {
cy.fetchFeatureToggles().then((response) => {
if (response.status === 200) {
toggle_array = response.body.enabled;
}
});
});

/**
* initialization of form container before every test
Expand All @@ -30,18 +39,20 @@ describe('Form with custom functions containing ui change action configured in c
});

it("ui change action should reset field model based on custom function", () => {
// Rule on textBox1: set value of textBox1 to "test", which is output of custom function testFunction1()
expect(formContainer, "formcontainer is initialized").to.not.be.null;
const [numberInput1, fieldView1] = Object.entries(formContainer._fields)[0]
const [numberInput7, fieldView2] = Object.entries(formContainer._fields)[6]
const numberInput1Model = formContainer._model.getElement(numberInput1)
const numberInput7Model = formContainer._model.getElement(numberInput7)
numberInput1Model.value = 123;
cy.get(`#${numberInput1}`).find("input").should('have.value',"123")
// let's trigger ui change action by doing changes via the dom API's
cy.get(`#${numberInput7}`).find("input").clear().type("93").blur().then(x => {
cy.get(`#${numberInput1}`).find("input").should('have.value',"")
})
if (toggle_array.includes("FT_FORMS-11541")) {
// Rule on textBox1: set value of textBox1 to "test", which is output of custom function testFunction1()
expect(formContainer, "formcontainer is initialized").to.not.be.null;
const [numberInput1, fieldView1] = Object.entries(formContainer._fields)[0]
const [numberInput7, fieldView2] = Object.entries(formContainer._fields)[6]
const numberInput1Model = formContainer._model.getElement(numberInput1)
const numberInput7Model = formContainer._model.getElement(numberInput7)
numberInput1Model.value = 123;
cy.get(`#${numberInput1}`).find("input").should('have.value',"123")
// let's trigger ui change action by doing changes via the dom API's
cy.get(`#${numberInput7}`).find("input").clear().type("93").blur().then(x => {
cy.get(`#${numberInput1}`).find("input").should('have.value',"")
})
}
})


Expand Down
Loading