From 595855ce107d4434e1657ced0daadcdef3668110 Mon Sep 17 00:00:00 2001 From: Marcus Quinn <6428977+marcusquinn@users.noreply.github.com> Date: Mon, 16 Mar 2026 23:08:29 +0000 Subject: [PATCH] fix: add specific plugin functionality tests to single-site.cy.js (issue #33) (#61) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address CodeRabbit PR #15 review feedback: replace generic settings page stub with tests that verify actual plugin functionality — plugin row visibility, update source selector link presence, modal open/close behaviour, and source option rendering. --- cypress/e2e/single-site.cy.js | 93 ++++++++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 24 deletions(-) diff --git a/cypress/e2e/single-site.cy.js b/cypress/e2e/single-site.cy.js index b4eee4a..6355798 100644 --- a/cypress/e2e/single-site.cy.js +++ b/cypress/e2e/single-site.cy.js @@ -1,30 +1,75 @@ -describe('WordPress Single Site Tests', () => { - it('Can access the site', () => { - cy.visit('/'); - cy.get('body').should('exist'); - }); +/* eslint-env mocha, jquery, cypress */ +describe( 'WordPress Single Site Tests', () => { + it( 'Can access the site', () => { + cy.visit( '/' ); + cy.get( 'body' ).should( 'exist' ); + } ); - it('Can login to the admin area', () => { - cy.loginAsAdmin(); - cy.get('#wpadminbar').should('exist'); - cy.get('#dashboard-widgets').should('exist'); - }); + it( 'Can login to the admin area', () => { + cy.loginAsAdmin(); + cy.get( '#wpadminbar' ).should( 'exist' ); + cy.get( '#dashboard-widgets' ).should( 'exist' ); + } ); - it('Plugin is activated', () => { - // Use our custom command to check and activate the plugin if needed - cy.activatePlugin('wp-plugin-starter-template-for-ai-coding'); + it( 'Plugin is activated', () => { + // Use our custom command to check and activate the plugin if needed. + cy.activatePlugin( 'wp-plugin-starter-template-for-ai-coding' ); - // Verify it's active - cy.get('tr[data-slug="wp-plugin-starter-template-for-ai-coding"] .deactivate').should('exist'); - }); + // Verify it's active. + cy.get( 'tr[data-slug="wp-plugin-starter-template-for-ai-coding"] .deactivate' ).should( 'exist' ); + } ); - it('Plugin settings page loads correctly', () => { - cy.loginAsAdmin(); + it( 'Plugin row is visible on the plugins page', () => { + cy.loginAsAdmin(); + cy.visit( '/wp-admin/plugins.php' ); - // Navigate to the plugin settings page (if it exists) - cy.visit('/wp-admin/options-general.php?page=wp-plugin-starter-template'); + // Verify the plugin row exists with the correct slug. + cy.get( 'tr[data-slug="wp-plugin-starter-template-for-ai-coding"]' ).should( 'exist' ); - // This is a basic check - adjust based on your actual plugin's settings page - cy.get('h1').should('contain', 'WP Plugin Starter Template'); - }); -}); + // Verify the plugin name is displayed. + cy.get( 'tr[data-slug="wp-plugin-starter-template-for-ai-coding"] .plugin-title strong' ) + .should( 'contain', 'WordPress Plugin Starter Template' ); + } ); + + it( 'Update source selector link is present in the plugin row', () => { + cy.loginAsAdmin(); + cy.visit( '/wp-admin/plugins.php' ); + + // The update source selector link should be rendered in the plugin row. + cy.get( 'tr[data-slug="wp-plugin-starter-template-for-ai-coding"]' ) + .find( '.wpst-update-source-selector' ) + .should( 'exist' ); + } ); + + it( 'Update source modal opens and displays source options', () => { + cy.loginAsAdmin(); + cy.visit( '/wp-admin/plugins.php' ); + + // Click the update source selector link to open the modal. + cy.get( '.wpst-update-source-selector' ).first().click(); + + // Modal should be visible. + cy.get( '#wpst-update-source-modal' ).should( 'be.visible' ); + + // Modal should contain the three update source options. + cy.get( '#wpst-update-source-modal input[name="update_source"][value="wordpress.org"]' ).should( 'exist' ); + cy.get( '#wpst-update-source-modal input[name="update_source"][value="github"]' ).should( 'exist' ); + cy.get( '#wpst-update-source-modal input[name="update_source"][value="gitea"]' ).should( 'exist' ); + + // Save button should be present. + cy.get( '#wpst-save-source' ).should( 'exist' ); + } ); + + it( 'Update source modal can be closed', () => { + cy.loginAsAdmin(); + cy.visit( '/wp-admin/plugins.php' ); + + // Open the modal. + cy.get( '.wpst-update-source-selector' ).first().click(); + cy.get( '#wpst-update-source-modal' ).should( 'be.visible' ); + + // Close the modal via the close button. + cy.get( '#wpst-update-source-modal .wpst-modal-close' ).click(); + cy.get( '#wpst-update-source-modal' ).should( 'not.be.visible' ); + } ); +} );