-
Notifications
You must be signed in to change notification settings - Fork 800
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
Pinterest Block: Add an e2e test. #14096
Changes from all commits
5c7148c
1ab9535
9f62cb1
3b64f13
1084358
212c1e5
8e275ca
5b44d01
c7b338c
ac68347
5025518
fee0f22
cad7c40
2805b85
4476621
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,49 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { waitForSelector, waitAndClick, waitAndType } from '../page-helper'; | ||
|
||
export default class PinterestBlock { | ||
constructor( block, page ) { | ||
this.blockTitle = PinterestBlock.title(); | ||
this.block = block; | ||
this.page = page; | ||
this.blockSelector = '#block-' + block.clientId; | ||
} | ||
|
||
static name() { | ||
return 'pinterest'; | ||
} | ||
|
||
static title() { | ||
return 'Pinterest'; | ||
} | ||
|
||
static embedUrl() { | ||
return 'https://www.pinterest.com/pin/180003316347175596/'; | ||
} | ||
|
||
async addEmbed() { | ||
const inputSelector = this.getSelector( '.components-placeholder__input' ); | ||
const descriptionSelector = this.getSelector( "button[type='submit']" ); | ||
|
||
await waitAndClick( this.page, inputSelector ); | ||
await waitAndType( this.page, inputSelector, PinterestBlock.embedUrl() ); | ||
|
||
await waitAndClick( this.page, descriptionSelector ); | ||
} | ||
|
||
getSelector( selector ) { | ||
return `${ this.blockSelector } ${ selector }`; | ||
} | ||
|
||
/** | ||
* Checks whether block is rendered on frontend | ||
* @param {Page} page Puppeteer page instance | ||
*/ | ||
static async isRendered( page ) { | ||
const containerSelector = `.entry-content a[data-pin-do='embedPin'][href='${ PinterestBlock.embedUrl() }']`; | ||
|
||
await waitForSelector( page, containerSelector ); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import { waitAndClick, waitForSelector } from '../page-helper'; | |
|
||
export default class PostFrontendPage extends Page { | ||
constructor( page ) { | ||
const expectedSelector = '#main article.post'; | ||
const expectedSelector = '.post'; | ||
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 reviewed all of the Core default themes, there was no consistent selector with the level of specificity of I don't think the lower specificity is a problem, since it's always loading a single post page: if there's no post, the 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. Thanks! |
||
super( page, { expectedSelector } ); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,9 @@ export default class BlockEditorPage extends Page { | |
super( page, { expectedSelector, url } ); | ||
} | ||
|
||
async insertBlock( blockName ) { | ||
await searchForBlock( blockName ); | ||
const blockIconSelector = `.editor-inserter__menu button[aria-label*='${ blockName }']`; | ||
async insertBlock( blockName, blockTitle ) { | ||
await searchForBlock( blockTitle ); | ||
const blockIconSelector = `.editor-block-list-item-jetpack-${ blockName }`; | ||
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. Gutenberg removed the |
||
const jetpackPanelSelector = '.components-panel__body .jetpack-logo'; | ||
await scrollIntoView( this.page, jetpackPanelSelector ); | ||
await waitAndClick( this.page, blockIconSelector ); | ||
|
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.
I changed this to use the element returned by
waitForSelector()
, as I'd originally modifiedwaitForSelector()
to accept an XPath selector, too (9f62cb1). That's since been reverted, I have no strong feelings either way about this change.