UNPKG

@wordpress/e2e-test-utils-playwright

Version:
8 lines (7 loc) 3.63 kB
{ "version": 3, "sources": ["../../src/admin/visit-site-editor.ts"], "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Admin } from './';\n\ninterface SiteEditorOptions {\n\tpostId?: string | number;\n\tpostType?: string;\n\tpath?: string;\n\tcanvas?: string;\n\tactiveView?: string;\n\tshowWelcomeGuide?: boolean;\n}\n\n/**\n * Visits the Site Editor main page.\n *\n * @param this\n * @param options Options to visit the site editor.\n */\nexport async function visitSiteEditor(\n\tthis: Admin,\n\toptions: SiteEditorOptions = {}\n) {\n\tconst { postId, postType, path, canvas, activeView } = options;\n\tconst query = new URLSearchParams();\n\n\tif ( postId ) {\n\t\tquery.set( 'postId', String( postId ) );\n\t}\n\tif ( postType ) {\n\t\tquery.set( 'postType', postType );\n\t}\n\tif ( path ) {\n\t\tquery.set( 'path', path );\n\t}\n\tif ( canvas ) {\n\t\tquery.set( 'canvas', canvas );\n\t}\n\tif ( activeView ) {\n\t\tquery.set( 'activeView', activeView );\n\t}\n\n\tawait this.visitAdminPage( 'site-editor.php', query.toString() );\n\n\tif ( ! options.showWelcomeGuide ) {\n\t\tawait this.editor.setPreferences( 'core/edit-site', {\n\t\t\twelcomeGuide: false,\n\t\t\twelcomeGuideStyles: false,\n\t\t\twelcomeGuidePage: false,\n\t\t\twelcomeGuideTemplate: false,\n\t\t} );\n\t}\n\n\t/**\n\t * @todo This is a workaround for the fact that the editor canvas is seen as\n\t * ready and visible before the loading spinner is hidden. Ideally, the\n\t * content underneath the loading overlay should be marked inert until the\n\t * loading is done.\n\t */\n\tif ( ! query.size || postId || canvas === 'edit' ) {\n\t\tconst canvasLoader = this.page.locator(\n\t\t\t// Spinner was used instead of the progress bar in an earlier\n\t\t\t// version of the site editor.\n\t\t\t'.edit-site-canvas-loader, .edit-site-canvas-spinner'\n\t\t);\n\n\t\ttry {\n\t\t\t// Wait for the canvas loader to appear first, so that the locator that\n\t\t\t// waits for the hidden state doesn't resolve prematurely.\n\t\t\tawait canvasLoader.waitFor( { state: 'visible', timeout: 60_000 } );\n\t\t\tawait canvasLoader.waitFor( {\n\t\t\t\tstate: 'hidden',\n\t\t\t\t// Bigger timeout is needed for larger entities, like the Large Post\n\t\t\t\t// HTML fixture that we load for performance tests, which often\n\t\t\t\t// doesn't make it under the default timeout value.\n\t\t\t\ttimeout: 60_000,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// If the canvas loader is already disappeared, skip the waiting.\n\t\t\tawait this.page\n\t\t\t\t.getByRole( 'region', { name: 'Editor content' } )\n\t\t\t\t.waitFor();\n\t\t}\n\t}\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBA,eAAsB,gBAErB,UAA6B,CAAC,GAC7B;AACD,QAAM,EAAE,QAAQ,UAAU,MAAM,QAAQ,WAAW,IAAI;AACvD,QAAM,QAAQ,IAAI,gBAAgB;AAElC,MAAK,QAAS;AACb,UAAM,IAAK,UAAU,OAAQ,MAAO,CAAE;AAAA,EACvC;AACA,MAAK,UAAW;AACf,UAAM,IAAK,YAAY,QAAS;AAAA,EACjC;AACA,MAAK,MAAO;AACX,UAAM,IAAK,QAAQ,IAAK;AAAA,EACzB;AACA,MAAK,QAAS;AACb,UAAM,IAAK,UAAU,MAAO;AAAA,EAC7B;AACA,MAAK,YAAa;AACjB,UAAM,IAAK,cAAc,UAAW;AAAA,EACrC;AAEA,QAAM,KAAK,eAAgB,mBAAmB,MAAM,SAAS,CAAE;AAE/D,MAAK,CAAE,QAAQ,kBAAmB;AACjC,UAAM,KAAK,OAAO,eAAgB,kBAAkB;AAAA,MACnD,cAAc;AAAA,MACd,oBAAoB;AAAA,MACpB,kBAAkB;AAAA,MAClB,sBAAsB;AAAA,IACvB,CAAE;AAAA,EACH;AAQA,MAAK,CAAE,MAAM,QAAQ,UAAU,WAAW,QAAS;AAClD,UAAM,eAAe,KAAK,KAAK;AAAA;AAAA;AA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