Commit 58e133b3 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '347381-dast-view-scans-deleted-dast-profiles' into 'master'

Render scans that don't have a DAST profile anymore

See merge request gitlab-org/gitlab!76322
parents bc2029ca ac5cee74
...@@ -52,12 +52,12 @@ export const BASE_TABS_TABLE_FIELDS = [ ...@@ -52,12 +52,12 @@ export const BASE_TABS_TABLE_FIELDS = [
}, },
{ {
...NAME_COLUMN, ...NAME_COLUMN,
formatter: (_value, _key, item) => item.dastProfile.name, formatter: (_value, _key, item) => item?.dastProfile?.name,
}, },
SCAN_TYPE_COLUMN, SCAN_TYPE_COLUMN,
{ {
...TARGET_COLUMN, ...TARGET_COLUMN,
formatter: (_value, _key, item) => item.dastProfile.dastSiteProfile.targetUrl, formatter: (_value, _key, item) => item?.dastProfile?.dastSiteProfile?.targetUrl,
}, },
START_DATE_COLUMN, START_DATE_COLUMN,
PIPELINE_ID_COLUMN, PIPELINE_ID_COLUMN,
......
import { GlTab, GlTable, GlAlert } from '@gitlab/ui'; import { GlTab, GlTable, GlAlert } from '@gitlab/ui';
import { createLocalVue } from '@vue/test-utils'; import { createLocalVue } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { merge } from 'lodash'; import { cloneDeep, merge } from 'lodash';
import allPipelinesWithPipelinesMock from 'test_fixtures/graphql/on_demand_scans/graphql/on_demand_scans.query.graphql.with_pipelines.json'; import allPipelinesWithPipelinesMock from 'test_fixtures/graphql/on_demand_scans/graphql/on_demand_scans.query.graphql.with_pipelines.json';
import allPipelinesWithoutPipelinesMock from 'test_fixtures/graphql/on_demand_scans/graphql/on_demand_scans.query.graphql.without_pipelines.json'; import allPipelinesWithoutPipelinesMock from 'test_fixtures/graphql/on_demand_scans/graphql/on_demand_scans.query.graphql.without_pipelines.json';
import { stubComponent } from 'helpers/stub_component'; import { stubComponent } from 'helpers/stub_component';
...@@ -22,6 +22,8 @@ jest.mock('~/lib/utils/common_utils'); ...@@ -22,6 +22,8 @@ jest.mock('~/lib/utils/common_utils');
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(VueApollo); localVue.use(VueApollo);
const [firstPipeline] = allPipelinesWithPipelinesMock.data.project.pipelines.nodes;
describe('BaseTab', () => { describe('BaseTab', () => {
let wrapper; let wrapper;
let router; let router;
...@@ -36,6 +38,8 @@ describe('BaseTab', () => { ...@@ -36,6 +38,8 @@ describe('BaseTab', () => {
const findEmptyState = () => wrapper.findComponent(EmptyState); const findEmptyState = () => wrapper.findComponent(EmptyState);
const findPagination = () => wrapper.findByTestId('pagination'); const findPagination = () => wrapper.findByTestId('pagination');
const findErrorAlert = () => wrapper.findComponent(GlAlert); const findErrorAlert = () => wrapper.findComponent(GlAlert);
const findFirstRow = () => wrapper.find('tbody > tr');
const findCellAt = (index) => findFirstRow().findAll('td').at(index);
// Helpers // Helpers
const createMockApolloProvider = () => { const createMockApolloProvider = () => {
...@@ -239,11 +243,6 @@ describe('BaseTab', () => { ...@@ -239,11 +243,6 @@ describe('BaseTab', () => {
}); });
describe('rendered cells', () => { describe('rendered cells', () => {
const [firstPipeline] = allPipelinesWithPipelinesMock.data.project.pipelines.nodes;
const findFirstRow = () => wrapper.find('tbody > tr');
const findCellAt = (index) => findFirstRow().findAll('td').at(index);
beforeEach(() => { beforeEach(() => {
createFullComponent({ createFullComponent({
propsData: { propsData: {
...@@ -298,6 +297,30 @@ describe('BaseTab', () => { ...@@ -298,6 +297,30 @@ describe('BaseTab', () => {
}); });
}); });
describe("when a scan's DAST profile got deleted", () => {
beforeEach(() => {
const allPipelinesWithPipelinesMockCopy = cloneDeep(allPipelinesWithPipelinesMock);
const pipelineWithoutDastProfile = { ...firstPipeline, dastProfile: null };
allPipelinesWithPipelinesMockCopy.data.project.pipelines.nodes[0] = pipelineWithoutDastProfile;
requestHandler = jest.fn().mockResolvedValue(allPipelinesWithPipelinesMockCopy);
createFullComponent({
stubs: {
GlTable: false,
},
});
return waitForPromises();
});
it.each`
cellName | cellIndex
${'name'} | ${1}
${'target'} | ${3}
`('render empty $cellName cell', ({ cellIndex }) => {
expect(findCellAt(cellIndex).text()).toBe('');
});
});
describe('when there are no pipelines', () => { describe('when there are no pipelines', () => {
beforeEach(() => { beforeEach(() => {
requestHandler = jest.fn().mockResolvedValue(allPipelinesWithoutPipelinesMock); requestHandler = jest.fn().mockResolvedValue(allPipelinesWithoutPipelinesMock);
......
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