@wordpress/e2e-test-utils-playwright
Version:
End-To-End (E2E) test utils for WordPress.
8 lines (7 loc) • 2.46 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/editor/site-editor.ts"],
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Editor } from './index';\n\ninterface Options {\n\t// If the only dirty entity is the current one, skip opening the save panel.\n\tisOnlyCurrentEntityDirty?: boolean;\n}\n\n/**\n * Save entities in the site editor. Assumes the editor is in a dirty state.\n *\n * @param this\n * @param options\n */\nexport async function saveSiteEditorEntities(\n\tthis: Editor,\n\toptions: Options = {}\n) {\n\tconst editorTopBar = this.page.getByRole( 'region', {\n\t\tname: 'Editor top bar',\n\t} );\n\n\t// If we have changes in a single entity which can be published the label is `Publish`.\n\tconst saveButton = editorTopBar.getByRole( 'button', {\n\t\tname: 'Save',\n\t\texact: true,\n\t} );\n\tconst publishButton = editorTopBar.getByRole( 'button', {\n\t\tname: 'Publish',\n\t} );\n\tconst publishButtonIsVisible = ! ( await saveButton.isVisible() );\n\t// First Save button in the top bar.\n\tconst buttonToClick = publishButtonIsVisible ? publishButton : saveButton;\n\tawait buttonToClick.click();\n\n\tif ( ! options.isOnlyCurrentEntityDirty ) {\n\t\t// Second Save button in the entities panel.\n\t\tawait this.page\n\t\t\t.getByRole( 'region', {\n\t\t\t\tname: /(Editor publish|Save panel)/,\n\t\t\t} )\n\t\t\t.getByRole( 'button', { name: 'Save', exact: true } )\n\t\t\t.click();\n\t}\n\t// The text in the notice can be different based on the edited entity, whether\n\t// we are saving multiple entities and whether we publish or update. So for now,\n\t// we locate it based on the last part.\n\tawait this.page\n\t\t.getByRole( 'button', { name: 'Dismiss this notice' } )\n\t\t.getByText( /(updated|published)\\./ )\n\t\t.first()\n\t\t.waitFor();\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,eAAsB,uBAErB,UAAmB,CAAC,GACnB;AACD,QAAM,eAAe,KAAK,KAAK,UAAW,UAAU;AAAA,IACnD,MAAM;AAAA,EACP,CAAE;AAGF,QAAM,aAAa,aAAa,UAAW,UAAU;AAAA,IACpD,MAAM;AAAA,IACN,OAAO;AAAA,EACR,CAAE;AACF,QAAM,gBAAgB,aAAa,UAAW,UAAU;AAAA,IACvD,MAAM;AAAA,EACP,CAAE;AACF,QAAM,yBAAyB,CAAI,MAAM,WAAW,UAAU;AAE9D,QAAM,gBAAgB,yBAAyB,gBAAgB;AAC/D,QAAM,cAAc,MAAM;AAE1B,MAAK,CAAE,QAAQ,0BAA2B;AAEzC,UAAM,KAAK,KACT,UAAW,UAAU;AAAA,MACrB,MAAM;AAAA,IACP,CAAE,EACD,UAAW,UAAU,EAAE,MAAM,QAAQ,OAAO,KAAK,CAAE,EACnD,MAAM;AAAA,EACT;AAIA,QAAM,KAAK,KACT,UAAW,UAAU,EAAE,MAAM,sBAAsB,CAAE,EACrD,UAAW,uBAAwB,EACnC,MAAM,EACN,QAAQ;AACX;",
"names": []
}