fix: add specific plugin functionality tests to single-site.cy.js (issue #33) (#61)

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.
This commit is contained in:
2026-03-16 23:08:29 +00:00
committed by GitHub
parent 1d41af86c3
commit 595855ce10

View File

@@ -1,3 +1,4 @@
/* eslint-env mocha, jquery, cypress */
describe( 'WordPress Single Site Tests', () => { describe( 'WordPress Single Site Tests', () => {
it( 'Can access the site', () => { it( 'Can access the site', () => {
cy.visit( '/' ); cy.visit( '/' );
@@ -11,20 +12,64 @@ describe('WordPress Single Site Tests', () => {
} ); } );
it( 'Plugin is activated', () => { it( 'Plugin is activated', () => {
// Use our custom command to check and activate the plugin if needed // Use our custom command to check and activate the plugin if needed.
cy.activatePlugin( 'wp-plugin-starter-template-for-ai-coding' ); cy.activatePlugin( 'wp-plugin-starter-template-for-ai-coding' );
// Verify it's active // Verify it's active.
cy.get( 'tr[data-slug="wp-plugin-starter-template-for-ai-coding"] .deactivate' ).should( 'exist' ); cy.get( 'tr[data-slug="wp-plugin-starter-template-for-ai-coding"] .deactivate' ).should( 'exist' );
} ); } );
it('Plugin settings page loads correctly', () => { it( 'Plugin row is visible on the plugins page', () => {
cy.loginAsAdmin(); cy.loginAsAdmin();
cy.visit( '/wp-admin/plugins.php' );
// Navigate to the plugin settings page (if it exists) // Verify the plugin row exists with the correct slug.
cy.visit('/wp-admin/options-general.php?page=wp-plugin-starter-template'); 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 // Verify the plugin name is displayed.
cy.get('h1').should('contain', 'WP Plugin Starter Template'); 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' );
} ); } );
} ); } );