Commit 45e8b5d6 authored by pburdette's avatar pburdette Committed by Miguel Rincon

Use find by role helper

Use findByRole to improve bundle
size and accessbility.
parent 6be45816
...@@ -187,12 +187,7 @@ export default { ...@@ -187,12 +187,7 @@ export default {
/> />
</template> </template>
<template #footer> <template #footer>
<gl-button <gl-button variant="confirm" :disabled="isProjectPathEmpty" @click="addProject">
variant="confirm"
:disabled="isProjectPathEmpty"
data-testid="add-project-button"
@click="addProject"
>
{{ $options.i18n.addProject }} {{ $options.i18n.addProject }}
</gl-button> </gl-button>
<gl-button @click="clearTargetProjectPath">{{ $options.i18n.cancel }}</gl-button> <gl-button @click="clearTargetProjectPath">{{ $options.i18n.cancel }}</gl-button>
......
...@@ -73,7 +73,6 @@ export default { ...@@ -73,7 +73,6 @@ export default {
variant="danger" variant="danger"
icon="remove" icon="remove"
:aria-label="__('Remove access')" :aria-label="__('Remove access')"
data-testid="remove-project-button"
@click="removeProject(item.fullPath)" @click="removeProject(item.fullPath)"
/> />
</template> </template>
......
import { GlToggle, GlLoadingIcon } from '@gitlab/ui'; import { GlToggle, GlLoadingIcon } from '@gitlab/ui';
import { createLocalVue, shallowMount, mount } from '@vue/test-utils'; import { createLocalVue } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import { mountExtended, shallowMountExtended } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import createFlash from '~/flash'; import createFlash from '~/flash';
import TokenAccess from '~/token_access/components/token_access.vue'; import TokenAccess from '~/token_access/components/token_access.vue';
...@@ -41,15 +42,15 @@ describe('TokenAccess component', () => { ...@@ -41,15 +42,15 @@ describe('TokenAccess component', () => {
const findToggle = () => wrapper.findComponent(GlToggle); const findToggle = () => wrapper.findComponent(GlToggle);
const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findAddProjectBtn = () => wrapper.find('[data-testid="add-project-button"]'); const findAddProjectBtn = () => wrapper.findByRole('button', { name: 'Add project' });
const findRemoveProjectBtn = () => wrapper.find('[data-testid="remove-project-button"]'); const findRemoveProjectBtn = () => wrapper.findByRole('button', { name: 'Remove access' });
const findTokenSection = () => wrapper.find('[data-testid="token-section"]'); const findTokenSection = () => wrapper.find('[data-testid="token-section"]');
const createMockApolloProvider = (requestHandlers) => { const createMockApolloProvider = (requestHandlers) => {
return createMockApollo(requestHandlers); return createMockApollo(requestHandlers);
}; };
const createComponent = (requestHandlers, mountFn = shallowMount) => { const createComponent = (requestHandlers, mountFn = shallowMountExtended) => {
wrapper = mountFn(TokenAccess, { wrapper = mountFn(TokenAccess, {
localVue, localVue,
provide: { provide: {
...@@ -138,7 +139,7 @@ describe('TokenAccess component', () => { ...@@ -138,7 +139,7 @@ describe('TokenAccess component', () => {
[getProjectsWithCIJobTokenScopeQuery, getProjectsWithScope], [getProjectsWithCIJobTokenScopeQuery, getProjectsWithScope],
[addProjectCIJobTokenScopeMutation, addProjectSuccessHandler], [addProjectCIJobTokenScopeMutation, addProjectSuccessHandler],
], ],
mount, mountExtended,
); );
await waitForPromises(); await waitForPromises();
...@@ -160,7 +161,7 @@ describe('TokenAccess component', () => { ...@@ -160,7 +161,7 @@ describe('TokenAccess component', () => {
[getProjectsWithCIJobTokenScopeQuery, getProjectsWithScope], [getProjectsWithCIJobTokenScopeQuery, getProjectsWithScope],
[addProjectCIJobTokenScopeMutation, addProjectFailureHandler], [addProjectCIJobTokenScopeMutation, addProjectFailureHandler],
], ],
mount, mountExtended,
); );
await waitForPromises(); await waitForPromises();
...@@ -181,7 +182,7 @@ describe('TokenAccess component', () => { ...@@ -181,7 +182,7 @@ describe('TokenAccess component', () => {
[getProjectsWithCIJobTokenScopeQuery, getProjectsWithScope], [getProjectsWithCIJobTokenScopeQuery, getProjectsWithScope],
[removeProjectCIJobTokenScopeMutation, removeProjectSuccessHandler], [removeProjectCIJobTokenScopeMutation, removeProjectSuccessHandler],
], ],
mount, mountExtended,
); );
await waitForPromises(); await waitForPromises();
...@@ -203,7 +204,7 @@ describe('TokenAccess component', () => { ...@@ -203,7 +204,7 @@ describe('TokenAccess component', () => {
[getProjectsWithCIJobTokenScopeQuery, getProjectsWithScope], [getProjectsWithCIJobTokenScopeQuery, getProjectsWithScope],
[removeProjectCIJobTokenScopeMutation, removeProjectFailureHandler], [removeProjectCIJobTokenScopeMutation, removeProjectFailureHandler],
], ],
mount, mountExtended,
); );
await waitForPromises(); await waitForPromises();
......
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