Commit 99ec3768 authored by Takuya Noguchi's avatar Takuya Noguchi

Expand group_empty_state spec

Co-authored-by: default avatarMark Florian <mflorian@gitlab.com>
Signed-off-by: default avatarTakuya Noguchi <takninnovationresearch@gmail.com>
parent f160373c
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`GroupEmptyState Renders an empty state for BAD_QUERY 1`] = ` exports[`GroupEmptyState given state BAD_QUERY passes the expected props to GlEmptyState 1`] = `
<gl-empty-state-stub Object {
compact="true" "compact": true,
primarybuttonlink="/path/to/settings" "description": null,
primarybuttontext="Verify configuration" "primaryButtonLink": "/path/to/settings",
svgpath="/path/to/empty-group-illustration.svg" "primaryButtonText": "Verify configuration",
title="Query cannot be processed" "secondaryButtonLink": null,
/> "secondaryButtonText": null,
"svgPath": "/path/to/empty-group-illustration.svg",
"title": "Query cannot be processed",
}
`; `;
exports[`GroupEmptyState Renders an empty state for BAD_QUERY 2`] = `"The Prometheus server responded with \\"bad request\\". Please check your queries are correct and are supported in your Prometheus version. <a href=\\"/path/to/docs\\">More information</a>"`; exports[`GroupEmptyState given state BAD_QUERY renders the slotted content 1`] = `
<div>
<div>
The Prometheus server responded with "bad request". Please check your queries are correct and are supported in your Prometheus version.
<a
href="/path/to/docs"
>
More information
</a>
</div>
</div>
`;
exports[`GroupEmptyState Renders an empty state for CONNECTION_FAILED 1`] = ` exports[`GroupEmptyState given state CONNECTION_FAILED passes the expected props to GlEmptyState 1`] = `
<gl-empty-state-stub Object {
compact="true" "compact": true,
description="We couldn't reach the Prometheus server. Either the server no longer exists or the configuration details need updating." "description": "We couldn't reach the Prometheus server. Either the server no longer exists or the configuration details need updating.",
primarybuttonlink="/path/to/settings" "primaryButtonLink": "/path/to/settings",
primarybuttontext="Verify configuration" "primaryButtonText": "Verify configuration",
svgpath="/path/to/empty-group-illustration.svg" "secondaryButtonLink": null,
title="Connection failed" "secondaryButtonText": null,
/> "svgPath": "/path/to/empty-group-illustration.svg",
"title": "Connection failed",
}
`; `;
exports[`GroupEmptyState Renders an empty state for CONNECTION_FAILED 2`] = `undefined`; exports[`GroupEmptyState given state CONNECTION_FAILED renders the slotted content 1`] = `<div />`;
exports[`GroupEmptyState Renders an empty state for FOO STATE 1`] = ` exports[`GroupEmptyState given state FOO STATE passes the expected props to GlEmptyState 1`] = `
<gl-empty-state-stub Object {
compact="true" "compact": true,
description="An error occurred while loading the data. Please try again." "description": "An error occurred while loading the data. Please try again.",
svgpath="/path/to/empty-group-illustration.svg" "primaryButtonLink": null,
title="An error has occurred" "primaryButtonText": null,
/> "secondaryButtonLink": null,
"secondaryButtonText": null,
"svgPath": "/path/to/empty-group-illustration.svg",
"title": "An error has occurred",
}
`; `;
exports[`GroupEmptyState Renders an empty state for FOO STATE 2`] = `undefined`; exports[`GroupEmptyState given state FOO STATE renders the slotted content 1`] = `<div />`;
exports[`GroupEmptyState Renders an empty state for LOADING 1`] = ` exports[`GroupEmptyState given state LOADING passes the expected props to GlEmptyState 1`] = `
<gl-empty-state-stub Object {
compact="true" "compact": true,
description="Creating graphs uses the data from the Prometheus server. If this takes a long time, ensure that data is available." "description": "Creating graphs uses the data from the Prometheus server. If this takes a long time, ensure that data is available.",
svgpath="/path/to/empty-group-illustration.svg" "primaryButtonLink": null,
title="Waiting for performance data" "primaryButtonText": null,
/> "secondaryButtonLink": null,
"secondaryButtonText": null,
"svgPath": "/path/to/empty-group-illustration.svg",
"title": "Waiting for performance data",
}
`; `;
exports[`GroupEmptyState Renders an empty state for LOADING 2`] = `undefined`; exports[`GroupEmptyState given state LOADING renders the slotted content 1`] = `<div />`;
exports[`GroupEmptyState Renders an empty state for NO_DATA 1`] = ` exports[`GroupEmptyState given state NO_DATA passes the expected props to GlEmptyState 1`] = `
<gl-empty-state-stub Object {
compact="true" "compact": true,
svgpath="/path/to/empty-group-illustration.svg" "description": null,
title="No data to display" "primaryButtonLink": null,
/> "primaryButtonText": null,
"secondaryButtonLink": null,
"secondaryButtonText": null,
"svgPath": "/path/to/empty-group-illustration.svg",
"title": "No data to display",
}
`; `;
exports[`GroupEmptyState Renders an empty state for NO_DATA 2`] = `"The data source is connected, but there is no data to display. <a href=\\"/path/to/docs\\">More information</a>"`; exports[`GroupEmptyState given state NO_DATA renders the slotted content 1`] = `
<div>
<div>
The data source is connected, but there is no data to display.
<a
href="/path/to/docs"
>
More information
</a>
</div>
</div>
`;
exports[`GroupEmptyState Renders an empty state for TIMEOUT 1`] = ` exports[`GroupEmptyState given state TIMEOUT passes the expected props to GlEmptyState 1`] = `
<gl-empty-state-stub Object {
compact="true" "compact": true,
svgpath="/path/to/empty-group-illustration.svg" "description": null,
title="Connection timed out" "primaryButtonLink": null,
/> "primaryButtonText": null,
"secondaryButtonLink": null,
"secondaryButtonText": null,
"svgPath": "/path/to/empty-group-illustration.svg",
"title": "Connection timed out",
}
`; `;
exports[`GroupEmptyState Renders an empty state for TIMEOUT 2`] = `"Charts can't be displayed as the request for data has timed out. <a href=\\"/path/to/docs\\">More information</a>"`; exports[`GroupEmptyState given state TIMEOUT renders the slotted content 1`] = `
<div>
<div>
Charts can't be displayed as the request for data has timed out.
<a
href="/path/to/docs"
>
More information
</a>
</div>
</div>
`;
exports[`GroupEmptyState Renders an empty state for UNKNOWN_ERROR 1`] = ` exports[`GroupEmptyState given state UNKNOWN_ERROR passes the expected props to GlEmptyState 1`] = `
<gl-empty-state-stub Object {
compact="true" "compact": true,
description="An error occurred while loading the data. Please try again." "description": "An error occurred while loading the data. Please try again.",
svgpath="/path/to/empty-group-illustration.svg" "primaryButtonLink": null,
title="An error has occurred" "primaryButtonText": null,
/> "secondaryButtonLink": null,
"secondaryButtonText": null,
"svgPath": "/path/to/empty-group-illustration.svg",
"title": "An error has occurred",
}
`; `;
exports[`GroupEmptyState Renders an empty state for UNKNOWN_ERROR 2`] = `undefined`; exports[`GroupEmptyState given state UNKNOWN_ERROR renders the slotted content 1`] = `<div />`;
import { GlEmptyState } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import GroupEmptyState from '~/monitoring/components/group_empty_state.vue'; import GroupEmptyState from '~/monitoring/components/group_empty_state.vue';
import { metricStates } from '~/monitoring/constants'; import { metricStates } from '~/monitoring/constants';
const MockGlEmptyState = {
props: GlEmptyState.props,
template: '<div><slot name="description"></slot></div>',
};
function createComponent(props) { function createComponent(props) {
return shallowMount(GroupEmptyState, { return shallowMount(GroupEmptyState, {
propsData: { propsData: {
...@@ -10,11 +16,20 @@ function createComponent(props) { ...@@ -10,11 +16,20 @@ function createComponent(props) {
settingsPath: '/path/to/settings', settingsPath: '/path/to/settings',
svgPath: '/path/to/empty-group-illustration.svg', svgPath: '/path/to/empty-group-illustration.svg',
}, },
stubs: {
GlEmptyState: MockGlEmptyState,
},
}); });
} }
describe('GroupEmptyState', () => { describe('GroupEmptyState', () => {
const supportedStates = [ let wrapper;
afterEach(() => {
wrapper.destroy();
});
describe.each([
metricStates.NO_DATA, metricStates.NO_DATA,
metricStates.TIMEOUT, metricStates.TIMEOUT,
metricStates.CONNECTION_FAILED, metricStates.CONNECTION_FAILED,
...@@ -22,13 +37,17 @@ describe('GroupEmptyState', () => { ...@@ -22,13 +37,17 @@ describe('GroupEmptyState', () => {
metricStates.LOADING, metricStates.LOADING,
metricStates.UNKNOWN_ERROR, metricStates.UNKNOWN_ERROR,
'FOO STATE', // does not fail with unknown states 'FOO STATE', // does not fail with unknown states
]; ])('given state %s', selectedState => {
beforeEach(() => {
it.each(supportedStates)('Renders an empty state for %s', selectedState => { wrapper = createComponent({ selectedState });
const wrapper = createComponent({ selectedState }); });
it('renders the slotted content', () => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
// slot is not rendered by the stub, test it separately });
expect(wrapper.vm.currentState.slottedDescription).toMatchSnapshot();
it('passes the expected props to GlEmptyState', () => {
expect(wrapper.find(MockGlEmptyState).props()).toMatchSnapshot();
});
}); });
}); });
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