From 2afacc478c0ef83670691b9877a4c4b2b06f38d7 Mon Sep 17 00:00:00 2001
From: Angela Chuang <yi-chun.chuang@elastic.co>
Date: Tue, 18 Jul 2023 10:07:30 +0100
Subject: [PATCH] review

---
 .../use_dashboard_listing_table.test.tsx      | 21 ++++++++++---------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.test.tsx b/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.test.tsx
index 1598b12b06f09..ceb53af4bf2eb 100644
--- a/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.test.tsx
+++ b/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.test.tsx
@@ -24,6 +24,7 @@ const getUiSettingsMock = jest.fn().mockImplementation((key) => {
   }
   return null;
 });
+const getPluginServices = pluginServices.getServices();
 
 jest.mock('@kbn/ebt-tools', () => ({
   reportPerformanceMetricEvent: jest.fn(),
@@ -45,19 +46,19 @@ describe('useDashboardListingTable', () => {
   beforeEach(() => {
     jest.clearAllMocks();
 
-    pluginServices.getServices().dashboardSessionStorage.dashboardHasUnsavedEdits = jest
+    getPluginServices.dashboardSessionStorage.dashboardHasUnsavedEdits = jest
       .fn()
       .mockReturnValue(true);
 
-    pluginServices.getServices().dashboardSessionStorage.getDashboardIdsWithUnsavedChanges = jest
+    getPluginServices.dashboardSessionStorage.getDashboardIdsWithUnsavedChanges = jest
       .fn()
       .mockReturnValue([]);
 
-    pluginServices.getServices().dashboardSessionStorage.clearState = clearStateMock;
-    pluginServices.getServices().dashboardCapabilities.showWriteControls = true;
-    pluginServices.getServices().dashboardContentManagement.deleteDashboards = deleteDashboards;
-    pluginServices.getServices().settings.uiSettings.get = getUiSettingsMock;
-    pluginServices.getServices().notifications.toasts.addError = jest.fn();
+    getPluginServices.dashboardSessionStorage.clearState = clearStateMock;
+    getPluginServices.dashboardCapabilities.showWriteControls = true;
+    getPluginServices.dashboardContentManagement.deleteDashboards = deleteDashboards;
+    getPluginServices.settings.uiSettings.get = getUiSettingsMock;
+    getPluginServices.notifications.toasts.addError = jest.fn();
   });
 
   test('should return the correct initial hasInitialFetchReturned state', () => {
@@ -208,7 +209,7 @@ describe('useDashboardListingTable', () => {
   });
 
   test('createItem should be undefined when showWriteControls equals false', () => {
-    pluginServices.getServices().dashboardCapabilities.showWriteControls = false;
+    getPluginServices.dashboardCapabilities.showWriteControls = false;
 
     const { result } = renderHook(() =>
       useDashboardListingTable({
@@ -221,7 +222,7 @@ describe('useDashboardListingTable', () => {
   });
 
   test('deleteItems should be undefined when showWriteControls equals false', () => {
-    pluginServices.getServices().dashboardCapabilities.showWriteControls = false;
+    getPluginServices.dashboardCapabilities.showWriteControls = false;
     const { result } = renderHook(() =>
       useDashboardListingTable({
         getDashboardUrl,
@@ -233,7 +234,7 @@ describe('useDashboardListingTable', () => {
   });
 
   test('editItem should be undefined when showWriteControls equals false', () => {
-    pluginServices.getServices().dashboardCapabilities.showWriteControls = false;
+    getPluginServices.dashboardCapabilities.showWriteControls = false;
     const { result } = renderHook(() =>
       useDashboardListingTable({
         getDashboardUrl,