From b47e7c01eb88a5c92cb1e68e3d69079915cb83a5 Mon Sep 17 00:00:00 2001 From: Shrikha Date: Wed, 20 Mar 2024 14:34:39 +0530 Subject: [PATCH] FORMS-13470: runtime test case for modal --- .../form/modal/v1/modal/.content.xml | 2 +- .../specs/modal/modal.runtime.spec.js | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 ui.tests/test-module/specs/modal/modal.runtime.spec.js diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/modal/v1/modal/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/modal/v1/modal/.content.xml index 8a12fa36a3..82a675aecf 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/modal/v1/modal/.content.xml +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/modal/v1/modal/.content.xml @@ -20,5 +20,5 @@ jcr:description="Modal" jcr:primaryType="cq:Component" jcr:title="Adaptive Form Modal (v1)" - sling:resourceSuperType="wcm/foundation/components/responsivegrid" + sling:resourceSuperType="core/fd/components/form/panelcontainer/v1/panelcontainer" componentGroup=".core-adaptiveform"/> \ No newline at end of file diff --git a/ui.tests/test-module/specs/modal/modal.runtime.spec.js b/ui.tests/test-module/specs/modal/modal.runtime.spec.js new file mode 100644 index 0000000000..45839d8dc4 --- /dev/null +++ b/ui.tests/test-module/specs/modal/modal.runtime.spec.js @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright 2024 Adobe + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ +describe('Form Runtime with Modal Component', () => { + const pagePath = "content/forms/af/core-components-it/samples/modal/basic.html" + const bemBlock = 'cmp-adaptiveform-modal' + const IS = "adaptiveFormModal" + const selectors = { + modal : `[data-cmp-is="${IS}"]` + } + + let formContainer = null + + beforeEach(() => { + cy.previewForm(pagePath).then(p => { + formContainer = p; + }) + }); + + it('opens the modal when the button is clicked, and makes the background inactive', () => { + // Click the button to open the modal + cy.get(`.${bemBlock}__button`).click(); + + // Check that the modal and overlay are visible + cy.get(`.${bemBlock}__dialog`).should('be.visible'); + + cy.get(`.${bemBlock}__overlay`).should('be.visible'); + }); + + it('closes the modal when the Escape key is pressed, and makes the background active again', () => { + // Open the modal + cy.get(`.${bemBlock}__button`).click(); + + // Check that the modal is visible + cy.get(`.${bemBlock}__overlay`).should('be.visible'); + + // Simulate pressing the Escape key + cy.get('body').type('{esc}'); + + // Check that the modal is no longer visible + cy.get(`.${bemBlock}__overlay`).should('not.exist'); + }); + +}); \ No newline at end of file