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