Commit 8dbe5cf0 authored by Lukas Eipert's avatar Lukas Eipert Committed by Justin Ho

Fix tests relating to GLIcon

Fix all tests relating to GlIcon
parent 4c6ff73c
...@@ -91,7 +91,7 @@ RSpec.describe 'Projects > Audit Events', :js do ...@@ -91,7 +91,7 @@ RSpec.describe 'Projects > Audit Events', :js do
visit project_deploy_keys_path(project) visit project_deploy_keys_path(project)
accept_confirm do accept_confirm do
find('.ic-remove').click find('[data-testid="remove-icon"]').click
end end
visit project_audit_events_path(project) visit project_audit_events_path(project)
......
...@@ -54,7 +54,9 @@ describe('Subscription Table Row', () => { ...@@ -54,7 +54,9 @@ describe('Subscription Table Row', () => {
}); });
it('should render an icon in the header cell', () => { it('should render an icon in the header cell', () => {
expect(vm.$el.querySelector(`.header-cell .ic-${header.icon}`)).not.toBe(null); expect(vm.$el.querySelector(`.header-cell [data-testid="${header.icon}-icon"]`)).not.toBe(
null,
);
}); });
columns.forEach((col, idx) => { columns.forEach((col, idx) => {
......
...@@ -83,7 +83,9 @@ describe('Environment', () => { ...@@ -83,7 +83,9 @@ describe('Environment', () => {
}); });
it('should render arrow to open deploy boards', () => { it('should render arrow to open deploy boards', () => {
expect(wrapper.find('.deploy-board-icon .ic-chevron-down').exists()).toBe(true); expect(wrapper.find('.deploy-board-icon [data-testid="chevron-down-icon"]').exists()).toBe(
true,
);
}); });
}); });
......
...@@ -54,7 +54,7 @@ describe('Environments Folder View', () => { ...@@ -54,7 +54,7 @@ describe('Environments Folder View', () => {
describe('deploy boards', () => { describe('deploy boards', () => {
it('should render arrow to open deploy boards', () => { it('should render arrow to open deploy boards', () => {
expect(wrapper.find('.folder-icon.ic-chevron-right').exists()).toBe(true); expect(wrapper.find('.folder-icon[data-testid="chevron-right-icon"]').exists()).toBe(true);
}); });
}); });
}); });
......
...@@ -94,11 +94,11 @@ exports[`Environment Header renders name and link to app matches the snapshot 1` ...@@ -94,11 +94,11 @@ exports[`Environment Header renders name and link to app matches the snapshot 1`
View app View app
<svg <svg
aria-hidden="true" class="fgray gl-icon s16"
class="fgray s16 ic-external-link" data-testid="external-link-icon"
> >
<use <use
xlink:href="#external-link" href="#external-link"
/> />
</svg> </svg>
</a> </a>
......
...@@ -65,7 +65,7 @@ describe('GeoNodeHeader', () => { ...@@ -65,7 +65,7 @@ describe('GeoNodeHeader', () => {
}); });
it(`should ${showWarning ? 'render' : 'not render'} the status icon`, () => { it(`should ${showWarning ? 'render' : 'not render'} the status icon`, () => {
expect(Boolean(vm.$el.querySelector('.ic-warning'))).toBe(showWarning); expect(Boolean(vm.$el.querySelector('[data-testid="warning-icon"]'))).toBe(showWarning);
}); });
}); });
}); });
......
...@@ -63,7 +63,7 @@ describe('SectionRevealButton', () => { ...@@ -63,7 +63,7 @@ describe('SectionRevealButton', () => {
describe('template', () => { describe('template', () => {
it('renders button element', () => { it('renders button element', () => {
expect(vm.$el.classList.contains('btn-link')).toBe(true); expect(vm.$el.classList.contains('btn-link')).toBe(true);
expect(vm.$el.querySelector('svg use').getAttribute('xlink:href')).toContain('#angle-down'); expect(vm.$el.querySelector('svg').getAttribute('data-testid')).toBe('angle-down-icon');
expect(vm.$el.querySelector('span').innerText.trim()).toBe('Foo button'); expect(vm.$el.querySelector('span').innerText.trim()).toBe('Foo button');
}); });
}); });
......
...@@ -71,8 +71,8 @@ describe('GeoReplicableStatus', () => { ...@@ -71,8 +71,8 @@ describe('GeoReplicableStatus', () => {
expect(wrapper.vm.icon.cssClass).toEqual(iconClass); expect(wrapper.vm.icon.cssClass).toEqual(iconClass);
}); });
it(`sets svg to ic-${iconName}`, () => { it(`sets svg to icon '${iconName}'`, () => {
expect(findIcon().classes()).toContain(`ic-${wrapper.vm.icon.name}`); expect(findIcon().attributes('data-testid')).toBe(`${wrapper.vm.icon.name}-icon`);
}); });
}); });
}); });
......
...@@ -87,9 +87,7 @@ describe('TableHeaderComponent', () => { ...@@ -87,9 +87,7 @@ describe('TableHeaderComponent', () => {
expect(headerItemEl).not.toBeNull(); expect(headerItemEl).not.toBeNull();
expect(headerItemEl.innerText.trim()).toBe('Name'); expect(headerItemEl.innerText.trim()).toBe('Name');
expect(headerItemEl.querySelector('svg use').getAttribute('xlink:href')).toContain( expect(headerItemEl.querySelector('svg').getAttribute('data-testid')).toBe('angle-up-icon');
'angle-up',
);
}); });
}); });
}); });
...@@ -41,11 +41,11 @@ exports[`UnscannedProjects component header matches the snapshot when the "helpP ...@@ -41,11 +41,11 @@ exports[`UnscannedProjects component header matches the snapshot when the "helpP
title="Project scanning help page" title="Project scanning help page"
> >
<svg <svg
aria-hidden="true" class="align-top gl-icon s12"
class="align-top s12 ic-question" data-testid="question-icon"
> >
<use <use
xlink:href="#question" href="#question"
/> />
</svg> </svg>
</a> </a>
......
...@@ -49,11 +49,11 @@ exports[`Vulnerability Severity component when the data has loaded matches snaps ...@@ -49,11 +49,11 @@ exports[`Vulnerability Severity component when the data has loaded matches snaps
class="d-flex align-items-center p-2" class="d-flex align-items-center p-2"
> >
<svg <svg
aria-hidden="true" class="mr-2 gl-text-gray-900 gl-icon s16"
class="mr-2 gl-text-gray-900 s16 ic-angle-right" data-testid="angle-right-icon"
> >
<use <use
xlink:href="#angle-right" href="#angle-right"
/> />
</svg> </svg>
...@@ -126,11 +126,11 @@ exports[`Vulnerability Severity component when the data has loaded matches snaps ...@@ -126,11 +126,11 @@ exports[`Vulnerability Severity component when the data has loaded matches snaps
class="d-flex align-items-center p-2" class="d-flex align-items-center p-2"
> >
<svg <svg
aria-hidden="true" class="mr-2 gl-text-gray-900 gl-icon s16"
class="mr-2 gl-text-gray-900 s16 ic-angle-right" data-testid="angle-right-icon"
> >
<use <use
xlink:href="#angle-right" href="#angle-right"
/> />
</svg> </svg>
...@@ -203,11 +203,11 @@ exports[`Vulnerability Severity component when the data has loaded matches snaps ...@@ -203,11 +203,11 @@ exports[`Vulnerability Severity component when the data has loaded matches snaps
class="d-flex align-items-center p-2" class="d-flex align-items-center p-2"
> >
<svg <svg
aria-hidden="true" class="mr-2 gl-text-gray-900 gl-icon s16"
class="mr-2 gl-text-gray-900 s16 ic-angle-right" data-testid="angle-right-icon"
> >
<use <use
xlink:href="#angle-right" href="#angle-right"
/> />
</svg> </svg>
...@@ -280,11 +280,11 @@ exports[`Vulnerability Severity component when the data has loaded matches snaps ...@@ -280,11 +280,11 @@ exports[`Vulnerability Severity component when the data has loaded matches snaps
class="d-flex align-items-center p-2" class="d-flex align-items-center p-2"
> >
<svg <svg
aria-hidden="true" class="mr-2 gl-text-gray-900 gl-icon s16"
class="mr-2 gl-text-gray-900 s16 ic-angle-right" data-testid="angle-right-icon"
> >
<use <use
xlink:href="#angle-right" href="#angle-right"
/> />
</svg> </svg>
...@@ -357,11 +357,11 @@ exports[`Vulnerability Severity component when the data has loaded matches snaps ...@@ -357,11 +357,11 @@ exports[`Vulnerability Severity component when the data has loaded matches snaps
class="d-flex align-items-center p-2" class="d-flex align-items-center p-2"
> >
<svg <svg
aria-hidden="true" class="mr-2 gl-text-gray-900 gl-icon s16"
class="mr-2 gl-text-gray-900 s16 ic-angle-right" data-testid="angle-right-icon"
> >
<use <use
xlink:href="#angle-right" href="#angle-right"
/> />
</svg> </svg>
......
...@@ -36,7 +36,7 @@ describe('Security Dashboard Table Row', () => { ...@@ -36,7 +36,7 @@ describe('Security Dashboard Table Row', () => {
const findLoader = () => wrapper.find('.js-skeleton-loader'); const findLoader = () => wrapper.find('.js-skeleton-loader');
const findContent = i => wrapper.findAll('.table-mobile-content').at(i); const findContent = i => wrapper.findAll('.table-mobile-content').at(i);
const findAllIssueCreated = () => wrapper.findAll('.ic-issue-created'); const findAllIssueCreated = () => wrapper.findAll('[data-testid="issue-created-icon"]');
const hasSelectedClass = () => wrapper.classes('gl-bg-blue-50'); const hasSelectedClass = () => wrapper.classes('gl-bg-blue-50');
const findCheckbox = () => wrapper.find(GlFormCheckbox); const findCheckbox = () => wrapper.find(GlFormCheckbox);
...@@ -173,7 +173,7 @@ describe('Security Dashboard Table Row', () => { ...@@ -173,7 +173,7 @@ describe('Security Dashboard Table Row', () => {
createComponent(mount, { props: { vulnerability } }); createComponent(mount, { props: { vulnerability } });
}); });
it('should have a `ic-issue-created` class', () => { it('should have a `issue-created` icon', () => {
expect(findAllIssueCreated()).toHaveLength(1); expect(findAllIssueCreated()).toHaveLength(1);
}); });
}); });
...@@ -185,7 +185,7 @@ describe('Security Dashboard Table Row', () => { ...@@ -185,7 +185,7 @@ describe('Security Dashboard Table Row', () => {
createComponent(mount, { props: { vulnerability } }); createComponent(mount, { props: { vulnerability } });
}); });
it('should not have a `ic-issue-created` class', () => { it('should not have a `issue-created` icon', () => {
expect(findAllIssueCreated()).toHaveLength(0); expect(findAllIssueCreated()).toHaveLength(0);
}); });
}); });
...@@ -197,7 +197,7 @@ describe('Security Dashboard Table Row', () => { ...@@ -197,7 +197,7 @@ describe('Security Dashboard Table Row', () => {
createComponent(shallowMount, { props: { vulnerability } }); createComponent(shallowMount, { props: { vulnerability } });
}); });
it('should not have a `ic-issue-created` class', () => { it('should not have a `issue-created` icon', () => {
expect(findAllIssueCreated()).toHaveLength(0); expect(findAllIssueCreated()).toHaveLength(0);
}); });
......
...@@ -90,7 +90,9 @@ describe('system note component', () => { ...@@ -90,7 +90,9 @@ describe('system note component', () => {
expect(findDescriptionVersion().html()).toContain(diffData); expect(findDescriptionVersion().html()).toContain(diffData);
expect( expect(
wrapper wrapper
.find('.description-version button.delete-description-history svg.ic-remove') .find(
'.description-version button.delete-description-history svg[data-testid="remove-icon"]',
)
.exists(), .exists(),
).toBe(true); ).toBe(true);
done(); done();
......
...@@ -167,7 +167,7 @@ describe('AdminLicenseManagementRow', () => { ...@@ -167,7 +167,7 @@ describe('AdminLicenseManagementRow', () => {
const buttonEl = findRemoveButton(); const buttonEl = findRemoveButton();
expect(buttonEl).not.toBeNull(); expect(buttonEl).not.toBeNull();
expect(buttonEl.querySelector('.ic-remove')).not.toBeNull(); expect(buttonEl.querySelector('[data-testid="remove-icon"]')).not.toBeNull();
}); });
it('renders computed property dropdownText into dropdown toggle', () => { it('renders computed property dropdownText into dropdown toggle', () => {
......
...@@ -82,7 +82,7 @@ RSpec.describe 'Merge request > User posts notes', :js do ...@@ -82,7 +82,7 @@ RSpec.describe 'Merge request > User posts notes', :js do
it 'shows a reply button' do it 'shows a reply button' do
reply_button = find('.js-reply-button', match: :first) reply_button = find('.js-reply-button', match: :first)
expect(reply_button).to have_selector('.ic-comment') expect(reply_button).to have_selector('[data-testid="comment-icon"]')
end end
it 'shows reply placeholder when clicking reply button' do it 'shows reply placeholder when clicking reply button' do
......
...@@ -22,7 +22,7 @@ RSpec.describe 'Project deploy keys', :js do ...@@ -22,7 +22,7 @@ RSpec.describe 'Project deploy keys', :js do
page.within(find('.qa-deploy-keys-settings')) do page.within(find('.qa-deploy-keys-settings')) do
expect(page).to have_selector('.deploy-key', count: 1) expect(page).to have_selector('.deploy-key', count: 1)
accept_confirm { find('.ic-remove').click } accept_confirm { find('[data-testid="remove-icon"]').click }
wait_for_requests wait_for_requests
......
...@@ -106,7 +106,7 @@ RSpec.describe 'Environments page', :js do ...@@ -106,7 +106,7 @@ RSpec.describe 'Environments page', :js do
expect(page).to have_css('.environments-container') expect(page).to have_css('.environments-container')
expect(page.all('.environment-name').length).to eq(1) expect(page.all('.environment-name').length).to eq(1)
expect(page.all('.ic-stop').length).to eq(0) expect(page.all('[data-testid="stop-icon"]').length).to eq(0)
end end
end end
end end
...@@ -301,7 +301,7 @@ RSpec.describe 'Environments page', :js do ...@@ -301,7 +301,7 @@ RSpec.describe 'Environments page', :js do
end end
it 'has a dropdown for actionable jobs' do it 'has a dropdown for actionable jobs' do
expect(page).to have_selector('.dropdown-new.btn.btn-default .ic-play') expect(page).to have_selector('.dropdown-new.btn.btn-default [data-testid="play-icon"]')
end end
it "has link to the delayed job's action" do it "has link to the delayed job's action" do
......
...@@ -70,7 +70,7 @@ RSpec.describe 'Projects > Settings > Repository settings' do ...@@ -70,7 +70,7 @@ RSpec.describe 'Projects > Settings > Repository settings' do
project.deploy_keys << private_deploy_key project.deploy_keys << private_deploy_key
visit project_settings_repository_path(project) visit project_settings_repository_path(project)
find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click find('.deploy-key', text: private_deploy_key.title).find('[data-testid="pencil-icon"]').click
fill_in 'deploy_key_title', with: 'updated_deploy_key' fill_in 'deploy_key_title', with: 'updated_deploy_key'
check 'deploy_key_deploy_keys_projects_attributes_0_can_push' check 'deploy_key_deploy_keys_projects_attributes_0_can_push'
...@@ -84,7 +84,7 @@ RSpec.describe 'Projects > Settings > Repository settings' do ...@@ -84,7 +84,7 @@ RSpec.describe 'Projects > Settings > Repository settings' do
project.deploy_keys << public_deploy_key project.deploy_keys << public_deploy_key
visit project_settings_repository_path(project) visit project_settings_repository_path(project)
find('.deploy-key', text: public_deploy_key.title).find('.ic-pencil').click find('.deploy-key', text: public_deploy_key.title).find('[data-testid="pencil-icon"]').click
check 'deploy_key_deploy_keys_projects_attributes_0_can_push' check 'deploy_key_deploy_keys_projects_attributes_0_can_push'
click_button 'Save changes' click_button 'Save changes'
...@@ -102,7 +102,7 @@ RSpec.describe 'Projects > Settings > Repository settings' do ...@@ -102,7 +102,7 @@ RSpec.describe 'Projects > Settings > Repository settings' do
find('.js-deployKeys-tab-available_project_keys').click find('.js-deployKeys-tab-available_project_keys').click
find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click find('.deploy-key', text: private_deploy_key.title).find('[data-testid="pencil-icon"]').click
fill_in 'deploy_key_title', with: 'updated_deploy_key' fill_in 'deploy_key_title', with: 'updated_deploy_key'
click_button 'Save changes' click_button 'Save changes'
...@@ -116,7 +116,7 @@ RSpec.describe 'Projects > Settings > Repository settings' do ...@@ -116,7 +116,7 @@ RSpec.describe 'Projects > Settings > Repository settings' do
project.deploy_keys << private_deploy_key project.deploy_keys << private_deploy_key
visit project_settings_repository_path(project) visit project_settings_repository_path(project)
accept_confirm { find('.deploy-key', text: private_deploy_key.title).find('.ic-remove').click } accept_confirm { find('.deploy-key', text: private_deploy_key.title).find('[data-testid="remove-icon"]').click }
expect(page).not_to have_content(private_deploy_key.title) expect(page).not_to have_content(private_deploy_key.title)
end end
......
...@@ -47,9 +47,9 @@ describe('Issuable right sidebar collapsed todo toggle', () => { ...@@ -47,9 +47,9 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
expect( expect(
document document
.querySelector('.js-issuable-todo.sidebar-collapsed-icon svg use') .querySelector('.js-issuable-todo.sidebar-collapsed-icon svg')
.getAttribute('xlink:href'), .getAttribute('data-testid'),
).toContain('todo-add'); ).toBe('todo-add-icon');
expect( expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon .todo-undone'), document.querySelector('.js-issuable-todo.sidebar-collapsed-icon .todo-undone'),
...@@ -72,9 +72,9 @@ describe('Issuable right sidebar collapsed todo toggle', () => { ...@@ -72,9 +72,9 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
expect( expect(
document document
.querySelector('.js-issuable-todo.sidebar-collapsed-icon svg.todo-undone use') .querySelector('.js-issuable-todo.sidebar-collapsed-icon svg.todo-undone')
.getAttribute('xlink:href'), .getAttribute('data-testid'),
).toContain('todo-done'); ).toBe('todo-done-icon');
done(); done();
}); });
......
...@@ -55,20 +55,20 @@ describe('Deploy keys key', () => { ...@@ -55,20 +55,20 @@ describe('Deploy keys key', () => {
it('shows pencil button for editing', () => { it('shows pencil button for editing', () => {
createComponent({ deployKey }); createComponent({ deployKey });
expect(wrapper.find('.btn .ic-pencil')).toExist(); expect(wrapper.find('.btn [data-testid="pencil-icon"]')).toExist();
}); });
it('shows disable button when the project is not deletable', () => { it('shows disable button when the project is not deletable', () => {
createComponent({ deployKey }); createComponent({ deployKey });
expect(wrapper.find('.btn .ic-cancel')).toExist(); expect(wrapper.find('.btn [data-testid="cancel-icon"]')).toExist();
}); });
it('shows remove button when the project is deletable', () => { it('shows remove button when the project is deletable', () => {
createComponent({ createComponent({
deployKey: { ...deployKey, destroyed_when_orphaned: true, almost_orphaned: true }, deployKey: { ...deployKey, destroyed_when_orphaned: true, almost_orphaned: true },
}); });
expect(wrapper.find('.btn .ic-remove')).toExist(); expect(wrapper.find('.btn [data-testid="remove-icon"]')).toExist();
}); });
}); });
...@@ -147,7 +147,7 @@ describe('Deploy keys key', () => { ...@@ -147,7 +147,7 @@ describe('Deploy keys key', () => {
it('shows pencil button for editing', () => { it('shows pencil button for editing', () => {
createComponent({ deployKey }); createComponent({ deployKey });
expect(wrapper.find('.btn .ic-pencil')).toExist(); expect(wrapper.find('.btn [data-testid="pencil-icon"]')).toExist();
}); });
it('shows disable button when key is enabled', () => { it('shows disable button when key is enabled', () => {
...@@ -155,7 +155,7 @@ describe('Deploy keys key', () => { ...@@ -155,7 +155,7 @@ describe('Deploy keys key', () => {
createComponent({ deployKey }); createComponent({ deployKey });
expect(wrapper.find('.btn .ic-cancel')).toExist(); expect(wrapper.find('.btn [data-testid="cancel-icon"]')).toExist();
}); });
}); });
}); });
...@@ -144,16 +144,16 @@ describe('Environment', () => { ...@@ -144,16 +144,16 @@ describe('Environment', () => {
}); });
it('should open a closed folder', () => { it('should open a closed folder', () => {
expect(wrapper.find('.folder-icon.ic-chevron-right').exists()).toBe(false); expect(wrapper.find('.folder-icon[data-testid="chevron-right-icon"]').exists()).toBe(false);
}); });
it('should close an opened folder', () => { it('should close an opened folder', () => {
expect(wrapper.find('.folder-icon.ic-chevron-down').exists()).toBe(true); expect(wrapper.find('.folder-icon[data-testid="chevron-down-icon"]').exists()).toBe(true);
// close folder // close folder
wrapper.find('.folder-name').trigger('click'); wrapper.find('.folder-name').trigger('click');
wrapper.vm.$nextTick(() => { wrapper.vm.$nextTick(() => {
expect(wrapper.find('.folder-icon.ic-chevron-down').exists()).toBe(false); expect(wrapper.find('.folder-icon[data-testid="chevron-down-icon"]').exists()).toBe(false);
}); });
}); });
......
...@@ -57,8 +57,8 @@ describe('ItemActionsComponent', () => { ...@@ -57,8 +57,8 @@ describe('ItemActionsComponent', () => {
expect(editBtn.getAttribute('href')).toBe(group.editPath); expect(editBtn.getAttribute('href')).toBe(group.editPath);
expect(editBtn.getAttribute('aria-label')).toBe('Edit group'); expect(editBtn.getAttribute('aria-label')).toBe('Edit group');
expect(editBtn.dataset.originalTitle).toBe('Edit group'); expect(editBtn.dataset.originalTitle).toBe('Edit group');
expect(editBtn.querySelectorAll('svg use').length).not.toBe(0); expect(editBtn.querySelectorAll('svg').length).not.toBe(0);
expect(editBtn.querySelector('svg use').getAttribute('xlink:href')).toContain('#settings'); expect(editBtn.querySelector('svg').getAttribute('data-testid')).toBe('settings-icon');
newVm.$destroy(); newVm.$destroy();
}); });
...@@ -75,8 +75,8 @@ describe('ItemActionsComponent', () => { ...@@ -75,8 +75,8 @@ describe('ItemActionsComponent', () => {
expect(leaveBtn.getAttribute('href')).toBe(group.leavePath); expect(leaveBtn.getAttribute('href')).toBe(group.leavePath);
expect(leaveBtn.getAttribute('aria-label')).toBe('Leave this group'); expect(leaveBtn.getAttribute('aria-label')).toBe('Leave this group');
expect(leaveBtn.dataset.originalTitle).toBe('Leave this group'); expect(leaveBtn.dataset.originalTitle).toBe('Leave this group');
expect(leaveBtn.querySelectorAll('svg use').length).not.toBe(0); expect(leaveBtn.querySelectorAll('svg').length).not.toBe(0);
expect(leaveBtn.querySelector('svg use').getAttribute('xlink:href')).toContain('#leave'); expect(leaveBtn.querySelector('svg').getAttribute('data-testid')).toBe('leave-icon');
newVm.$destroy(); newVm.$destroy();
}); });
......
...@@ -27,12 +27,12 @@ describe('ItemCaretComponent', () => { ...@@ -27,12 +27,12 @@ describe('ItemCaretComponent', () => {
it('should render caret down icon if `isGroupOpen` prop is `true`', () => { it('should render caret down icon if `isGroupOpen` prop is `true`', () => {
vm = createComponent(true); vm = createComponent(true);
expect(vm.$el.querySelector('svg use').getAttribute('xlink:href')).toContain('angle-down'); expect(vm.$el.querySelector('svg').getAttribute('data-testid')).toBe('angle-down-icon');
}); });
it('should render caret right icon if `isGroupOpen` prop is `false`', () => { it('should render caret right icon if `isGroupOpen` prop is `false`', () => {
vm = createComponent(); vm = createComponent();
expect(vm.$el.querySelector('svg use').getAttribute('xlink:href')).toContain('angle-right'); expect(vm.$el.querySelector('svg').getAttribute('data-testid')).toBe('angle-right-icon');
}); });
}); });
}); });
...@@ -72,7 +72,7 @@ describe('ItemStatsValueComponent', () => { ...@@ -72,7 +72,7 @@ describe('ItemStatsValueComponent', () => {
}); });
it('renders element icon correctly', () => { it('renders element icon correctly', () => {
expect(vm.$el.querySelector('svg use').getAttribute('xlink:href')).toContain('folder'); expect(vm.$el.querySelector('svg').getAttribute('data-testid')).toBe('folder-icon');
}); });
it('renders value count correctly', () => { it('renders value count correctly', () => {
......
...@@ -27,12 +27,12 @@ describe('ItemTypeIconComponent', () => { ...@@ -27,12 +27,12 @@ describe('ItemTypeIconComponent', () => {
vm = createComponent(ITEM_TYPE.GROUP, true); vm = createComponent(ITEM_TYPE.GROUP, true);
expect(vm.$el.querySelector('use').getAttribute('xlink:href')).toContain('folder-open'); expect(vm.$el.querySelector('svg').getAttribute('data-testid')).toBe('folder-open-icon');
vm.$destroy(); vm.$destroy();
vm = createComponent(ITEM_TYPE.GROUP); vm = createComponent(ITEM_TYPE.GROUP);
expect(vm.$el.querySelector('use').getAttribute('xlink:href')).toContain('folder'); expect(vm.$el.querySelector('svg').getAttribute('data-testid')).toBe('folder-icon');
vm.$destroy(); vm.$destroy();
}); });
...@@ -41,12 +41,12 @@ describe('ItemTypeIconComponent', () => { ...@@ -41,12 +41,12 @@ describe('ItemTypeIconComponent', () => {
vm = createComponent(ITEM_TYPE.PROJECT); vm = createComponent(ITEM_TYPE.PROJECT);
expect(vm.$el.querySelector('use').getAttribute('xlink:href')).toContain('bookmark'); expect(vm.$el.querySelector('svg').getAttribute('data-testid')).toBe('bookmark-icon');
vm.$destroy(); vm.$destroy();
vm = createComponent(ITEM_TYPE.GROUP); vm = createComponent(ITEM_TYPE.GROUP);
expect(vm.$el.querySelector('use').getAttribute('xlink:href')).not.toContain('bookmark'); expect(vm.$el.querySelector('svg').getAttribute('data-testid')).not.toBe('bookmark-icon');
vm.$destroy(); vm.$destroy();
}); });
}); });
......
...@@ -153,14 +153,14 @@ describe('IDE extra file row component', () => { ...@@ -153,14 +153,14 @@ describe('IDE extra file row component', () => {
describe('merge request icon', () => { describe('merge request icon', () => {
it('hides when not a merge request change', () => { it('hides when not a merge request change', () => {
expect(vm.$el.querySelector('.ic-git-merge')).toBe(null); expect(vm.$el.querySelector('[data-testid="git-merge-icon"]')).toBe(null);
}); });
it('shows when a merge request change', done => { it('shows when a merge request change', done => {
vm.file.mrChange = true; vm.file.mrChange = true;
vm.$nextTick(() => { vm.$nextTick(() => {
expect(vm.$el.querySelector('.ic-git-merge')).not.toBe(null); expect(vm.$el.querySelector('[data-testid="git-merge-icon"]')).not.toBe(null);
done(); done();
}); });
......
...@@ -23,6 +23,8 @@ describe('IDE job description', () => { ...@@ -23,6 +23,8 @@ describe('IDE job description', () => {
}); });
it('renders CI icon', () => { it('renders CI icon', () => {
expect(vm.$el.querySelector('.ci-status-icon .ic-status_success_borderless')).not.toBe(null); expect(
vm.$el.querySelector('.ci-status-icon [data-testid="status_success_borderless-icon"]'),
).not.toBe(null);
}); });
}); });
...@@ -24,7 +24,7 @@ describe('IDE jobs item', () => { ...@@ -24,7 +24,7 @@ describe('IDE jobs item', () => {
}); });
it('renders CI icon', () => { it('renders CI icon', () => {
expect(vm.$el.querySelector('.ic-status_success_borderless')).not.toBe(null); expect(vm.$el.querySelector('[data-testid="status_success_borderless-icon"]')).not.toBe(null);
}); });
it('does not render view logs button if not started', done => { it('does not render view logs button if not started', done => {
......
...@@ -33,7 +33,7 @@ describe('IDE merge request item', () => { ...@@ -33,7 +33,7 @@ describe('IDE merge request item', () => {
store, store,
}); });
}; };
const findIcon = () => wrapper.find('.ic-mobile-issue-close'); const findIcon = () => wrapper.find('[data-testid="mobile-issue-close-icon"]');
beforeEach(() => { beforeEach(() => {
store = createStore(); store = createStore();
......
...@@ -23,7 +23,7 @@ describe('NavDropdown', () => { ...@@ -23,7 +23,7 @@ describe('NavDropdown', () => {
vm.$mount(); vm.$mount();
}; };
const findIcon = name => vm.$el.querySelector(`.ic-${name}`); const findIcon = name => vm.$el.querySelector(`[data-testid="${name}-icon]`);
const findMRIcon = () => findIcon('merge-request'); const findMRIcon = () => findIcon('merge-request');
const findBranchIcon = () => findIcon('branch'); const findBranchIcon = () => findIcon('branch');
......
...@@ -28,7 +28,7 @@ describe('IDE new entry dropdown button component', () => { ...@@ -28,7 +28,7 @@ describe('IDE new entry dropdown button component', () => {
}); });
it('renders icon', () => { it('renders icon', () => {
expect(vm.$el.querySelector('.ic-doc-new')).not.toBe(null); expect(vm.$el.querySelector('[data-testid="doc-new-icon"]')).not.toBe(null);
}); });
it('emits click event', () => { it('emits click event', () => {
......
...@@ -35,7 +35,7 @@ describe('Job Log Collapsible Section', () => { ...@@ -35,7 +35,7 @@ describe('Job Log Collapsible Section', () => {
}); });
it('renders an icon with the closed state', () => { it('renders an icon with the closed state', () => {
expect(findCollapsibleLineSvg().classes()).toContain('ic-angle-right'); expect(findCollapsibleLineSvg().attributes('data-testid')).toBe('angle-right-icon');
}); });
}); });
...@@ -52,7 +52,7 @@ describe('Job Log Collapsible Section', () => { ...@@ -52,7 +52,7 @@ describe('Job Log Collapsible Section', () => {
}); });
it('renders an icon with the open state', () => { it('renders an icon with the open state', () => {
expect(findCollapsibleLineSvg().classes()).toContain('ic-angle-down'); expect(findCollapsibleLineSvg().attributes('data-testid')).toBe('angle-down-icon');
}); });
it('renders collapsible lines content', () => { it('renders collapsible lines content', () => {
......
...@@ -9,8 +9,8 @@ export default { ...@@ -9,8 +9,8 @@ export default {
} }
const iconReferences = [].slice.apply(element.querySelectorAll('svg use')); const iconReferences = [].slice.apply(element.querySelectorAll('svg use'));
const matchingIcon = iconReferences.find(reference => const matchingIcon = iconReferences.find(
reference.getAttribute('xlink:href').endsWith(`#${iconName}`), reference => reference.parentNode.getAttribute('data-testid') === `${iconName}-icon`,
); );
const pass = Boolean(matchingIcon); const pass = Boolean(matchingIcon);
...@@ -22,7 +22,7 @@ export default { ...@@ -22,7 +22,7 @@ export default {
message = `${element.outerHTML} does not contain the sprite icon "${iconName}"!`; message = `${element.outerHTML} does not contain the sprite icon "${iconName}"!`;
const existingIcons = iconReferences.map(reference => { const existingIcons = iconReferences.map(reference => {
const iconUrl = reference.getAttribute('xlink:href'); const iconUrl = reference.getAttribute('href');
return `"${iconUrl.replace(/^.+#/, '')}"`; return `"${iconUrl.replace(/^.+#/, '')}"`;
}); });
if (existingIcons.length > 0) { if (existingIcons.length > 0) {
......
...@@ -121,10 +121,10 @@ describe('RelatedIssuableItem', () => { ...@@ -121,10 +121,10 @@ describe('RelatedIssuableItem', () => {
}); });
it('renders milestone icon and name', () => { it('renders milestone icon and name', () => {
const milestoneIcon = tokenMetadata().find('.item-milestone svg use'); const milestoneIcon = tokenMetadata().find('.item-milestone svg');
const milestoneTitle = tokenMetadata().find('.item-milestone .milestone-title'); const milestoneTitle = tokenMetadata().find('.item-milestone .milestone-title');
expect(milestoneIcon.attributes('href')).toContain('clock'); expect(milestoneIcon.attributes('data-testid')).toBe('clock-icon');
expect(milestoneTitle.text()).toContain('Milestone title'); expect(milestoneTitle.text()).toContain('Milestone title');
}); });
......
...@@ -36,10 +36,10 @@ end ...@@ -36,10 +36,10 @@ end
RSpec.shared_examples 'expanded stack trace context' do |selected_line: nil, expected_line: 1| RSpec.shared_examples 'expanded stack trace context' do |selected_line: nil, expected_line: 1|
it 'expands the stack trace context', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/217810' } do it 'expands the stack trace context', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/217810' } do
within('div.stacktrace') do within('div.stacktrace') do
find("div.file-holder:nth-child(#{selected_line}) svg.ic-chevron-right").click if selected_line find("div.file-holder:nth-child(#{selected_line}) svg[data-testid='chevron-right-icon']").click if selected_line
expanded_line = find("div.file-holder:nth-child(#{expected_line})") expanded_line = find("div.file-holder:nth-child(#{expected_line})")
expect(expanded_line).to have_css('svg.ic-chevron-down') expect(expanded_line).to have_css('svg[data-testid="chevron-down-icon"]')
event_response['entries'][0]['data']['values'][0]['stacktrace']['frames'][-expected_line]['context'].each do |context| event_response['entries'][0]['data']['values'][0]['stacktrace']['frames'][-expected_line]['context'].each do |context|
expect(page).to have_content(context[0]) expect(page).to have_content(context[0])
......
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