import { FtrProviderContext } from '../ftr_provider_context' ; function extractCountFromSummary ( str ) { return parseInt ( str . split ( '\n' ) [ 1 ] , 10 ) ; } export function CopySavedObjectsToSpacePageProvider ( { getService , getPageObjects , } ) { const testSubjects = getService ( 'testSubjects' ) ; const { savedObjects , common } = getPageObjects ( [ 'savedObjects' , 'common' ] ) ; return { async openCopyToSpaceFlyoutForObject ( objectName ) { await savedObjects . searchForObject ( objectName ) ; await common . sleep ( 1000 ) ; await savedObjects . clickCopyToSpaceByTitle ( objectName ) ; await testSubjects . existOrFail ( 'copy-to-space-flyout' ) ; } , async setupForm ( { createNewCopies , overwrite , destinationSpaceId , } ) { if ( createNewCopies && overwrite ) { throw new Error ( 'createNewCopies and overwrite options cannot be used together' ) ; } if ( ! createNewCopies ) { const form = await testSubjects . find ( 'copy-to-space-form' ) ; const label = await form . findByCssSelector ( 'label[for="createNewCopiesDisabled"]' ) ; await label . click ( ) ; } if ( ! overwrite ) { const radio = await testSubjects . find ( 'cts-copyModeControl-overwriteRadioGroup' ) ; const label = await radio . findByCssSelector ( 'label[for="overwriteDisabled"]' ) ; await label . click ( ) ; } await testSubjects . click ( `cts-space-selector-row-${ destinationSpaceId }` ) ; } , async startCopy ( ) { await testSubjects . click ( 'cts-initiate-button' ) ; } , async finishCopy ( ) { await testSubjects . click ( 'cts-finish-button' ) ; await testSubjects . waitForDeleted ( 'copy-to-space-flyout' ) ; } , async getSummaryCounts ( ) { const success = extractCountFromSummary ( await testSubjects . getVisibleText ( 'cts-summary-success-count' ) ) ; const pending = extractCountFromSummary ( await testSubjects . getVisibleText ( 'cts-summary-pending-count' ) ) ; const skipped = extractCountFromSummary ( await testSubjects . getVisibleText ( 'cts-summary-skipped-count' ) ) ; const errors = extractCountFromSummary ( await testSubjects . getVisibleText ( 'cts-summary-error-count' ) ) ; return { success , pending , skipped , errors , } ; } , } ; }