Commit a967f52b authored by mfluharty's avatar mfluharty

Feature flag recent failures counts

Push the feature flag to the frontend in the merge requests controller
Only display the recent failures summaries and badges if enabled
Adjust spec to check for presence/absence when enabled/disabled
parent 1cae5e73
......@@ -92,7 +92,7 @@ export default {
return reportTextBuilder(name, summary);
},
hasRecentFailures(summary) {
return summary?.recentlyFailed > 0;
return this.glFeatures.testFailureHistory && summary?.recentlyFailed > 0;
},
getRecentFailuresText(summary) {
return recentFailuresTextBuilder(summary);
......
......@@ -2,12 +2,14 @@
import { mapActions } from 'vuex';
import { GlBadge } from '@gitlab/ui';
import { n__ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
export default {
name: 'TestIssueBody',
components: {
GlBadge,
},
mixins: [glFeatureFlagsMixin()],
props: {
issue: {
type: Object,
......@@ -24,6 +26,11 @@ export default {
default: false,
},
},
computed: {
shouldShowRecentFailures() {
return this.glFeatures.testFailureHistory && this.issue.recent_failures;
},
},
methods: {
...mapActions(['openModal']),
recentFailuresText(count) {
......@@ -45,7 +52,7 @@ export default {
@click="openModal({ issue })"
>
<gl-badge v-if="isNew" variant="danger" class="gl-mr-2">{{ s__('New') }}</gl-badge>
<gl-badge v-if="issue.recent_failures" variant="warning" class="gl-mr-2">
<gl-badge v-if="shouldShowRecentFailures" variant="warning" class="gl-mr-2">
{{ recentFailuresText(issue.recent_failures) }}
</gl-badge>
{{ issue.name }}
......
......@@ -42,6 +42,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
push_frontend_feature_flag(:default_merge_ref_for_diffs, @project)
push_frontend_feature_flag(:core_security_mr_widget, @project, default_enabled: true)
push_frontend_feature_flag(:remove_resolve_note, @project, default_enabled: true)
push_frontend_feature_flag(:test_failure_history, @project)
record_experiment_user(:invite_members_version_a)
record_experiment_user(:invite_members_version_b)
......
......@@ -22,7 +22,7 @@ describe('Grouped test reports app', () => {
let wrapper;
let mockStore;
const mountComponent = ({ props = { pipelinePath } } = {}) => {
const mountComponent = ({ props = { pipelinePath }, testFailureHistory = false } = {}) => {
wrapper = mount(Component, {
store: mockStore,
localVue,
......@@ -31,6 +31,11 @@ describe('Grouped test reports app', () => {
pipelinePath,
...props,
},
provide: {
glFeatures: {
testFailureHistory,
},
},
});
};
......@@ -239,23 +244,48 @@ describe('Grouped test reports app', () => {
describe('with recent failures counts', () => {
beforeEach(() => {
setReports(recentFailuresTestReports);
mountComponent();
});
it('renders the recently failed tests summary', () => {
expect(findHeader().text()).toContain(
'2 out of 3 failed tests have failed more than once in the last 14 days',
);
});
describe('with feature flag enabled', () => {
beforeEach(() => {
mountComponent({ testFailureHistory: true });
});
it('renders the recently failed count on the test suite', () => {
expect(findSummaryDescription().text()).toContain(
'1 out of 2 failed tests has failed more than once in the last 14 days',
);
it('renders the recently failed tests summary', () => {
expect(findHeader().text()).toContain(
'2 out of 3 failed tests have failed more than once in the last 14 days',
);
});
it('renders the recently failed count on the test suite', () => {
expect(findSummaryDescription().text()).toContain(
'1 out of 2 failed tests has failed more than once in the last 14 days',
);
});
it('renders the recent failures count on the test case', () => {
expect(findIssueDescription().text()).toContain('Failed 8 times in the last 14 days');
});
});
it('renders the recent failures count on the test case', () => {
expect(findIssueDescription().text()).toContain('Failed 8 times in the last 14 days');
describe('with feature flag disabled', () => {
beforeEach(() => {
mountComponent({ testFailureHistory: false });
});
it('does not render the recently failed tests summary', () => {
expect(findHeader().text()).not.toContain('failed more than once in the last 14 days');
});
it('does not render the recently failed count on the test suite', () => {
expect(findSummaryDescription().text()).not.toContain(
'failed more than once in the last 14 days',
);
});
it('renders the recent failures count on the test case', () => {
expect(findIssueDescription().text()).not.toContain('in the last 14 days');
});
});
});
......
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