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

updated styles for sites editor to hide/unhide switch labels #932

Merged
merged 1 commit into from
Nov 15, 2023
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 @@ -11,6 +11,7 @@
<filter root="/conf/core-components-examples/settings/wcm/templates/af-blank-v2" mode="update"/>
<filter root="/conf/core-components-examples/settings/wcm/templates/afv2frag-template" mode="update"/>
<filter root="/conf/core-components-examples/settings/wcm/templates/content-page/policies/jcr:content/root/responsivegrid/core-components-examples/components/form/container" mode="update"/>
<filter root="/conf/core-components-examples/settings/wcm/templates/content-page/policies/jcr:content/root/responsivegrid/forms-components-examples" mode="update"/>
<filter root="/content/core-components-examples/library/forms-and-communications-portal" mode="update"/>
<filter root="/content/core-components-examples/library/adaptive-form" mode="update"/>
<filter root="/conf/core-components-examples/settings/wcm/templates/content-page/structure/jcr:content/root/sidebar/accordion" mode="update"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
</form>
</components>
</core-components-examples>
<forms-components-examples jcr:primaryType="nt:unstructured">
<components jcr:primaryType="nt:unstructured">
<form jcr:primaryType="nt:unstructured">
<switch
egmox marked this conversation as resolved.
Show resolved Hide resolved
cq:policy="forms-components-examples/components/form/switch/default"
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/core/components/policies/mapping"/>
</form>
</components>
</forms-components-examples>
</responsivegrid>
</root>
</jcr:content>
Expand Down
14 changes: 13 additions & 1 deletion ui.tests/test-module/libs/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Cypress.Commands.add("openEditableToolbar", (selector) => {
cy.get(selector).first().click({force: true});
cy.get(path).should('be.visible');
} else {
cy.get(siteSelectors.overlays.self).scrollIntoView().click(0, 0); // dont click on body, always use overlay wrapper to click
cy.get(siteSelectors.overlays.self).scrollIntoView(); // dont click on body, always use overlay wrapper to click
cy.get(selector).click({force: true});
cy.get(path).should('be.visible');
}
Expand Down Expand Up @@ -678,3 +678,15 @@ Cypress.Commands.add("isElementInViewport", { prevSubject: true }, (subject) =>
rect.right <= Cypress.config("viewportWidth")
);
});


/**
* This function is used to fetch elements from ContentFrame iframe which are not accessible.
* Without this, the element will not be returned due to browser's cross-origin security feature.
*/
Cypress.Commands.add("getContentIframeBody", () => {
return cy
.get('#ContentFrame')
.its('0.contentDocument.body').should('not.be.empty')
.then(cy.wrap)
})
40 changes: 40 additions & 0 deletions ui.tests/test-module/specs/switch/switch.authoring.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const sitesSelectors = require('../../libs/commons/sitesSelectors'),
*/
describe('Page - Authoring', function () {

const unhideLabelsCss = '.cmp-adaptiveform-switch__unhide-labels';

const dropSwitchInSites = function() {
const dataPath = "/content/core-components-examples/library/adaptive-form/switch/jcr:content/root/responsivegrid/demo/component/guideContainer/*",
Expand Down Expand Up @@ -115,6 +116,26 @@ describe('Page - Authoring', function () {
cy.get('.rte-toolbar-item[title="Close"]').should('be.visible').click();
cy.deleteComponentByPath(switchDrop);
});

it('labels can hide and unhide with styles', function(){
const styleSelector = '[action="/content/forms/af/core-components-it/blank/_jcr_content/guideContainer/switch"] coral-selectlist-item';
cy.cleanTest(switchDrop).then(() => {
dropSwitchInContainer();
cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + switchEditPathSelector);
cy.invokeEditableAction("[data-action='STYLE']");
cy.get(styleSelector).eq(1).click().then(() => {
cy.get('body').click(0, 0);
cy.getContentIframeBody().find(unhideLabelsCss).should('have.length', 1);
});
cy.invokeEditableAction("[data-action='STYLE']");
cy.get(styleSelector).eq(0).click().then(() => {
cy.get('body').click(0, 0);
cy.getContentIframeBody().find(unhideLabelsCss).should('have.length', 0);
});
cy.deleteComponentByPath(switchDrop);
});
});

})

context('Open Sites Editor', function() {
Expand Down Expand Up @@ -174,5 +195,24 @@ describe('Page - Authoring', function () {
cy.get('.rte-toolbar-item[title="Close"]').should('be.visible').click();
cy.deleteComponentByPath(switchDrop);
});

it('labels can hide and unhide with styles', {retries: 3}, function(){
const styleSelector = '[action="/content/core-components-examples/library/adaptive-form/switch/_jcr_content/root/responsivegrid/demo/component/guideContainer/switch"] coral-selectlist-item';
cy.cleanTest(switchDrop).then(() => {
dropSwitchInSites();
cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + switchEditPathSelector);
cy.invokeEditableAction("[data-action='STYLE']");
cy.get(styleSelector).eq(1).click({force: true}).then(() => {
cy.get('body').click(0, 0);
cy.getContentIframeBody().find(unhideLabelsCss).scrollIntoView().should('have.length', 1);
});
cy.invokeEditableAction("[data-action='STYLE']");
cy.get(styleSelector).eq(1).click({force: true}).then(() => {
cy.get('body').click(0, 0);
cy.getContentIframeBody().find(unhideLabelsCss).should('have.length', 0);
});
cy.deleteComponentByPath(switchDrop);
});
});
})
});
Loading