diff --git a/.wp-env.json b/.wp-env.json index 902493a..1713cd0 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -1,4 +1,5 @@ { + "plugins": ["WordPress/classic-editor"], "env": { "tests": { "mappings": { diff --git a/tests/cypress/integration/open-document-settings-panel.test.js b/tests/cypress/integration/open-document-settings-panel.test.js deleted file mode 100644 index 2c10d1a..0000000 --- a/tests/cypress/integration/open-document-settings-panel.test.js +++ /dev/null @@ -1,64 +0,0 @@ -describe('Command: openDocumentSettingsPanel', () => { - 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'); - }); - }); - -}); diff --git a/tests/cypress/integration/open-document-settings-sidebar.test.js b/tests/cypress/integration/open-document-settings-sidebar.test.js deleted file mode 100644 index b7d737c..0000000 --- a/tests/cypress/integration/open-document-settings-sidebar.test.js +++ /dev/null @@ -1,58 +0,0 @@ -describe('Command: openDocumentSettingsSidebar', () => { - beforeEach(() => { - cy.login(); - }); - - 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' - ); - }) -}); diff --git a/tests/cypress/integration/open-document-settings.test.js b/tests/cypress/integration/open-document-settings.test.js new file mode 100644 index 0000000..a0111fd --- /dev/null +++ b/tests/cypress/integration/open-document-settings.test.js @@ -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'); + }); +});