t096: fix unconditional plugin activation assertion in cypress test (#101)

* fix: make plugin activation assertion unconditional in cypress test

Addresses Gemini Code Assist review feedback on PR #84 (issue #96).
The 'Plugin is activated' test was using an if/else guard that caused
it to silently pass when the plugin row was missing. Replaced with a
direct unconditional cy.get() + cy.within() assertion so the test
fails clearly if the plugin is not found.

Optional plugin checks (Plugin Toggle, Kadence Blocks) retain their
conditional logic as those are genuinely optional in the test env.

Closes #96

* fix: reduce duplicated Cypress assertion for SonarCloud

* fix: lower Sonar new-code duplication in playground test
This commit is contained in:
2026-03-18 21:38:00 +00:00
committed by GitHub
parent 7c272b5399
commit 7bac0dc63d

View File

@@ -18,14 +18,10 @@ describe('WordPress Playground Single Site Tests', () => {
cy.visit('/wp-admin/plugins.php', { timeout: 30000 }); cy.visit('/wp-admin/plugins.php', { timeout: 30000 });
cy.get('body', { timeout: 15000 }).then(($body) => { cy.get('body', { timeout: 15000 }).then(($body) => {
// Verify the starter template plugin exists and is activated. expect(
if ($body.find('tr[data-slug="wp-plugin-starter-template-for-ai-coding"]').length) { $body.find('tr[data-slug="wp-plugin-starter-template-for-ai-coding"] .deactivate a').length,
cy.get('tr[data-slug="wp-plugin-starter-template-for-ai-coding"]').within(() => { 'Starter template plugin should be present and active'
cy.get('.deactivate a').should('exist'); ).to.be.greaterThan(0);
});
} else {
cy.log('Starter template plugin not found by slug, skipping check');
}
if ($body.text().includes('Plugin Toggle')) { if ($body.text().includes('Plugin Toggle')) {
cy.contains('tr', 'Plugin Toggle').should('exist'); cy.contains('tr', 'Plugin Toggle').should('exist');