From 812b0ac21baf32cda058769e76df9ad0404ce917 Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Sat, 14 Dec 2024 00:27:46 +0530 Subject: [PATCH] fix eslint issues in existing tests --- .../pmk-media-kit-page-creation.test.js | 79 +++++++++---------- .../integration/pmk-plugin-activation.test.js | 20 ++--- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/tests/cypress/integration/pmk-media-kit-page-creation.test.js b/tests/cypress/integration/pmk-media-kit-page-creation.test.js index 02fa466..e8ce856 100644 --- a/tests/cypress/integration/pmk-media-kit-page-creation.test.js +++ b/tests/cypress/integration/pmk-media-kit-page-creation.test.js @@ -1,45 +1,44 @@ -describe( 'Check if Media Kit page is created on plugin activation', () => { - before( () => { - cy - .visitAdminPage( 'edit.php?post_type=page' ) - .get( '#post-search-input' ) - .clear() - .type( 'Media Kit' ) - .get( '#search-submit' ).click(); - } ); +describe('Check if Media Kit page is created on plugin activation', () => { + before(() => { + cy.visitAdminPage('edit.php?post_type=page') + .get('#post-search-input') + .clear() + .type('Media Kit') + .get('#search-submit') + .click(); + }); - it( 'Activate Media Kit Plugin', () => { - cy.get( 'body' ).then( ( $body ) => { - if ( $body.find('[aria-label="Move “Media Kit” to the Trash"]' ).length > 0 ) { - cy.get( '[aria-label="Move “Media Kit” to the Trash"]' ).click({ force: true }); - } - }); + it('Activate Media Kit Plugin', () => { + cy.get('body').then(($body) => { + if ($body.find('[aria-label="Move “Media Kit” to the Trash"]').length > 0) { + cy.get('[aria-label="Move “Media Kit” to the Trash"]').click({ force: true }); + } + }); - cy. - visitAdminPage( 'plugins.php' ) - .get( '#deactivate-publisher-media-kit' ).click() - .get( '#activate-publisher-media-kit' ).click() - .get( '#deactivate-publisher-media-kit' ).should( 'be.visible' ); + cy.visitAdminPage('plugins.php') + .get('#deactivate-publisher-media-kit') + .click() + .get('#activate-publisher-media-kit') + .click() + .get('#deactivate-publisher-media-kit') + .should('be.visible'); - cy - .get( '.updated.notice a' ) - .invoke('attr', 'href') - .then(href => { - cy - .request( href ) - .its('status') - .should('eq', 200); + cy.get('.updated.notice a') + .invoke('attr', 'href') + .then((href) => { + cy.request(href).its('status').should('eq', 200); + }); + }); - }); - } ); + it('Ensure image URLs display correctly', () => { + cy.visitAdminPage('edit.php?post_type=page'); - it( 'Ensure image URLs display correctly', () => { - cy.visitAdminPage( 'edit.php?post_type=page' ); - - cy.get( '#post-search-input' ).clear().type( 'Media Kit{Enter}' ); - cy.get( 'a.row-title' ).first().click(); - cy.get( '.wp-block img[src^="' + Cypress.config( 'baseUrl' ) + '"]' ).first().each( ( $img ) => { - cy.request( $img.attr( 'src' ) ).its( 'status' ).should( 'eq', 200 ); - } ); - } ); -} ); + cy.get('#post-search-input').clear().type('Media Kit{Enter}'); + cy.get('a.row-title').first().click(); + cy.get(`.wp-block img[src^="${Cypress.config('baseUrl')}"]`) + .first() + .each(($img) => { + cy.request($img.attr('src')).its('status').should('eq', 200); + }); + }); +}); diff --git a/tests/cypress/integration/pmk-plugin-activation.test.js b/tests/cypress/integration/pmk-plugin-activation.test.js index 93c9a98..0e2c832 100644 --- a/tests/cypress/integration/pmk-plugin-activation.test.js +++ b/tests/cypress/integration/pmk-plugin-activation.test.js @@ -1,9 +1,11 @@ -describe( 'Admin can login and make sure plugin is activated', () => { - it( 'Can activate plugin if it is deactivated', () => { - cy. - visitAdminPage( 'plugins.php' ) - .get( '#deactivate-publisher-media-kit' ).click() - .get( '#activate-publisher-media-kit' ).click() - .get( '#deactivate-publisher-media-kit' ).should( 'be.visible' ); - } ); -} ); \ No newline at end of file +describe('Admin can login and make sure plugin is activated', () => { + it('Can activate plugin if it is deactivated', () => { + cy.visitAdminPage('plugins.php') + .get('#deactivate-publisher-media-kit') + .click() + .get('#activate-publisher-media-kit') + .click() + .get('#deactivate-publisher-media-kit') + .should('be.visible'); + }); +});