@wordpress/e2e-test-utils-playwright
Version:
End-To-End (E2E) test utils for WordPress.
8 lines (7 loc) • 2.63 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/editor/publish-post.ts"],
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Editor } from './index';\n\n/**\n * Publishes the post, resolving once the request is complete (once a notice\n * is displayed).\n *\n * @param this\n */\nexport async function publishPost( this: Editor ) {\n\t// If we have changes in other entities, the label is `Save` instead of `Publish`.\n\tconst saveButton = this.page\n\t\t.getByRole( 'region', { name: 'Editor top bar' } )\n\t\t.getByRole( 'button', { name: 'Save', exact: true } );\n\tconst publishButton = this.page\n\t\t.getByRole( 'region', { name: 'Editor top bar' } )\n\t\t.getByRole( 'button', { name: 'Publish', exact: true } );\n\tconst buttonToClick = ( await saveButton.isVisible() )\n\t\t? saveButton\n\t\t: publishButton;\n\tawait buttonToClick.click();\n\n\tconst entitiesSaveButton = this.page\n\t\t.getByRole( 'region', { name: 'Editor publish' } )\n\t\t.getByRole( 'button', { name: 'Save', exact: true } );\n\tconst isEntitiesSavePanelVisible = await entitiesSaveButton.isVisible();\n\n\t// Save any entities.\n\tif ( isEntitiesSavePanelVisible ) {\n\t\t// Handle saving entities.\n\t\tawait entitiesSaveButton.click();\n\t}\n\n\t// Handle saving just the post.\n\tawait this.page\n\t\t.getByRole( 'region', {\n\t\t\tname: 'Editor publish',\n\t\t} )\n\t\t.getByRole( 'button', { name: 'Publish', exact: true } )\n\t\t.click();\n\n\tawait this.page\n\t\t.getByRole( 'button', { name: 'Dismiss this notice' } )\n\t\t.filter( { hasText: 'published' } )\n\t\t.waitFor();\n\tconst postId = new URL( this.page.url() ).searchParams.get( 'post' );\n\n\treturn typeof postId === 'string' ? parseInt( postId, 10 ) : null;\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,eAAsB,cAA4B;AAEjD,QAAM,aAAa,KAAK,KACtB,UAAW,UAAU,EAAE,MAAM,iBAAiB,CAAE,EAChD,UAAW,UAAU,EAAE,MAAM,QAAQ,OAAO,KAAK,CAAE;AACrD,QAAM,gBAAgB,KAAK,KACzB,UAAW,UAAU,EAAE,MAAM,iBAAiB,CAAE,EAChD,UAAW,UAAU,EAAE,MAAM,WAAW,OAAO,KAAK,CAAE;AACxD,QAAM,gBAAkB,MAAM,WAAW,UAAU,IAChD,aACA;AACH,QAAM,cAAc,MAAM;AAE1B,QAAM,qBAAqB,KAAK,KAC9B,UAAW,UAAU,EAAE,MAAM,iBAAiB,CAAE,EAChD,UAAW,UAAU,EAAE,MAAM,QAAQ,OAAO,KAAK,CAAE;AACrD,QAAM,6BAA6B,MAAM,mBAAmB,UAAU;AAGtE,MAAK,4BAA6B;AAEjC,UAAM,mBAAmB,MAAM;AAAA,EAChC;AAGA,QAAM,KAAK,KACT,UAAW,UAAU;AAAA,IACrB,MAAM;AAAA,EACP,CAAE,EACD,UAAW,UAAU,EAAE,MAAM,WAAW,OAAO,KAAK,CAAE,EACtD,MAAM;AAER,QAAM,KAAK,KACT,UAAW,UAAU,EAAE,MAAM,sBAAsB,CAAE,EACrD,OAAQ,EAAE,SAAS,YAAY,CAAE,EACjC,QAAQ;AACV,QAAM,SAAS,IAAI,IAAK,KAAK,KAAK,IAAI,CAAE,EAAE,aAAa,IAAK,MAAO;AAEnE,SAAO,OAAO,WAAW,WAAW,SAAU,QAAQ,EAAG,IAAI;AAC9D;",
"names": []
}