debian-mirror-gitlab/spec/frontend/token_access/token_projects_table_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-09-30 23:02:18 +05:30
import { GlTable, GlButton } from '@gitlab/ui';
2023-01-13 00:05:48 +05:30
import { mountExtended } from 'helpers/vue_test_utils_helper';
2021-09-30 23:02:18 +05:30
import TokenProjectsTable from '~/token_access/components/token_projects_table.vue';
2023-04-23 21:23:45 +05:30
import { mockProjects, mockFields } from './mock_data';
2021-09-30 23:02:18 +05:30
describe('Token projects table', () => {
let wrapper;
const createComponent = () => {
2023-01-13 00:05:48 +05:30
wrapper = mountExtended(TokenProjectsTable, {
2021-09-30 23:02:18 +05:30
provide: {
fullPath: 'root/ci-project',
},
propsData: {
2023-04-23 21:23:45 +05:30
tableFields: mockFields,
2021-09-30 23:02:18 +05:30
projects: mockProjects,
},
});
};
const findTable = () => wrapper.findComponent(GlTable);
const findDeleteProjectBtn = () => wrapper.findComponent(GlButton);
const findAllDeleteProjectBtn = () => wrapper.findAllComponents(GlButton);
2023-01-13 00:05:48 +05:30
const findAllTableRows = () => wrapper.findAllByTestId('projects-token-table-row');
const findProjectNameCell = () => wrapper.findByTestId('token-access-project-name');
const findProjectNamespaceCell = () => wrapper.findByTestId('token-access-project-namespace');
2021-09-30 23:02:18 +05:30
beforeEach(() => {
createComponent();
});
it('displays a table', () => {
expect(findTable().exists()).toBe(true);
});
it('displays the correct amount of table rows', () => {
expect(findAllTableRows()).toHaveLength(mockProjects.length);
});
it('delete project button emits event with correct project to delete', async () => {
await findDeleteProjectBtn().trigger('click');
expect(wrapper.emitted('removeProject')).toEqual([[mockProjects[0].fullPath]]);
});
it('does not show the remove icon if the project is locked', () => {
// currently two mock projects with one being a locked project
expect(findAllDeleteProjectBtn()).toHaveLength(1);
});
2023-01-13 00:05:48 +05:30
it('displays project and namespace cells', () => {
expect(findProjectNameCell().text()).toBe('merge-train-stuff');
expect(findProjectNamespaceCell().text()).toBe('root');
});
2021-09-30 23:02:18 +05:30
});