Skip to content

Commit d3250a2

Browse files
Anurudra Shuklaci-build
authored andcommitted
FORMS-24185: add regression test for fragment without a panel
PR #1603 (reverted, see FORMS-24163) assumed every fragment's label container used the generic panel class, which threw when a fragment's fragmentPath resolved directly to fields with no wrapping panel. The existing fixture (test-fragment) always wraps fields in a panel, so this shape went uncaught. Reuses the existing container-rules.html page, which already embeds a panel-less fragment.
1 parent c99faaa commit d3250a2

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

ui.tests/test-module/specs/fragment/fragment.runtime.cy.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,36 @@ describe("Form Runtime with Fragment", () => {
210210
cy.get(`#${model.items[0].id}`).should('have.text', 'Thanks');
211211
});
212212
})
213+
214+
describe("Form Runtime with Fragment without a panel", () => {
215+
// Regression test for FORMS-24185 (found while fixing FORMS-24163).
216+
// PR #1603 (reverted) added an updateLabel override that derived the BEM class from
217+
// the element's classList and assumed a `.<bemClass>__label-container` descendant always
218+
// exists. That assumption broke rendering (with a console error) for a fragment whose
219+
// fragmentPath resolves directly to fields with no wrapping panel. The other fixture used
220+
// in this file (test-fragment) always wraps its fields in a panel, so this shape went
221+
// uncaught; container-rules.html embeds test-fragment-container-rules, which has none.
222+
const pagePath = "content/forms/af/core-components-it/samples/fragment/container-rules.html";
223+
const bemBlock = 'cmp-adaptiveform-fragment';
224+
225+
before(() => {
226+
cy.attachConsoleErrorSpy();
227+
});
228+
229+
it("renders the fragment and its label without a console error", () => {
230+
cy.previewForm(pagePath).then(formContainer => {
231+
expect(formContainer, "formContainer is initialized").to.not.be.null;
232+
233+
const [textInputId] = Object.entries(formContainer._fields)[0];
234+
cy.get(`#${textInputId}`).should('be.visible');
235+
236+
// Only asserting the container exists here - checked against a live author
237+
// (localhost:4502) and this page's fragment label doesn't render text via this
238+
// element on this content, so a stricter text/visibility check on `__label`
239+
// would be asserting behavior this fixture doesn't actually exhibit.
240+
cy.get(`.${bemBlock}__label-container`).should('exist');
241+
242+
cy.expectNoConsoleErrors();
243+
});
244+
});
245+
})

0 commit comments

Comments
 (0)