Commit c0773cdd authored by Illya Klymov's avatar Illya Klymov

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

* migrate to proper use of findComponent/findAllComponents
parent 68755b38
...@@ -114,8 +114,8 @@ describe('Board card component', () => { ...@@ -114,8 +114,8 @@ describe('Board card component', () => {
createComponent({ groupId: 1 }); createComponent({ groupId: 1 });
expect(wrapper.findAll(GlLabel)).toHaveLength(3); expect(wrapper.findAllComponents(GlLabel)).toHaveLength(3);
expect(wrapper.find(GlLabel).props('title')).toContain(title); expect(wrapper.findComponent(GlLabel).props('title')).toContain(title);
}); });
it('shows no labels when the isShowingLabels state is false', () => { it('shows no labels when the isShowingLabels state is false', () => {
...@@ -130,7 +130,7 @@ describe('Board card component', () => { ...@@ -130,7 +130,7 @@ describe('Board card component', () => {
it('shows weight component', () => { it('shows weight component', () => {
createComponent(); createComponent();
expect(wrapper.find(IssueCardWeight).exists()).toBe(true); expect(wrapper.findComponent(IssueCardWeight).exists()).toBe(true);
}); });
}); });
}); });
...@@ -49,11 +49,11 @@ describe('ee/BoardContent', () => { ...@@ -49,11 +49,11 @@ describe('ee/BoardContent', () => {
}); });
it(`renders BoardContentSidebar = ${resultIssue}`, () => { it(`renders BoardContentSidebar = ${resultIssue}`, () => {
expect(wrapper.find(BoardContentSidebar).exists()).toBe(resultIssue); expect(wrapper.findComponent(BoardContentSidebar).exists()).toBe(resultIssue);
}); });
it(`renders EpicBoardContentSidebar = ${resultEpic}`, () => { it(`renders EpicBoardContentSidebar = ${resultEpic}`, () => {
expect(wrapper.find(EpicBoardContentSidebar).exists()).toBe(resultEpic); expect(wrapper.findComponent(EpicBoardContentSidebar).exists()).toBe(resultEpic);
}); });
}); });
}); });
...@@ -106,7 +106,7 @@ describe('Board List Header Component', () => { ...@@ -106,7 +106,7 @@ describe('Board List Header Component', () => {
}); });
}; };
const findSettingsButton = () => wrapper.find({ ref: 'settingsBtn' }); const findSettingsButton = () => wrapper.findComponent({ ref: 'settingsBtn' });
const findIterationPeriod = () => wrapper.find('[data-testid="board-list-iteration-period"]'); const findIterationPeriod = () => wrapper.find('[data-testid="board-list-iteration-period"]');
afterEach(() => { afterEach(() => {
...@@ -211,7 +211,7 @@ describe('Board List Header Component', () => { ...@@ -211,7 +211,7 @@ describe('Board List Header Component', () => {
await waitForPromises(); await waitForPromises();
const weightTooltip = wrapper.find({ ref: 'weightTooltip' }); const weightTooltip = wrapper.findComponent({ ref: 'weightTooltip' });
expect(weightTooltip.exists()).toBe(true); expect(weightTooltip.exists()).toBe(true);
expect(weightTooltip.text()).toContain(boardListQueryResponse().data.boardList.totalWeight); expect(weightTooltip.text()).toContain(boardListQueryResponse().data.boardList.totalWeight);
...@@ -220,7 +220,7 @@ describe('Board List Header Component', () => { ...@@ -220,7 +220,7 @@ describe('Board List Header Component', () => {
it('weightFeatureAvailable is false', () => { it('weightFeatureAvailable is false', () => {
createComponent(); createComponent();
expect(wrapper.find({ ref: 'weightTooltip' }).exists()).toBe(false); expect(wrapper.findComponent({ ref: 'weightTooltip' }).exists()).toBe(false);
}); });
}); });
......
...@@ -61,16 +61,18 @@ describe('BoardSettingsListType', () => { ...@@ -61,16 +61,18 @@ describe('BoardSettingsListType', () => {
it('renders gl-avatar-link with correct href', () => { it('renders gl-avatar-link with correct href', () => {
createComponent({ activeId: 1, boardListType: 'assignee' }); createComponent({ activeId: 1, boardListType: 'assignee' });
expect(wrapper.find(GlAvatarLink).exists()).toBe(true); expect(wrapper.findComponent(GlAvatarLink).exists()).toBe(true);
expect(wrapper.find(GlAvatarLink).attributes('href')).toBe('https://gitlab.com/root'); expect(wrapper.findComponent(GlAvatarLink).attributes('href')).toBe(
'https://gitlab.com/root',
);
}); });
it('renders gl-avatar-labeled with "root" as username and name as "root"', () => { it('renders gl-avatar-labeled with "root" as username and name as "root"', () => {
createComponent({ activeId: 1, boardListType: 'assignee' }); createComponent({ activeId: 1, boardListType: 'assignee' });
expect(wrapper.find(GlAvatarLabeled).exists()).toBe(true); expect(wrapper.findComponent(GlAvatarLabeled).exists()).toBe(true);
expect(wrapper.find(GlAvatarLabeled).attributes('label')).toBe('root'); expect(wrapper.findComponent(GlAvatarLabeled).attributes('label')).toBe('root');
expect(wrapper.find(GlAvatarLabeled).attributes('sublabel')).toBe('@root'); expect(wrapper.findComponent(GlAvatarLabeled).attributes('sublabel')).toBe('@root');
}); });
it('renders the correct list type text', () => { it('renders the correct list type text', () => {
......
...@@ -18,7 +18,7 @@ describe('BoardSettingsWipLimit', () => { ...@@ -18,7 +18,7 @@ describe('BoardSettingsWipLimit', () => {
const clickEdit = () => wrapper.find('.js-edit-button').vm.$emit('click'); const clickEdit = () => wrapper.find('.js-edit-button').vm.$emit('click');
const findRemoveWipLimit = () => wrapper.find('.js-remove-limit'); const findRemoveWipLimit = () => wrapper.find('.js-remove-limit');
const findWipLimit = () => wrapper.find('.js-wip-limit'); const findWipLimit = () => wrapper.find('.js-wip-limit');
const findInput = () => wrapper.find(GlFormInput); const findInput = () => wrapper.findComponent(GlFormInput);
const createComponent = ({ const createComponent = ({
vuexState = { activeId: listId }, vuexState = { activeId: listId },
......
...@@ -73,7 +73,7 @@ describe('EpicBoardContentSidebar', () => { ...@@ -73,7 +73,7 @@ describe('EpicBoardContentSidebar', () => {
}); });
it('confirms we render MountingPortal', () => { it('confirms we render MountingPortal', () => {
expect(wrapper.find(MountingPortal).props()).toMatchObject({ expect(wrapper.findComponent(MountingPortal).props()).toMatchObject({
mountTo: '#js-right-sidebar-portal', mountTo: '#js-right-sidebar-portal',
append: true, append: true,
name: 'epic-board-sidebar', name: 'epic-board-sidebar',
...@@ -111,7 +111,7 @@ describe('EpicBoardContentSidebar', () => { ...@@ -111,7 +111,7 @@ describe('EpicBoardContentSidebar', () => {
}); });
it('renders 2 SidebarDateWidget', () => { it('renders 2 SidebarDateWidget', () => {
expect(wrapper.findAll(SidebarDateWidget)).toHaveLength(2); expect(wrapper.findAllComponents(SidebarDateWidget)).toHaveLength(2);
}); });
it('renders SidebarParticipantsWidget', () => { it('renders SidebarParticipantsWidget', () => {
...@@ -135,7 +135,7 @@ describe('EpicBoardContentSidebar', () => { ...@@ -135,7 +135,7 @@ describe('EpicBoardContentSidebar', () => {
}); });
it('calls toggleBoardItem with correct parameters', async () => { it('calls toggleBoardItem with correct parameters', async () => {
wrapper.find(GlDrawer).vm.$emit('close'); wrapper.findComponent(GlDrawer).vm.$emit('close');
expect(toggleBoardItem).toHaveBeenCalledTimes(1); expect(toggleBoardItem).toHaveBeenCalledTimes(1);
expect(toggleBoardItem).toHaveBeenCalledWith(expect.any(Object), { expect(toggleBoardItem).toHaveBeenCalledWith(expect.any(Object), {
......
...@@ -38,7 +38,7 @@ describe('EpicFilteredSearch', () => { ...@@ -38,7 +38,7 @@ describe('EpicFilteredSearch', () => {
}); });
it('finds BoardFilteredSearch', () => { it('finds BoardFilteredSearch', () => {
expect(wrapper.find(BoardFilteredSearch).exists()).toBe(true); expect(wrapper.findComponent(BoardFilteredSearch).exists()).toBe(true);
}); });
it('passes tokens to BoardFilteredSearch', () => { it('passes tokens to BoardFilteredSearch', () => {
...@@ -73,7 +73,7 @@ describe('EpicFilteredSearch', () => { ...@@ -73,7 +73,7 @@ describe('EpicFilteredSearch', () => {
], ],
}, },
]; ];
expect(wrapper.find(BoardFilteredSearch).props('tokens').toString()).toBe( expect(wrapper.findComponent(BoardFilteredSearch).props('tokens').toString()).toBe(
orderBy(tokens, ['title']).toString(), orderBy(tokens, ['title']).toString(),
); );
}); });
......
...@@ -82,7 +82,7 @@ describe('EpicLane', () => { ...@@ -82,7 +82,7 @@ describe('EpicLane', () => {
}); });
it('displays 1 icon', () => { it('displays 1 icon', () => {
expect(wrapper.findAll(GlIcon)).toHaveLength(1); expect(wrapper.findAllComponents(GlIcon)).toHaveLength(1);
}); });
it('displays epic title', () => { it('displays epic title', () => {
...@@ -90,17 +90,17 @@ describe('EpicLane', () => { ...@@ -90,17 +90,17 @@ describe('EpicLane', () => {
}); });
it('renders one IssuesLaneList component per list passed in props', () => { it('renders one IssuesLaneList component per list passed in props', () => {
expect(wrapper.findAll(IssuesLaneList)).toHaveLength(wrapper.props('lists').length); expect(wrapper.findAllComponents(IssuesLaneList)).toHaveLength(wrapper.props('lists').length);
}); });
it('hides issues when collapsing', () => { it('hides issues when collapsing', () => {
expect(wrapper.findAll(IssuesLaneList)).toHaveLength(wrapper.props('lists').length); expect(wrapper.findAllComponents(IssuesLaneList)).toHaveLength(wrapper.props('lists').length);
expect(wrapper.vm.isCollapsed).toBe(false); expect(wrapper.vm.isCollapsed).toBe(false);
findChevronButton().vm.$emit('click'); findChevronButton().vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.findAll(IssuesLaneList)).toHaveLength(0); expect(wrapper.findAllComponents(IssuesLaneList)).toHaveLength(0);
expect(wrapper.vm.isCollapsed).toBe(true); expect(wrapper.vm.isCollapsed).toBe(true);
}); });
}); });
......
...@@ -140,7 +140,7 @@ describe('EpicsSwimlanes', () => { ...@@ -140,7 +140,7 @@ describe('EpicsSwimlanes', () => {
it('renders virtual-list', () => { it('renders virtual-list', () => {
const virtualList = wrapper.findComponent(VirtualList); const virtualList = wrapper.findComponent(VirtualList);
const scrollableContainer = wrapper.find({ ref: 'scrollableContainer' }).element; const scrollableContainer = wrapper.findComponent({ ref: 'scrollableContainer' }).element;
expect(BoardUtils.calculateSwimlanesBufferSize).toHaveBeenCalledWith( expect(BoardUtils.calculateSwimlanesBufferSize).toHaveBeenCalledWith(
wrapper.element.offsetTop, wrapper.element.offsetTop,
......
...@@ -42,7 +42,7 @@ describe('IssueBoardFilter', () => { ...@@ -42,7 +42,7 @@ describe('IssueBoardFilter', () => {
}); });
it('finds BoardFilteredSearch', () => { it('finds BoardFilteredSearch', () => {
expect(wrapper.find(BoardFilteredSearch).exists()).toBe(true); expect(wrapper.findComponent(BoardFilteredSearch).exists()).toBe(true);
}); });
it('passes the correct tokens to BoardFilteredSearch including epics', () => { it('passes the correct tokens to BoardFilteredSearch including epics', () => {
...@@ -53,7 +53,9 @@ describe('IssueBoardFilter', () => { ...@@ -53,7 +53,9 @@ describe('IssueBoardFilter', () => {
wrapper.vm.fetchIterations, wrapper.vm.fetchIterations,
); );
expect(wrapper.find(BoardFilteredSearch).props('tokens')).toEqual(orderBy(tokens, ['title'])); expect(wrapper.findComponent(BoardFilteredSearch).props('tokens')).toEqual(
orderBy(tokens, ['title']),
);
}); });
}); });
}); });
...@@ -57,7 +57,7 @@ describe('IssuesLaneList', () => { ...@@ -57,7 +57,7 @@ describe('IssuesLaneList', () => {
}); });
it('renders one BoardCard component per issue passed in props', () => { it('renders one BoardCard component per issue passed in props', () => {
expect(wrapper.findAll(BoardCard)).toHaveLength(wrapper.props('issues').length); expect(wrapper.findAllComponents(BoardCard)).toHaveLength(wrapper.props('issues').length);
}); });
}); });
...@@ -73,7 +73,7 @@ describe('IssuesLaneList', () => { ...@@ -73,7 +73,7 @@ describe('IssuesLaneList', () => {
}); });
it('does not renders BoardCard components', () => { it('does not renders BoardCard components', () => {
expect(wrapper.findAll(BoardCard)).toHaveLength(0); expect(wrapper.findAllComponents(BoardCard)).toHaveLength(0);
}); });
}); });
......
...@@ -25,13 +25,13 @@ describe('ToggleEpicsSwimlanes', () => { ...@@ -25,13 +25,13 @@ describe('ToggleEpicsSwimlanes', () => {
describe('dropdownLabel', () => { describe('dropdownLabel', () => {
it('displays "None" when isShowingEpicsSwimlanes is false', () => { it('displays "None" when isShowingEpicsSwimlanes is false', () => {
expect(wrapper.find(GlDropdown).props('text')).toEqual('None'); expect(wrapper.findComponent(GlDropdown).props('text')).toEqual('None');
}); });
it('returns "Epics" when isShowingEpicsSwimlanes is true', () => { it('returns "Epics" when isShowingEpicsSwimlanes is true', () => {
store = new Vuex.Store({ state: { isShowingEpicsSwimlanes: true } }); store = new Vuex.Store({ state: { isShowingEpicsSwimlanes: true } });
createComponent(); createComponent();
expect(wrapper.find(GlDropdown).props('text')).toEqual('Epic'); expect(wrapper.findComponent(GlDropdown).props('text')).toEqual('Epic');
}); });
}); });
...@@ -45,8 +45,8 @@ describe('ToggleEpicsSwimlanes', () => { ...@@ -45,8 +45,8 @@ describe('ToggleEpicsSwimlanes', () => {
}); });
it('renders dropdown with 2 options', () => { it('renders dropdown with 2 options', () => {
expect(wrapper.find(GlDropdown).exists()).toBe(true); expect(wrapper.findComponent(GlDropdown).exists()).toBe(true);
expect(wrapper.findAll(GlDropdownItem).length).toEqual(2); expect(wrapper.findAllComponents(GlDropdownItem).length).toEqual(2);
}); });
}); });
}); });
...@@ -5,10 +5,11 @@ import WeightSelect from 'ee/boards/components/weight_select.vue'; ...@@ -5,10 +5,11 @@ import WeightSelect from 'ee/boards/components/weight_select.vue';
describe('WeightSelect', () => { describe('WeightSelect', () => {
let wrapper; let wrapper;
const editButton = () => wrapper.find(GlButton); const editButton = () => wrapper.findComponent(GlButton);
const valueContainer = () => wrapper.find('[data-testid="selected-weight"]'); const valueContainer = () => wrapper.find('[data-testid="selected-weight"]');
const weightDropdown = () => wrapper.find(GlDropdown); const weightDropdown = () => wrapper.findComponent(GlDropdown);
const getWeightItemAtIndex = (index) => weightDropdown().findAll(GlDropdownItem).at(index); const getWeightItemAtIndex = (index) =>
weightDropdown().findAllComponents(GlDropdownItem).at(index);
const defaultProps = { const defaultProps = {
weights: ['Any', 'None', 0, 1, 2, 3], weights: ['Any', 'None', 0, 1, 2, 3],
board: { board: {
......
...@@ -38,7 +38,7 @@ describe('ToggleLabels component', () => { ...@@ -38,7 +38,7 @@ describe('ToggleLabels component', () => {
it('onStorageUpdate parses empty value as false', async () => { it('onStorageUpdate parses empty value as false', async () => {
wrapper = createComponent(); wrapper = createComponent();
const localStorageSync = wrapper.find(LocalStorageSync); const localStorageSync = wrapper.findComponent(LocalStorageSync);
localStorageSync.vm.$emit('input', ''); localStorageSync.vm.$emit('input', '');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
...@@ -49,10 +49,10 @@ describe('ToggleLabels component', () => { ...@@ -49,10 +49,10 @@ describe('ToggleLabels component', () => {
it('sets GlToggle value from store.isShowingLabels', () => { it('sets GlToggle value from store.isShowingLabels', () => {
wrapper = createComponent({ isShowingLabels: true }); wrapper = createComponent({ isShowingLabels: true });
expect(wrapper.find(GlToggle).props('value')).toEqual(true); expect(wrapper.findComponent(GlToggle).props('value')).toEqual(true);
wrapper = createComponent({ isShowingLabels: false }); wrapper = createComponent({ isShowingLabels: false });
expect(wrapper.find(GlToggle).props('value')).toEqual(false); expect(wrapper.findComponent(GlToggle).props('value')).toEqual(false);
}); });
}); });
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