-
Notifications
You must be signed in to change notification settings - Fork 8
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
PRESS2-1489 Add Cypress Tests for site-logo step #410
Changes from 2 commits
19ce21b
93cc06b
c3b331e
6aa3c2a
0a6e6af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// <reference types="Cypress" /> | ||
|
||
import { AdminBarCheck, BackButtonCheck, DarkBGCheck, DisabledNextButton, LightBGChcek, ProgressBarCheck, SkipButtonCheck } from "../wp-module-support/siteGen.cy"; | ||
|
||
describe( 'SiteGen Site Logo Step', function () { | ||
before( () => { | ||
cy.visit( | ||
'wp-admin/?page=nfd-onboarding#/sitgen/step/site-logo' | ||
); | ||
} ); | ||
|
||
it( 'Check for the header admin bar', () => { | ||
AdminBarCheck(); | ||
} ); | ||
|
||
it( 'Check for the existing dark background', () => { | ||
DarkBGCheck(); | ||
} ); | ||
|
||
it( 'Check for the light background', () => { | ||
LightBGChcek(); | ||
} ); | ||
|
||
it( 'Check the Progress Bar Value', () => { | ||
ProgressBarCheck('33.3333%'); | ||
}); | ||
|
||
it( 'Check for back button and go back', () => { | ||
BackButtonCheck('sitgen/step/site-logo'); | ||
} ); | ||
|
||
it( 'Check if the heading is visible', () => { | ||
cy.get('.ai-heading').should('be.visible'); | ||
} ); | ||
|
||
it( 'Check for the skip button and click', () => { | ||
SkipButtonCheck('sitgen/step/site-logo'); | ||
} ); | ||
|
||
it( 'Check if the Next Button is disabled when there is no logo', () => { | ||
DisabledNextButton(); | ||
} ); | ||
|
||
it( 'Check if Image gets uploaded and Next button is enabled', () => { | ||
const sampleLogoPath = `vendor/newfold-labs/wp-module-onboarding/tests/cypress/fixtures/image.png`; | ||
const LogoPreviewClass = '.nfd-onboarding-image-uploader--with-text__site_logo__preview'; | ||
if( | ||
cy.get('.nfd-onboarding-button--site-gen-next--disabled') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an assertion, will it have a return value true/false? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, if the element is not visible, it'll return false. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have used this in basic info step also, in earlier onboarding flow. |
||
.should('be.visible') | ||
){ | ||
cy.get(LogoPreviewClass) | ||
.should('not.exist'); | ||
}; | ||
cy.get('input[type=file]', { timeout: 10000 }) | ||
.should('exist') | ||
.selectFile( sampleLogoPath , {force: true} ) | ||
.then( () => { | ||
cy.wait( 1000 ); | ||
cy.get(LogoPreviewClass, { timeout: 10000 } ).should( 'be.visible' ); | ||
cy.get( '.nfd-onboarding-image-uploader--with-text__site_logo__preview__reset__button' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ); | ||
} ); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be the else condition? Next is enabled which means Logo is already uploaded. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
|
||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Click on next and verify if its going to social media step or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add this. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,36 @@ export const OptionsDetails = (className,textValue,optionsValue) => { | |
.click(); | ||
}; | ||
}; | ||
|
||
export const ProgressBarCheck = ( WidthPercent ) => { | ||
cy.get('.nfd-onboarding-header__progress-bar').should('be.visible'); | ||
cy.get('.nfd-onboarding-header__progress-bar__progress') | ||
.invoke('attr', 'style') | ||
.then((styleAttribute) => { | ||
const value = styleAttribute.match(/width:\s*([\d.]+%)/)[1]; | ||
expect(value).equal(WidthPercent); | ||
}); | ||
}; | ||
|
||
export const BackButtonCheck = (currURL) => { | ||
cy.get('.nfd-onboarding-button--dark') | ||
.should('be.visible') | ||
.click(); | ||
cy.url().should('not.contain', currURL); | ||
cy.go('back'); | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Click Back meaning you are in site-detail step and cy.go('back') will take us to site-logo again right? Just checking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yess. |
||
|
||
export const SkipButtonCheck = (currURL) => { | ||
cy.get('.skip-button') | ||
.should('be.visible') | ||
.contains('Skip for now') | ||
.click(); | ||
cy.url().should('not.contain', currURL); | ||
cy.go('back'); | ||
}; | ||
|
||
export const DisabledNextButton = () => { | ||
cy.get('.nfd-onboarding-button--site-gen-next--disabled') | ||
.should('be.visible') | ||
.contains( 'Next' ); | ||
}; |
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.
Verifying upon skip, url is not current URL is okay.
We need to also check if it is exactly going to next right step or not. Please verify next expected step url too.
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.
As I commented on the other PR as well. We are not checking the next page URL as in future the order of pages might change and this will lead to failing of tests. Checking the curr URL is sufficient, I guess whether the current URL changes or not.