Skip to content

Commit

Permalink
update app solutions tests to use fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
circlecube committed Oct 29, 2024
1 parent 24d2050 commit a4a596b
Showing 1 changed file with 39 additions and 29 deletions.
68 changes: 39 additions & 29 deletions tests/cypress/integration/solutions-app.cy.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
// <reference types="Cypress" />
const entitlementsFixture = require( '../fixtures/entitlements.json' );

describe( 'My Plugins and Tools in Plugin App', function () {
beforeEach( () => {
cy.visit( '/wp-admin/index.php' );

// we should move the debug.json entitlement response into a fixture.
// for now this test will work if debug mode is on since it will load the debug data.
// also need to devise a way to set capabilities via cli command for testing with/without solutions.
} );

// check that it does not display when capabilities.hasSolution is false
it( 'My Plugins & Tools nav does not display without solution', () => {
cy.visit(
'/wp-admin/admin.php?page=' +
Cypress.env( 'pluginId' ) +
'#/',
'/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/',
{
onLoad() {
cy.window().then( ( win ) => {
Expand All @@ -23,15 +18,15 @@ describe( 'My Plugins and Tools in Plugin App', function () {
},
}
);
cy.get('a.wppbh-app-navitem[href="#/my_plugins_and_tools"]').should('not.exist');
cy.get( 'a.wppbh-app-navitem[href="#/my_plugins_and_tools"]' ).should(
'not.exist'
);
} );

// check that my plugins and tools displays when capabilities.hasSolution is true
it( 'My Plugins & Tools nav displays with Solution', () => {
cy.visit(
'/wp-admin/admin.php?page=' +
Cypress.env( 'pluginId' ) +
'#/',
'/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/',
{
onLoad() {
cy.window().then( ( win ) => {
Expand All @@ -40,7 +35,9 @@ describe( 'My Plugins and Tools in Plugin App', function () {
},
}
);
cy.get('a.wppbh-app-navitem[href="#/my_plugins_and_tools"]').should('be.visible');
cy.get( 'a.wppbh-app-navitem[href="#/my_plugins_and_tools"]' ).should(
'be.visible'
);
} );

// check that entitlement categories load in accordions
Expand All @@ -57,40 +54,53 @@ describe( 'My Plugins and Tools in Plugin App', function () {
},
}
);

cy.get('a.wppbh-app-navitem[href="#/my_plugins_and_tools"]').should('be.visible');


cy.intercept(
{
method: 'GET',
url: /newfold-solutions(\/|%2F)v1(\/|%2F)entitlements/,
},
{
body: entitlementsFixture,
delay: 100,
}
).as( 'getEntitlements' );
cy.wait( '@getEntitlements' );

cy.get( 'a.wppbh-app-navitem[href="#/my_plugins_and_tools"]' ).should(
'be.visible'
);

cy.get( '.newfold-entitlements-container' )
.contains( 'h2', 'Tools' )
.contains( 'h2', 'Plugins & Tools' )
.scrollIntoView()
.should( 'be.visible' );

cy.get( '.nfd-core-tool-mypluginsntools' )
.contains( 'h3', 'Core Tools' )
.contains( 'h2', 'Core Tools' )
.scrollIntoView()
.should( 'be.visible' );

// accordion closed
cy.get( '.nfd-core-tool-mypluginsntools' )
.contains( 'h4', 'Jetpack')
.scrollIntoView()
.should( 'be.visible' );

.contains( 'h3', 'Jetpack' )
.should( 'not.exist' );

// test accordion functionality
cy.get( '.nfd-core-tool-mypluginsntools' )
.contains( 'h3', 'Core Tools' )
.contains( 'h2', 'Core Tools' )
.click();

// accordion closed
// accordion opened
cy.get( '.nfd-core-tool-mypluginsntools' )
.contains( 'h4', 'Jetpack')
.should( 'not.exist' );
.contains( 'h3', 'Jetpack' )
.scrollIntoView()
.should( 'be.visible' );
} );

// test entitlement button case states
// test entitlement button case states
// 1. plugin already installed and active
// 2. plugin already installed but not active
// 3. free plugin not installed, needs appropriate installer attributes
// 4. premium plugin not installed, needs appropriate pls attributes


} );

0 comments on commit a4a596b

Please sign in to comment.