From 05c1277390469a69edb4d6a442d4bd0bdde4ca7d Mon Sep 17 00:00:00 2001
From: Tre' Seymour <wayne.seymour@elastic.co>
Date: Mon, 30 Aug 2021 10:36:53 +0100
Subject: [PATCH] [Archive Migration][Partial] discover apps-management

Comes from https://github.com/elastic/kibana/pull/102827

Helps with https://github.com/elastic/kibana/pull/108503

Piggy back off of the work from @tylersmalley
Only include the changes under the
test/functional/apps/management folder.
---
 .../apps/management/_field_formatter.ts          |  3 ++-
 .../apps/management/_handle_version_conflict.js  |  8 ++++++--
 .../management/_mgmt_import_saved_objects.js     | 16 +++++++++-------
 .../apps/management/_runtime_fields.js           |  4 ++--
 .../apps/management/_scripted_fields.js          |  4 ++--
 5 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/test/functional/apps/management/_field_formatter.ts b/test/functional/apps/management/_field_formatter.ts
index 65b1f4d324fb1..ecaa96ef18d70 100644
--- a/test/functional/apps/management/_field_formatter.ts
+++ b/test/functional/apps/management/_field_formatter.ts
@@ -32,11 +32,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
         'test_field_formatters',
         'test_logstash_reader',
       ]);
-      await esArchiver.load('test/functional/fixtures/es_archiver/discover');
+      await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
       await kibanaServer.uiSettings.replace({});
     });
 
     after(async function afterAll() {
+      await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
       await PageObjects.settings.navigateTo();
       await esArchiver.emptyKibanaIndex();
     });
diff --git a/test/functional/apps/management/_handle_version_conflict.js b/test/functional/apps/management/_handle_version_conflict.js
index 82723ad7ce967..f73489a5185b5 100644
--- a/test/functional/apps/management/_handle_version_conflict.js
+++ b/test/functional/apps/management/_handle_version_conflict.js
@@ -19,7 +19,7 @@ import expect from '@kbn/expect';
 
 export default function ({ getService, getPageObjects }) {
   const testSubjects = getService('testSubjects');
-  const esArchiver = getService('esArchiver');
+  const kibanaServer = getService('kibanaServer');
   const browser = getService('browser');
   const es = getService('es');
   const retry = getService('retry');
@@ -30,7 +30,11 @@ export default function ({ getService, getPageObjects }) {
   describe('index version conflict', function describeIndexTests() {
     before(async function () {
       await browser.setWindowSize(1200, 800);
-      await esArchiver.load('test/functional/fixtures/es_archiver/discover');
+      await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
+    });
+
+    after(async () => {
+      await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
     });
 
     it('Should be able to surface version conflict notification while creating scripted field', async function () {
diff --git a/test/functional/apps/management/_mgmt_import_saved_objects.js b/test/functional/apps/management/_mgmt_import_saved_objects.js
index 84e57a798c006..41a4ada274256 100644
--- a/test/functional/apps/management/_mgmt_import_saved_objects.js
+++ b/test/functional/apps/management/_mgmt_import_saved_objects.js
@@ -10,21 +10,23 @@ import expect from '@kbn/expect';
 import path from 'path';
 
 export default function ({ getService, getPageObjects }) {
-  const esArchiver = getService('esArchiver');
+  const kibanaServer = getService('kibanaServer');
   const PageObjects = getPageObjects(['common', 'settings', 'header', 'savedObjects']);
 
   //in 6.4.0 bug the Saved Search conflict would be resolved and get imported but the visualization
   //that referenced the saved search was not imported.( https://github.com/elastic/kibana/issues/22238)
 
   describe('mgmt saved objects', function describeIndexTests() {
-    beforeEach(async function () {
-      await esArchiver.emptyKibanaIndex();
-      await esArchiver.load('test/functional/fixtures/es_archiver/discover');
-      await PageObjects.settings.navigateTo();
+    before(async () => {
+      await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
+    });
+
+    after(async () => {
+      await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
     });
 
-    afterEach(async function () {
-      await esArchiver.unload('test/functional/fixtures/es_archiver/discover');
+    beforeEach(async function () {
+      await PageObjects.settings.navigateTo();
     });
 
     it('should import saved objects mgmt', async function () {
diff --git a/test/functional/apps/management/_runtime_fields.js b/test/functional/apps/management/_runtime_fields.js
index 745a3f9b079a4..14bd8f37d7551 100644
--- a/test/functional/apps/management/_runtime_fields.js
+++ b/test/functional/apps/management/_runtime_fields.js
@@ -9,7 +9,6 @@
 import expect from '@kbn/expect';
 
 export default function ({ getService, getPageObjects }) {
-  const esArchiver = getService('esArchiver');
   const kibanaServer = getService('kibanaServer');
   const log = getService('log');
   const browser = getService('browser');
@@ -23,13 +22,14 @@ export default function ({ getService, getPageObjects }) {
 
     before(async function () {
       await browser.setWindowSize(1200, 800);
-      await esArchiver.load('test/functional/fixtures/es_archiver/discover');
+      await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
       // delete .kibana index and then wait for Kibana to re-create it
       await kibanaServer.uiSettings.replace({});
       await kibanaServer.uiSettings.update({});
     });
 
     after(async function afterAll() {
+      await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
       await PageObjects.settings.navigateTo();
       await PageObjects.settings.clickKibanaIndexPatterns();
       await PageObjects.settings.removeLogstashIndexPatternIfExist();
diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js
index 2ff9e55c59ebb..57784e5c99bef 100644
--- a/test/functional/apps/management/_scripted_fields.js
+++ b/test/functional/apps/management/_scripted_fields.js
@@ -25,7 +25,6 @@
 import expect from '@kbn/expect';
 
 export default function ({ getService, getPageObjects }) {
-  const esArchiver = getService('esArchiver');
   const kibanaServer = getService('kibanaServer');
   const log = getService('log');
   const browser = getService('browser');
@@ -46,13 +45,14 @@ export default function ({ getService, getPageObjects }) {
 
     before(async function () {
       await browser.setWindowSize(1200, 800);
-      await esArchiver.load('test/functional/fixtures/es_archiver/discover');
+      await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
       // delete .kibana index and then wait for Kibana to re-create it
       await kibanaServer.uiSettings.replace({});
       await kibanaServer.uiSettings.update({ 'doc_table:legacy': true });
     });
 
     after(async function afterAll() {
+      await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
       await PageObjects.settings.navigateTo();
       await PageObjects.settings.clickKibanaIndexPatterns();
       await PageObjects.settings.removeLogstashIndexPatternIfExist();