Skip to content

Commit f492e2e

Browse files
JasonStoltzConstance
andauthored
Apply suggestions from code review
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
1 parent c371287 commit f492e2e

4 files changed

Lines changed: 11 additions & 13 deletions

File tree

x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail_logic.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ const DELETE_SUCCESS = i18n.translate(
4141
export const DocumentDetailLogic = kea<DocumentDetailLogicType>({
4242
path: ['enterprise_search', 'app_search', 'document_detail_logic'],
4343
actions: () => ({
44-
setFields: (fields: FieldDetails[]) => ({ fields }),
45-
getDocumentDetails: (documentId: string) => ({ documentId }),
46-
deleteDocument: (documentId: string) => ({ documentId }),
44+
setFields: (fields) => ({ fields }),
45+
getDocumentDetails: (documentId) => ({ documentId }),
46+
deleteDocument: (documentId) => ({ documentId }),
4747
}),
4848
reducers: () => ({
4949
dataLoading: [

x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/documents_detail_logic.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('DocumentsLogic', () => {
8989

9090
it('handles errors', async () => {
9191
mount();
92-
const promise = Promise.reject('An error occured');
92+
const promise = Promise.reject('An error occurred');
9393
http.get.mockReturnValue(promise);
9494

9595
try {
@@ -98,23 +98,23 @@ describe('DocumentsLogic', () => {
9898
} catch {
9999
// Do nothing
100100
}
101-
expect(flashAPIErrors).toHaveBeenCalledWith('An error occured');
101+
expect(flashAPIErrors).toHaveBeenCalledWith('An error occurred');
102102
});
103103
});
104104

105105
describe('deleteDocument', () => {
106-
let originalWindowConfirm: any;
106+
let confirmSpy: any;
107107
let promise: Promise<any>;
108108

109109
beforeEach(() => {
110-
originalWindowConfirm = window.confirm;
111-
window.confirm = () => true;
110+
confirmSpy = jest.spyOn(window, 'confirm');
111+
confirmSpy.mockImplementation(jest.fn(() => true));
112112
promise = Promise.resolve({});
113113
http.delete.mockReturnValue(promise);
114114
});
115115

116116
afterEach(() => {
117-
window.confirm = originalWindowConfirm;
117+
confirmSpy.mockRestore())
118118
});
119119

120120
it('will call an API endpoint and show a success message', async () => {

x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/documents_logic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export interface DocumentsLogicActions {
1515
openDocumentCreation(): void;
1616
}
1717

18-
type DocumnetsLogicType = MakeLogicType<DocumentsLogicValues, DocumentsLogicActions>;
18+
type DocumentsLogicType = MakeLogicType<DocumentsLogicValues, DocumentsLogicActions>;
1919

20-
export const DocumentsLogic = kea<DocumnetsLogicType>({
20+
export const DocumentsLogic = kea<DocumentsLogicType>({
2121
path: ['enterprise_search', 'app_search', 'documents_logic'],
2222
actions: () => ({
2323
openDocumentCreation: true,

x-pack/plugins/enterprise_search/server/routes/app_search/documents.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ describe('document routes', () => {
1717
mockRouter = new MockRouter({
1818
method: 'get',
1919
path: '/api/app_search/engines/{engineName}/documents/{documentId}',
20-
payload: 'query',
2120
});
2221

2322
registerDocumentRoutes({
@@ -43,7 +42,6 @@ describe('document routes', () => {
4342
mockRouter = new MockRouter({
4443
method: 'delete',
4544
path: '/api/app_search/engines/{engineName}/documents/{documentId}',
46-
payload: 'query',
4745
});
4846

4947
registerDocumentRoutes({

0 commit comments

Comments
 (0)