-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My plugins tools page #55
Open
asr0393
wants to merge
2
commits into
main
Choose a base branch
from
my_plugins_tools_page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
185 changes: 185 additions & 0 deletions
185
tests/cypress/integration/my_plugins&tools_categories.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
// <reference types="Cypress" /> | ||
import { wpLogin } from '../wp-module-support/utils.cy'; | ||
|
||
const entitlementsFixture = require( '../fixtures/entitlements.json' ); | ||
|
||
describe( 'My Plugins and Tools in Plugin App', { testIsolation: true }, () => { | ||
beforeEach( () => { | ||
wpLogin(); | ||
|
||
const ecomCategories = { | ||
// Example structure for ecom categories | ||
categories: [ | ||
{ id: 1, name: "Store Operations"}, | ||
{ id: 2, name: "Search Engine Optimization" }, | ||
{ id: 3, name: "Sales & Checkout" }, | ||
{ id: 4, name: "Content Monetization" }, | ||
{ id: 5, name: "Core Tools" }, | ||
{ id: 6, name: "Customer Engagement" }, | ||
{ id: 7, name: "Product Management" } | ||
], | ||
} | ||
// Mocked solution 1 - will only return a subset of categories | ||
const serviceCategories = { | ||
|
||
categories: [ | ||
{ id: 2, name: "Search Engine Optimization" }, | ||
{ id: 4, name: "Content Monetization" }, | ||
{ id: 5, name: "Core Tools" }, | ||
{ id: 6, name: "Customer Engagement" }, | ||
], | ||
}; | ||
|
||
const contentcreatorCategories = { | ||
categories: [ | ||
{id: 2, name: "Search Engine Optimization" }, | ||
{ id: 3, name: "Sales & Checkout" }, | ||
{ id: 4, name: "Content Monetization" }, | ||
{ id: 5, name: "Core Tools" }, | ||
], | ||
}; | ||
cy.visit( '/wp-admin/index.php' ); | ||
} ); | ||
|
||
//Check Categories based on Solution Type (Content Creator, Services, Commerce) | ||
it('Extracts the solution SKU from API response and check for the solution specific categories', () => { | ||
|
||
// set up the intercept for entitlements | ||
cy.intercept( | ||
{ | ||
method: 'GET', | ||
url: /newfold-solutions(\/|%2F)v1(\/|%2F)entitlements/, | ||
}, | ||
{ | ||
body: entitlementsFixture, | ||
delay: 100, | ||
} | ||
).as( 'getEntitlements' ); | ||
|
||
cy.visit('/wp-admin/admin.php?page=' + Cypress.env('pluginId') + '#/my_plugins_and_tools'); | ||
cy.wait('@getEntitlements').then((interception) => { | ||
// Access the response body from the intercepted request | ||
const solutions = interception.response.body.solutions; | ||
// Log the solutions for debugging | ||
cy.log('Solutions:', JSON.stringify(solutions)); | ||
const solutionSku = solutions[0]?.sku; | ||
cy.log('Solution SKU:', solutionSku); | ||
const solution = solutions.find(s => s.sku === solutionSku); | ||
const categories = solution?.categories || []; | ||
if (solutionSku === 'WP_SOLUTION_COMMERCE') { | ||
cy.log('This site is associated with the "commerce" solution'); | ||
cy.get('.newfold-entitlements-container').should('contain', 'Search Engine Optimization'); | ||
cy.get('.newfold-entitlements-container').should('contain', 'Content Monetization'); | ||
cy.get('.newfold-entitlements-container').should('contain', 'Core Tools'); | ||
cy.get('.newfold-entitlements-container').should('contain', 'Customer Engagement'); | ||
cy.get('.newfold-entitlements-container').should('contain','Sales & Checkout' ); | ||
cy.get('.newfold-entitlements-container').should('contain','Store Operations' ); | ||
cy.get('.newfold-entitlements-container').should('contain','Product Management' ); | ||
|
||
} else if (solutionSku === 'WP_SOLUTION_SERVICE') { | ||
cy.log('This site is associated with the "Service" solution'); | ||
cy.get('.newfold-entitlements-container').should('contain', 'Search Engine Optimization'); | ||
cy.get('.newfold-entitlements-container').should('contain', 'Content Monetization'); | ||
cy.get('.newfold-entitlements-container').should('contain', 'Core Tools'); | ||
cy.get('.newfold-entitlements-container').should('contain', 'Customer Engagement'); | ||
|
||
} else if (solutionSku === 'WP_SOLUTION_CREATOR') { | ||
cy.log('This site is associated with the "Content Creator" solution'); | ||
cy.get('.newfold-entitlements-container').should('contain', 'Search Engine Optimization'); | ||
cy.get('.newfold-entitlements-container').should('contain','Sales & Checkout' ); | ||
cy.get('.newfold-entitlements-container').should('contain', 'Core Tools'); | ||
cy.get('.newfold-entitlements-container').should('contain', 'Customer Engagement'); | ||
|
||
} | ||
else { | ||
cy.log('No solution plan associated with the site'); | ||
} | ||
|
||
|
||
// Dynamically check categories based on the solution SKU | ||
categories.forEach(category => { | ||
cy.get('.newfold-entitlements-container') | ||
.contains('h2', category) // Check if the category is visible | ||
.scrollIntoView() | ||
.should('be.visible'); | ||
cy.log('categories'); | ||
|
||
} ); | ||
cy.get( '.newfold-entitlements-container' ) | ||
.contains( 'h2', 'My Plugins & Tools' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ); | ||
//category:Core tools | ||
cy.get( '.nfd-core-tool-mypluginsntools' ) | ||
.contains( 'h2', 'Core Tools' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ) | ||
.click(); | ||
|
||
cy.get( '.nfd-core-tool-mypluginsntools' ) | ||
.contains( 'h3', 'Jetpack' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ); | ||
|
||
cy.get( '.nfd-core-tool-mypluginsntools' ) | ||
.contains( 'h3', 'WonderBlocks' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ); | ||
//category:Content Monetization | ||
|
||
cy.get( '.nfd-core-tool-mypluginsntools' ) | ||
.contains( 'h2', 'Content Monetization' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ) | ||
.click(); | ||
//category:Customer Engagement | ||
|
||
cy.get( '.nfd-core-tool-mypluginsntools' ) | ||
.contains( 'h2', 'Customer Engagement' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ) | ||
.click(); | ||
//category:Product Management | ||
|
||
cy.get( '.nfd-core-tool-mypluginsntools' ) | ||
.contains( 'h2', 'Product Management' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ) | ||
.click(); | ||
//category:Sales & Checkout | ||
cy.get( '.nfd-core-tool-mypluginsntools' ) | ||
.contains( 'h2', 'Sales & Checkout' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ) | ||
.click(); | ||
|
||
//category:Search Engine Optimization | ||
cy.get( '.nfd-core-tool-mypluginsntools' ) | ||
.contains( 'h2', 'Search Engine Optimization' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ) | ||
.click(); | ||
|
||
//category:Store Operations | ||
cy.get( '.nfd-core-tool-mypluginsntools' ) | ||
.contains( 'h2', 'Store Operations' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ) | ||
.click(); | ||
|
||
|
||
}); | ||
}); | ||
|
||
//verify Add New Plugin button link | ||
it('Verify the Add New Plugin link near the title', () => { | ||
cy.visit('/wp-admin/admin.php?page=' + Cypress.env('pluginId') + '#/my_plugins_and_tools'); | ||
cy.get('a') | ||
.contains('Add a New Plugin') | ||
.should('be.visible') | ||
.click() | ||
cy.url().should('eq', 'https://bjo.kax.mybluehost.me/website_489152c4/wp-admin/plugin-install.php') | ||
|
||
}); | ||
}); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely failing because in the runner the href will not match this. Try something more along these lines:
The test doesn't need to click the link as that will take longer for the new page to load, since it can just check the href.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test is to verify the list of categories based on the solution plan as the catergories those are displayed for each solution(ecom,content creator and services) are different. Where in I tried to add the mock data for verify categories based on solution plan.