diff --git a/public/apps/customerror/custom-error.tsx b/public/apps/customerror/custom-error.tsx
index eb4dd9f2e..973068add 100644
--- a/public/apps/customerror/custom-error.tsx
+++ b/public/apps/customerror/custom-error.tsx
@@ -21,6 +21,7 @@ import { Router, Route } from 'react-router-dom';
import { ERROR_MISSING_ROLE_PATH } from '../../../common';
import { ClientConfigType } from '../../types';
import './_index.scss';
+import { logout } from '../account/utils';
interface CustomErrorDeps {
title: string;
@@ -45,8 +46,13 @@ export function CustomErrorPage(props: CustomErrorDeps) {
{props.subtitle}
-
- Back to OpenSearch Dashboards Home
+ logout(props.http, '')}
+ data-test-subj="error-logout-button"
+ fullWidth
+ >
+ Logout
);
@@ -74,3 +80,4 @@ export async function renderPage(
);
return () => ReactDOM.unmountComponentAtNode(params.element);
}
+export { EuiButton };
diff --git a/public/apps/customerror/test/__snapshots__/custom-error.test.tsx.snap b/public/apps/customerror/test/__snapshots__/custom-error.test.tsx.snap
new file mode 100644
index 000000000..ceb888fc1
--- /dev/null
+++ b/public/apps/customerror/test/__snapshots__/custom-error.test.tsx.snap
@@ -0,0 +1,39 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Custom error page test renders and clicks the button on the error page 1`] = `
+
+
+
+
+ Title
+
+
+
+
+ Sub Title
+
+
+
+ Logout
+
+
+`;
diff --git a/public/apps/customerror/test/custom-error.test.tsx b/public/apps/customerror/test/custom-error.test.tsx
new file mode 100644
index 000000000..18291c351
--- /dev/null
+++ b/public/apps/customerror/test/custom-error.test.tsx
@@ -0,0 +1,61 @@
+/*
+ * Copyright OpenSearch Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+import { shallow } from 'enzyme';
+import React from 'react';
+import { CustomErrorPage } from '../custom-error';
+import { cleanup } from '@testing-library/react';
+import '@testing-library/jest-dom';
+import { EuiButton } from '../custom-error';
+import { logout } from '../../account/utils';
+
+afterEach(() => {
+ cleanup();
+});
+
+describe('Custom error page test', () => {
+ let component;
+
+ beforeEach(() => {
+ component = shallow(
+
+ Logout
+
+ );
+ });
+
+ it('renders and clicks the button on the error page', () => {
+ const wrapper = shallow(
+
+ );
+
+ expect(wrapper).toMatchSnapshot();
+
+ component.find('[data-test-subj="error-logout-button"]').simulate('onClick', {
+ preventDefault: () => {},
+ });
+ });
+});