Skip to content

Commit

Permalink
WP 6.2 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeelia committed Feb 12, 2025
1 parent 2031068 commit 433e8ad
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 73 deletions.
133 changes: 62 additions & 71 deletions tests/cypress/support/commands/block-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,73 +64,53 @@ Cypress.Commands.add('insertBlock', (blockName) => {

Cypress.Commands.add('supportsBlockColors', { prevSubject: true }, (subject, isEdit) => {
if (isEdit) {
cy.get('.block-editor-block-inspector').as('blockInspector');
cy.get('.block-editor-block-inspector button[aria-label="Styles"]').click();
cy.get('.block-editor-block-inspector button').contains('Background').click();

if (wpVersion === '6.2') {
cy.get(
'.color-block-support-panel .components-button[aria-label="View and add options"]',
).click();
cy.get(
`.popover-slot button[aria-label="Color: Black"],
.block-editor-color-gradient-control__panel button[aria-label="Color: Black"]`,
).click();

cy.get('.components-button[aria-label="Show Background"]').click();
cy.get('.block-editor-panel-color-gradient-settings__dropdown').click();

cy.get('.components-button[aria-label="Color: Black"]').click();

cy.get('.color-block-support-panel').click();
} else {
cy.get('.block-editor-block-inspector button[aria-label="Styles"]').click();
cy.get('.block-editor-block-inspector button').contains('Background').click();

cy.get(
`.popover-slot button[aria-label="Color: Black"],
.block-editor-color-gradient-control__panel button[aria-label="Color: Black"]`,
).click();

cy.get('.block-editor-block-inspector button[aria-label="Settings"]').click();
}
cy.get('.block-editor-block-inspector button[aria-label="Settings"]').click();
}

cy.wrap(subject).should('have.css', 'background-color', 'rgb(0, 0, 0)');
});

Cypress.Commands.add('supportsBlockTypography', { prevSubject: true }, (subject, isEdit) => {
if (isEdit) {
if (wpVersion === '6.2') {
cy.get(
'.typography-block-support-panel .components-button[aria-label="View and add options"]',
).click();

cy.get('.components-button[aria-label="Show Font size"]').click();
cy.get('.components-custom-select-control__button[aria-label="Font size"]').click();
cy.get('.components-custom-select-control__item').contains('Extra small').click();
cy.get('.block-editor-block-inspector button[aria-label="Styles"]').click();
cy.get('.block-editor-block-inspector button[aria-label="Typography options"]').click();

cy.get('[aria-label="Typography options"] button, .popover-slot button')
.contains(/Font size|Size/)
.as('fontSizeButton');
cy.get('@fontSizeButton').click();
cy.get('@fontSizeButton').click();
cy.get('@fontSizeButton').type('{esc}');

cy.get('.block-editor-block-inspector fieldset.components-font-size-picker')
.find('button[role="combobox"], button[aria-label="Font size"]')
.click();

cy.get(
'.block-editor-block-inspector li[role="option"], .block-editor-block-inspector div[role="option"]',
)
.contains('Extra small')
.click();

cy.get(
'.typography-block-support-panel .components-button[aria-label="View options"]',
).click();
cy.get('.components-button[aria-label="Show Line height"]').click();
cy.get('.components-input-control__input[placeholder="1.5"]').clearThenType(2);
} else {
cy.get('.block-editor-block-inspector button[aria-label="Styles"]').click();
if (wpVersion === '6.2') {
cy.get('.block-editor-block-inspector button[aria-label="Typography options"]').click();

cy.get('[aria-label="Typography options"] button, .popover-slot button')
.contains(/Font size|Size/)
.contains('Line height')
.as('fontSizeButton');
cy.get('@fontSizeButton').click();
cy.get('@fontSizeButton').click();
cy.get('@fontSizeButton').type('{esc}');

cy.get(
'.block-editor-block-inspector fieldset.components-font-size-picker button[role="combobox"]',
).click();
cy.get(
'.block-editor-block-inspector li[role="option"], .block-editor-block-inspector div[role="option"]',
)
.contains('Extra small')
.click();

cy.get('.components-input-control__input[placeholder="1.5"]').clearThenType(2);
} else {
cy.get('.block-editor-line-height-control input').clearThenType(2);

cy.get('.block-editor-block-inspector button[aria-label="Settings"]').click();
}
}
Expand All @@ -141,31 +121,42 @@ Cypress.Commands.add('supportsBlockTypography', { prevSubject: true }, (subject,

Cypress.Commands.add('supportsBlockDimensions', { prevSubject: true }, (subject, isEdit) => {
if (isEdit) {
if (wpVersion === '6.2') {
cy.get(
'.dimensions-block-support-panel .components-button[aria-label="View and add options"]',
).click();

cy.get('.components-button[aria-label="Show Padding"]').click();
cy.get('.components-button[aria-label="Unlink Sides"]').click();
cy.get('.components-input-control__input[aria-label="Top"]').clearThenType(10);
cy.get('.components-input-control__input[aria-label="Right"]').clearThenType(15);
cy.get('.components-input-control__input[aria-label="Bottom"]').clearThenType(10);
cy.get('.components-input-control__input[aria-label="Left"]').clearThenType(15);
cy.get('.block-editor-block-inspector button[aria-label="Styles"]').click();
cy.get('.block-editor-block-inspector button[aria-label="Dimensions options"]').click();

cy.get('.dimensions-block-support-panel').click();
} else {
cy.get('.block-editor-block-inspector button[aria-label="Styles"]').click();
cy.get('.block-editor-block-inspector button[aria-label="Dimensions options"]').click();
cy.get('.dimensions-block-support-panel').as('dimensionsPanel');

cy.get('.dimensions-block-support-panel').as('dimensionsPanel');
cy.get('[aria-label="Dimensions options"] button, .popover-slot button')
.contains('Padding')
.as('paddingButton');
cy.get('@paddingButton').click();
cy.get('@paddingButton').click();
cy.get('@paddingButton').type('{esc}');

cy.get('[aria-label="Dimensions options"] button, .popover-slot button')
.contains('Padding')
.as('paddingButton');
cy.get('@paddingButton').click();
cy.get('@paddingButton').type('{esc}');
if (wpVersion === '6.2') {
cy.get('.components-button[aria-label="Unlink sides"]').click();

const inputs = [
{ label: 'Top padding', value: 10 },
{ label: 'Right padding', value: 15 },
{ label: 'Bottom padding', value: 10 },
{ label: 'Left padding', value: 15 },
];

inputs.forEach(({ label, value }) => {
cy.get('@dimensionsPanel')
.find('button[aria-label="Set custom size"]')
.first()
.click({ force: true });
cy.get('@dimensionsPanel')
.contains('label', label)
.closest('div')
.find('input')
.clearThenType(value);
});

cy.get('.dimensions-block-support-panel').click();
} else {
cy.get('@dimensionsPanel')
.find('.component-spacing-sizes-control, .spacing-sizes-control__wrapper')
.first()
Expand Down
12 changes: 10 additions & 2 deletions tests/cypress/support/global-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ before(() => {
});

afterEach(() => {
if (cy.state('test').state === 'failed') {
if (cy.state('test').state !== 'failed') {
return;
}

cy.get('body').then(($body) => {
if (!$body.find('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-copy-button').length) {
return;
}

cy.get('#debug-menu-target-EP_Debug_Bar_ElasticPress .ep-copy-button')
.invoke('attr', 'data-clipboard-text')
.then((text) => {
Expand All @@ -53,5 +61,5 @@ afterEach(() => {
const testTitle = cy.state('test').title;
cy.writeFile(`tests/cypress/logs/${parentTitle} - ${testTitle}.log`, text);
});
}
});
});

0 comments on commit 433e8ad

Please sign in to comment.