Skip to content

Commit

Permalink
Retiring FT-FORMS-8771 (#1258)
Browse files Browse the repository at this point in the history
Co-authored-by: Navneet Agarwal <[email protected]>
  • Loading branch information
navneet-ag and Navneet Agarwal authored Jun 3, 2024
1 parent e24b83f commit e0481b5
Showing 1 changed file with 29 additions and 46 deletions.
75 changes: 29 additions & 46 deletions ui.tests/test-module/specs/recaptcha/recaptcha.runtime.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import 'cypress-wait-until';

describe("Form Runtime with Recaptcha Input", () => {

const FT_CLOUD_CONFIG_PROVIDER = "FT_FORMS-8771";
const pagePath = "content/forms/af/core-components-it/samples/recaptcha/basic.html"
const enterprisePagePath = "content/forms/af/core-components-it/samples/recaptcha/enterprisescore.html"
const bemBlock = 'cmp-adaptiveform-recaptcha'
Expand All @@ -28,16 +27,6 @@ describe("Form Runtime with Recaptcha Input", () => {

let formContainer = null

let toggle_array = [];

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

// Whitelist the error message
cy.on('uncaught:exception', (err) => {
// when we render form with captcha, and FT is not enabled, this error is expected
Expand Down Expand Up @@ -73,44 +62,38 @@ describe("Form Runtime with Recaptcha Input", () => {
})
}

if (toggle_array.includes(FT_CLOUD_CONFIG_PROVIDER)) {
it(" should get model and view initialized properly ", () => {
expect(formContainer, "formcontainer is initialized").to.not.be.null;
expect(formContainer._model.items.length, "model and view elements match").to.equal(Object.keys(formContainer._fields).length);
Object.entries(formContainer._fields).forEach(([id, field]) => {
expect(field.getId()).to.equal(id)
expect(formContainer._model.getElement(id), `model and view are in sync`).to.equal(field.getModel())
});
})

it(" model's changes are reflected in the html ", () => {
const [id, fieldView] = Object.entries(formContainer._fields)[0]
const model = formContainer._model.getElement(id)
cy.get('#' + id + ' .cmp-adaptiveform-recaptcha__widget > div.g-recaptcha').should('exist');

checkHTML(model.id, model.getState()).then(() => {
model.visible = false
return checkHTML(model.id, model.getState())
}).then(() => {
model.enable = false
return checkHTML(model.id, model.getState())
})
it(" should get model and view initialized properly ", () => {
expect(formContainer, "formcontainer is initialized").to.not.be.null;
expect(formContainer._model.items.length, "model and view elements match").to.equal(Object.keys(formContainer._fields).length);
Object.entries(formContainer._fields).forEach(([id, field]) => {
expect(field.getId()).to.equal(id)
expect(formContainer._model.getElement(id), `model and view are in sync`).to.equal(field.getModel())
});
})

it(" html changes are reflected in model ", () => {
const [id, fieldView] = Object.entries(formContainer._fields)[0]
const model = formContainer._model.getElement(id)
it(" model's changes are reflected in the html ", () => {
const [id, fieldView] = Object.entries(formContainer._fields)[0]
const model = formContainer._model.getElement(id)
cy.get('#' + id + ' .cmp-adaptiveform-recaptcha__widget > div.g-recaptcha').should('exist');

checkHTML(model.id, model.getState()).then(() => {
model.visible = false
return checkHTML(model.id, model.getState())
}).then(() => {
model.enable = false
return checkHTML(model.id, model.getState())
})
});

it(" html changes are reflected in model ", () => {
const [id, fieldView] = Object.entries(formContainer._fields)[0]
const model = formContainer._model.getElement(id)
cy.log(model.getState().value)
cy.get(`#${id}`).click().then(x => {
cy.log(model.getState().value)
cy.get(`#${id}`).click().then(x => {
cy.log(model.getState().value)
expect(model.getState().value).to.not.be.null
})
});
} else {
it('Feature toggle of captcha is disabled, skipping tests', () => {
cy.log('Tests were skipped because the feature toggle of captcha is disabled');
});
}
expect(model.getState().value).to.not.be.null
})
});

it("decoration element should not have same class name", () => {
expect(formContainer, "formcontainer is initialized").to.not.be.null;
Expand Down

0 comments on commit e0481b5

Please sign in to comment.