Commit 1afb0102 authored by Miguel Rincon's avatar Miguel Rincon

Merge branch 'find-migrate-ee-audit-events' into 'master'

Replace deprecated usage of find/findAll in ee/spec/frontend/audit_events

See merge request gitlab-org/gitlab!78635
parents 112e7c2f 4ad3919b
...@@ -65,32 +65,32 @@ describe('AuditEventsApp', () => { ...@@ -65,32 +65,32 @@ describe('AuditEventsApp', () => {
}); });
it('renders audit events table', () => { it('renders audit events table', () => {
expect(wrapper.find(AuditEventsTable).props()).toEqual({ expect(wrapper.findComponent(AuditEventsTable).props()).toEqual({
events, events,
isLastPage: true, isLastPage: true,
}); });
}); });
it('renders audit events filter', () => { it('renders audit events filter', () => {
expect(wrapper.find(AuditEventsFilter).props()).toEqual({ expect(wrapper.findComponent(AuditEventsFilter).props()).toEqual({
filterTokenOptions, filterTokenOptions,
value: TEST_FILTER_VALUE, value: TEST_FILTER_VALUE,
}); });
}); });
it('renders date range field', () => { it('renders date range field', () => {
expect(wrapper.find(DateRangeField).props()).toEqual({ expect(wrapper.findComponent(DateRangeField).props()).toEqual({
startDate: TEST_START_DATE, startDate: TEST_START_DATE,
endDate: TEST_END_DATE, endDate: TEST_END_DATE,
}); });
}); });
it('renders sorting field', () => { it('renders sorting field', () => {
expect(wrapper.find(SortingField).props()).toEqual({ sortBy: TEST_SORT_BY }); expect(wrapper.findComponent(SortingField).props()).toEqual({ sortBy: TEST_SORT_BY });
}); });
it('renders the audit events export button', () => { it('renders the audit events export button', () => {
expect(wrapper.find(AuditEventsExportButton).props()).toEqual({ expect(wrapper.findComponent(AuditEventsExportButton).props()).toEqual({
exportHref: exportHref:
'http://example.com/audit_log_reports.csv?created_after=2020-01-01&created_before=2020-02-02', 'http://example.com/audit_log_reports.csv?created_after=2020-01-01&created_before=2020-02-02',
}); });
...@@ -111,7 +111,7 @@ describe('AuditEventsApp', () => { ...@@ -111,7 +111,7 @@ describe('AuditEventsApp', () => {
`('for $name, it calls $handler', ({ field, action, payload }) => { `('for $name, it calls $handler', ({ field, action, payload }) => {
expect(store.dispatch).not.toHaveBeenCalled(); expect(store.dispatch).not.toHaveBeenCalled();
wrapper.find(field).vm.$emit('selected', payload); wrapper.findComponent(field).vm.$emit('selected', payload);
expect(store.dispatch).toHaveBeenCalledWith(action, payload); expect(store.dispatch).toHaveBeenCalledWith(action, payload);
}); });
...@@ -123,7 +123,7 @@ describe('AuditEventsApp', () => { ...@@ -123,7 +123,7 @@ describe('AuditEventsApp', () => {
}); });
it('does not render the audit events export button', () => { it('does not render the audit events export button', () => {
expect(wrapper.find(AuditEventsExportButton).exists()).toBe(false); expect(wrapper.findComponent(AuditEventsExportButton).exists()).toBe(false);
}); });
}); });
...@@ -133,7 +133,7 @@ describe('AuditEventsApp', () => { ...@@ -133,7 +133,7 @@ describe('AuditEventsApp', () => {
}); });
it('does not render the audit events filter', () => { it('does not render the audit events filter', () => {
expect(wrapper.find(AuditEventsFilter).exists()).toBe(false); expect(wrapper.findComponent(AuditEventsFilter).exists()).toBe(false);
}); });
}); });
}); });
...@@ -8,7 +8,7 @@ const EXPORT_HREF = 'http://example.com/audit_log_reports.csv?created_after=2020 ...@@ -8,7 +8,7 @@ const EXPORT_HREF = 'http://example.com/audit_log_reports.csv?created_after=2020
describe('AuditEventsExportButton component', () => { describe('AuditEventsExportButton component', () => {
let wrapper; let wrapper;
const findExportButton = () => wrapper.find(GlButton); const findExportButton = () => wrapper.findComponent(GlButton);
const createComponent = (props = {}) => { const createComponent = (props = {}) => {
return shallowMount(AuditEventsExportButton, { return shallowMount(AuditEventsExportButton, {
......
...@@ -9,7 +9,7 @@ describe('AuditEventsFilter', () => { ...@@ -9,7 +9,7 @@ describe('AuditEventsFilter', () => {
let wrapper; let wrapper;
const value = [{ type: 'project', value: { data: 1, operator: '=' } }]; const value = [{ type: 'project', value: { data: 1, operator: '=' } }];
const findFilteredSearch = () => wrapper.find(GlFilteredSearch); const findFilteredSearch = () => wrapper.findComponent(GlFilteredSearch);
const getAvailableTokens = () => findFilteredSearch().props('availableTokens'); const getAvailableTokens = () => findFilteredSearch().props('availableTokens');
const getAvailableTokenProps = (type) => const getAvailableTokenProps = (type) =>
getAvailableTokens().find((token) => token.type === type); getAvailableTokens().find((token) => token.type === type);
......
...@@ -21,7 +21,13 @@ describe('AuditEventsTable component', () => { ...@@ -21,7 +21,13 @@ describe('AuditEventsTable component', () => {
}; };
const getCell = (trIdx, tdIdx) => { const getCell = (trIdx, tdIdx) => {
return wrapper.find(GlTable).find('tbody').findAll('tr').at(trIdx).findAll('td').at(tdIdx); return wrapper
.findComponent(GlTable)
.find('tbody')
.findAll('tr')
.at(trIdx)
.findAll('td')
.at(tdIdx);
}; };
beforeEach(() => { beforeEach(() => {
...@@ -49,13 +55,13 @@ describe('AuditEventsTable component', () => { ...@@ -49,13 +55,13 @@ describe('AuditEventsTable component', () => {
describe('Pagination behaviour', () => { describe('Pagination behaviour', () => {
it('should show', () => { it('should show', () => {
expect(wrapper.find(GlPagination).exists()).toBe(true); expect(wrapper.findComponent(GlPagination).exists()).toBe(true);
}); });
it('should hide if there is no data', () => { it('should hide if there is no data', () => {
wrapper.setProps({ events: [] }); wrapper.setProps({ events: [] });
wrapper.vm.$nextTick(() => { wrapper.vm.$nextTick(() => {
expect(wrapper.find(GlPagination).exists()).toBe(false); expect(wrapper.findComponent(GlPagination).exists()).toBe(false);
}); });
}); });
...@@ -63,27 +69,27 @@ describe('AuditEventsTable component', () => { ...@@ -63,27 +69,27 @@ describe('AuditEventsTable component', () => {
setWindowLocation('?page=2'); setWindowLocation('?page=2');
wrapper = createComponent(); wrapper = createComponent();
expect(wrapper.find(GlPagination).props().value).toBe(2); expect(wrapper.findComponent(GlPagination).props().value).toBe(2);
}); });
it('should not have a prevPage if the page is 1', () => { it('should not have a prevPage if the page is 1', () => {
setWindowLocation('?page=1'); setWindowLocation('?page=1');
wrapper = createComponent(); wrapper = createComponent();
expect(wrapper.find(GlPagination).props().prevPage).toBe(null); expect(wrapper.findComponent(GlPagination).props().prevPage).toBe(null);
}); });
it('should set the prevPage to 1 if the page is 2', () => { it('should set the prevPage to 1 if the page is 2', () => {
setWindowLocation('?page=2'); setWindowLocation('?page=2');
wrapper = createComponent(); wrapper = createComponent();
expect(wrapper.find(GlPagination).props().prevPage).toBe(1); expect(wrapper.findComponent(GlPagination).props().prevPage).toBe(1);
}); });
it('should not have a nextPage if isLastPage is true', () => { it('should not have a nextPage if isLastPage is true', () => {
wrapper.setProps({ isLastPage: true }); wrapper.setProps({ isLastPage: true });
wrapper.vm.$nextTick(() => { wrapper.vm.$nextTick(() => {
expect(wrapper.find(GlPagination).props().nextPage).toBe(null); expect(wrapper.findComponent(GlPagination).props().nextPage).toBe(null);
}); });
}); });
...@@ -91,11 +97,11 @@ describe('AuditEventsTable component', () => { ...@@ -91,11 +97,11 @@ describe('AuditEventsTable component', () => {
setWindowLocation('?page=1'); setWindowLocation('?page=1');
wrapper = createComponent(); wrapper = createComponent();
expect(wrapper.find(GlPagination).props().nextPage).toBe(2); expect(wrapper.findComponent(GlPagination).props().nextPage).toBe(2);
}); });
it('should set the nextPage to 2 if the page is not set', () => { it('should set the nextPage to 2 if the page is not set', () => {
expect(wrapper.find(GlPagination).props().nextPage).toBe(2); expect(wrapper.findComponent(GlPagination).props().nextPage).toBe(2);
}); });
}); });
}); });
...@@ -16,8 +16,8 @@ describe('DateRangeField component', () => { ...@@ -16,8 +16,8 @@ describe('DateRangeField component', () => {
const startDate = parsePikadayDate('2020-03-13'); const startDate = parsePikadayDate('2020-03-13');
const endDate = parsePikadayDate('2020-03-14'); const endDate = parsePikadayDate('2020-03-14');
const findDatePicker = () => wrapper.find(GlDaterangePicker); const findDatePicker = () => wrapper.findComponent(GlDaterangePicker);
const findDateRangeButtons = () => wrapper.find(DateRangeButtons); const findDateRangeButtons = () => wrapper.findComponent(DateRangeButtons);
const createComponent = (props = {}, stubs = {}) => { const createComponent = (props = {}, stubs = {}) => {
wrapper = shallowMount(DateRangeField, { wrapper = shallowMount(DateRangeField, {
......
...@@ -12,7 +12,7 @@ describe('SortingField component', () => { ...@@ -12,7 +12,7 @@ describe('SortingField component', () => {
}; };
const getCheckedOptions = () => const getCheckedOptions = () =>
wrapper.findAll(GlDropdownItem).filter((item) => item.props().isChecked); wrapper.findAllComponents(GlDropdownItem).filter((item) => item.props().isChecked);
beforeEach(() => { beforeEach(() => {
initComponent(); initComponent();
...@@ -25,7 +25,7 @@ describe('SortingField component', () => { ...@@ -25,7 +25,7 @@ describe('SortingField component', () => {
describe('when initialized', () => { describe('when initialized', () => {
it('should have sorting options', () => { it('should have sorting options', () => {
expect(wrapper.findAll(GlDropdownItem)).toHaveLength(2); expect(wrapper.findAllComponents(GlDropdownItem)).toHaveLength(2);
}); });
it('should set the sorting option to `created_desc` by default', () => { it('should set the sorting option to `created_desc` by default', () => {
...@@ -49,7 +49,7 @@ describe('SortingField component', () => { ...@@ -49,7 +49,7 @@ describe('SortingField component', () => {
describe('when the user clicks on a option', () => { describe('when the user clicks on a option', () => {
beforeEach(() => { beforeEach(() => {
initComponent(); initComponent();
wrapper.findAll(GlDropdownItem).at(1).vm.$emit('click'); wrapper.findAllComponents(GlDropdownItem).at(1).vm.$emit('click');
}); });
it('should emit the "selected" event with clicked option', () => { it('should emit the "selected" event with clicked option', () => {
......
...@@ -19,7 +19,7 @@ describe('GroupToken', () => { ...@@ -19,7 +19,7 @@ describe('GroupToken', () => {
const value = { data: 123 }; const value = { data: 123 };
const config = { type: 'foo' }; const config = { type: 'foo' };
const findAuditFilterToken = () => wrapper.find(AuditFilterToken); const findAuditFilterToken = () => wrapper.findComponent(AuditFilterToken);
const initComponent = () => { const initComponent = () => {
wrapper = shallowMount(GroupToken, { wrapper = shallowMount(GroupToken, {
......
...@@ -28,7 +28,7 @@ describe('MemberToken', () => { ...@@ -28,7 +28,7 @@ describe('MemberToken', () => {
const value = { data: 123 }; const value = { data: 123 };
const config = { type: 'foo', groupId: 123 }; const config = { type: 'foo', groupId: 123 };
const findAuditFilterToken = () => wrapper.find(AuditFilterToken); const findAuditFilterToken = () => wrapper.findComponent(AuditFilterToken);
const initComponent = () => { const initComponent = () => {
wrapper = shallowMount(MemberToken, { wrapper = shallowMount(MemberToken, {
......
...@@ -19,7 +19,7 @@ describe('ProjectToken', () => { ...@@ -19,7 +19,7 @@ describe('ProjectToken', () => {
const value = { data: 123 }; const value = { data: 123 };
const config = { type: 'foo' }; const config = { type: 'foo' };
const findAuditFilterToken = () => wrapper.find(AuditFilterToken); const findAuditFilterToken = () => wrapper.findComponent(AuditFilterToken);
const initComponent = () => { const initComponent = () => {
wrapper = shallowMount(ProjectToken, { wrapper = shallowMount(ProjectToken, {
......
...@@ -24,7 +24,7 @@ describe('AuditFilterToken', () => { ...@@ -24,7 +24,7 @@ describe('AuditFilterToken', () => {
const findFilteredSearchSuggestions = () => wrapper.findAllByTestId('audit-filter-suggestion'); const findFilteredSearchSuggestions = () => wrapper.findAllByTestId('audit-filter-suggestion');
const findFilteredSearchToken = () => wrapper.find('#filtered-search-token'); const findFilteredSearchToken = () => wrapper.find('#filtered-search-token');
const findItemAvatar = () => wrapper.findByTestId('audit-filter-item-avatar'); const findItemAvatar = () => wrapper.findByTestId('audit-filter-item-avatar');
const findLoadingIcon = (type) => wrapper.find(type).find(GlLoadingIcon); const findLoadingIcon = (type) => wrapper.find(type).findComponent(GlLoadingIcon);
const findViewLoadingIcon = () => findLoadingIcon('.view'); const findViewLoadingIcon = () => findLoadingIcon('.view');
const findSuggestionsLoadingIcon = () => findLoadingIcon('.suggestions'); const findSuggestionsLoadingIcon = () => findLoadingIcon('.suggestions');
...@@ -187,7 +187,7 @@ describe('AuditFilterToken', () => { ...@@ -187,7 +187,7 @@ describe('AuditFilterToken', () => {
it('renders an avatar for each suggestion', () => { it('renders an avatar for each suggestion', () => {
mockSuggestions.forEach((suggestion, index) => { mockSuggestions.forEach((suggestion, index) => {
const avatar = findFilteredSearchSuggestions().at(index).find(GlAvatar); const avatar = findFilteredSearchSuggestions().at(index).findComponent(GlAvatar);
expect(avatar.props()).toMatchObject({ expect(avatar.props()).toMatchObject({
alt: `${suggestion.name}'s avatar`, alt: `${suggestion.name}'s avatar`,
......
...@@ -22,7 +22,7 @@ describe('UserToken', () => { ...@@ -22,7 +22,7 @@ describe('UserToken', () => {
const value = { data: 123 }; const value = { data: 123 };
const config = { type: 'foo' }; const config = { type: 'foo' };
const findAuditFilterToken = () => wrapper.find(AuditFilterToken); const findAuditFilterToken = () => wrapper.findComponent(AuditFilterToken);
const initComponent = () => { const initComponent = () => {
wrapper = shallowMount(UserToken, { wrapper = shallowMount(UserToken, {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment