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

Fix openDocumentSettings* commands in case Classic Editor is installed #27

Merged
merged 1 commit into from
Mar 25, 2022
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
1 change: 1 addition & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"plugins": ["WordPress/classic-editor"],
"env": {
"tests": {
"mappings": {
Expand Down
64 changes: 0 additions & 64 deletions tests/cypress/integration/open-document-settings-panel.test.js

This file was deleted.

This file was deleted.

127 changes: 127 additions & 0 deletions tests/cypress/integration/open-document-settings.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
describe('Commands: openDocumentSettings*', () => {
before(() => {
cy.login();

// Disable Classic Editor if it's enabled
cy.visit('/wp-admin/options-writing.php');
cy.get('body').then($body => {
if (
$body.find('.classic-editor-options').length !== 0 &&
$body.find('#classic-editor-classic').is(':checked')
) {
cy.get('#classic-editor-block').click();
cy.get('#submit').click();
}
});
});

beforeEach(() => {
cy.login();
});

it("Should be able to open (don't close) Status Panel on a new post", () => {
cy.visit(`/wp-admin/post-new.php`);
cy.get('button[aria-label="Close dialog"]').click();

const name = 'Status & visibility';
cy.openDocumentSettingsPanel(name);

// Assertion: Stick to the top checkbox should be visible
cy.get('.components-panel__body .components-panel__body-title button')
.contains(name)
.then($button => {
const $panel = $button.parents('.components-panel__body');
cy.wrap($panel).should('contain', 'Stick to the top of the blog');
});
});

it('Should be able to open Tags panel on the existing post', () => {
cy.visit(`/wp-admin/edit.php?post_type=post`);
cy.get('#the-list .row-title').first().click();
cy.get('button[aria-label="Close dialog"]').click();

cy.get('.is-root-container.block-editor-block-list__layout > *')
.first()
.click();

const name = 'Tags';
cy.openDocumentSettingsPanel(name);

// Assertion: Add new tag input should be visible
cy.get('.components-panel__body .components-panel__body-title button')
.contains(name)
.then($button => {
const $panel = $button.parents('.components-panel__body');
cy.wrap($panel).should('contain', 'Add New Tag');
});
});

it('Should be able to open Discussion panel on the existing page', () => {
cy.visit(`/wp-admin/edit.php?post_type=page`);
cy.get('#the-list .row-title').first().click();
cy.get('button[aria-label="Close dialog"]').click();

cy.get('.is-root-container.block-editor-block-list__layout > *')
.first()
.click();

const name = 'Discussion';
cy.openDocumentSettingsPanel(name, 'Page');

// Assertion: Allow comments checkbox should be visible
cy.get('.components-panel__body .components-panel__body-title button')
.contains(name)
.then($button => {
const $panel = $button.parents('.components-panel__body');
cy.wrap($panel).should('contain', 'Allow comments');
});
});
it('Should be able to Open Post Settings Sidebar on a new Post', () => {
cy.visit(`/wp-admin/post-new.php`);
cy.get('button[aria-label="Close dialog"]').click();
cy.openDocumentSettingsSidebar();

// Assertions:
cy.get('.edit-post-sidebar__panel-tab')
.contains('Post')
.should('have.class', 'is-active');
cy.get('.components-panel .components-panel__body').should('be.visible');
});

it('Should be able to Open Block tab of the first block on existing post', () => {
cy.visit(`/wp-admin/edit.php?post_type=post`);
cy.get('#the-list .row-title').first().click();
cy.get('button[aria-label="Close dialog"]').click();

cy.get('.is-root-container.block-editor-block-list__layout > *')
.first()
.click();
cy.openDocumentSettingsSidebar('Block');

// Assertions:
cy.get('.edit-post-sidebar__panel-tab')
.contains('Block')
.should('have.class', 'is-active');
cy.get('.components-panel .block-editor-block-inspector').should(
'be.visible'
);
});

it('Should be able to open Page Settings sidebar on an existing page', () => {
cy.visit(`/wp-admin/edit.php?post_type=page`);
cy.get('#the-list .row-title').first().click();
cy.get('button[aria-label="Close dialog"]').click();

cy.get('.is-root-container.block-editor-block-list__layout > *')
.first()
.click();

cy.openDocumentSettingsSidebar('Page');

// Assertions:
cy.get('.edit-post-sidebar__panel-tab')
.contains('Page')
.should('have.class', 'is-active');
cy.get('.components-panel .components-panel__body').should('be.visible');
});
});