Commit 080d39fa authored by Alexander Turinske's avatar Alexander Turinske

Add snapshot testing

- to verify visual changes
parent cc88dc11
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`PolicyDrawerLayout component enabled policy matches the snapshots 1`] = `
<div>
<div
data-testid="policy-summary"
>
<span
data-testid="summary-text"
>
Summary
</span>
</div>
<policy-info-row-stub
data-testid="policy-type"
label="Policy Type"
>
Scan Execution
</policy-info-row-stub>
<policy-info-row-stub
label="Description"
>
<div
data-testid="custom-description-text"
>
This policy enforces pipeline configuration to have a job with DAST scan
</div>
</policy-info-row-stub>
<policy-info-row-stub
label="Status"
>
<div
class="gl-text-green-500"
data-testid="enabled-status-text"
>
<gl-icon-stub
class="gl-mr-3"
name="check-circle-filled"
size="16"
/>
Enabled
</div>
</policy-info-row-stub>
</div>
`;
exports[`PolicyDrawerLayout component not enabled policy matches the snapshots 1`] = `
<div>
<div
data-testid="policy-summary"
>
<span
data-testid="summary-text"
>
Summary
</span>
</div>
<policy-info-row-stub
data-testid="policy-type"
label="Policy Type"
>
Scan Execution
</policy-info-row-stub>
<policy-info-row-stub
label="Description"
>
<div
class="gl-text-gray-500"
data-testid="default-description-text"
>
No description
</div>
</policy-info-row-stub>
<policy-info-row-stub
label="Status"
>
<div
class="gl-text-gray-500"
data-testid="not-enabled-status-text"
>
Not enabled
</div>
</policy-info-row-stub>
</div>
`;
...@@ -11,15 +11,12 @@ describe('PolicyDrawerLayout component', () => { ...@@ -11,15 +11,12 @@ describe('PolicyDrawerLayout component', () => {
let wrapper; let wrapper;
const DESCRIPTION = 'This policy enforces pipeline configuration to have a job with DAST scan'; const DESCRIPTION = 'This policy enforces pipeline configuration to have a job with DAST scan';
const SUMMARY = 'Summary';
const TYPE = 'Scan Execution'; const TYPE = 'Scan Execution';
const findCustomDescription = () => wrapper.findByTestId('custom-description-text'); const findCustomDescription = () => wrapper.findByTestId('custom-description-text');
const findDefaultDescription = () => wrapper.findByTestId('default-description-text'); const findDefaultDescription = () => wrapper.findByTestId('default-description-text');
const findEnabledText = () => wrapper.findByTestId('enabled-status-text'); const findEnabledText = () => wrapper.findByTestId('enabled-status-text');
const findNotEnabledText = () => wrapper.findByTestId('not-enabled-status-text'); const findNotEnabledText = () => wrapper.findByTestId('not-enabled-status-text');
const findSummaryText = () => wrapper.findByTestId('summary-text');
const findTypeText = () => wrapper.findByTestId('policy-type');
const componentStatusText = (status) => (status ? 'does' : 'does not'); const componentStatusText = (status) => (status ? 'does' : 'does not');
...@@ -50,8 +47,6 @@ describe('PolicyDrawerLayout component', () => { ...@@ -50,8 +47,6 @@ describe('PolicyDrawerLayout component', () => {
it.each` it.each`
component | status | finder | exists | text component | status | finder | exists | text
${'type text'} | ${'does'} | ${findTypeText} | ${true} | ${TYPE}
${'summary text'} | ${'does'} | ${findSummaryText} | ${true} | ${SUMMARY}
${'custom description'} | ${componentStatusText(hasDescription)} | ${findCustomDescription} | ${hasDescription} | ${DESCRIPTION} ${'custom description'} | ${componentStatusText(hasDescription)} | ${findCustomDescription} | ${hasDescription} | ${DESCRIPTION}
${'default description'} | ${componentStatusText(!hasDescription)} | ${findDefaultDescription} | ${!hasDescription} | ${DEFAULT_DESCRIPTION_LABEL} ${'default description'} | ${componentStatusText(!hasDescription)} | ${findDefaultDescription} | ${!hasDescription} | ${DEFAULT_DESCRIPTION_LABEL}
${'enabled text'} | ${componentStatusText(enabled)} | ${findEnabledText} | ${enabled} | ${ENABLED_LABEL} ${'enabled text'} | ${componentStatusText(enabled)} | ${findEnabledText} | ${enabled} | ${ENABLED_LABEL}
...@@ -63,5 +58,9 @@ describe('PolicyDrawerLayout component', () => { ...@@ -63,5 +58,9 @@ describe('PolicyDrawerLayout component', () => {
expect(component.text()).toBe(text); expect(component.text()).toBe(text);
} }
}); });
it('matches the snapshots', () => {
expect(wrapper.element).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