Skip to content

Commit

Permalink
fix: 3570 - feature flag in front of grant activity preference (#3606)
Browse files Browse the repository at this point in the history
  • Loading branch information
phm200 authored Oct 10, 2024
1 parent cb03e5e commit 12ed230
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
30 changes: 27 additions & 3 deletions packages/client/src/views/MyProfileView.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
import { shallowMount } from '@vue/test-utils';
import { createStore } from 'vuex';
import MyProfileView from '@/views/MyProfileView.vue';
import { shareTerminologyEnabled } from '@/helpers/featureFlags';
import { shareTerminologyEnabled, followNotesEnabled } from '@/helpers/featureFlags';

describe('MyProfileView.vue', () => {
const store = createStore({
Expand All @@ -24,6 +24,7 @@ describe('MyProfileView.vue', () => {
vi.mock('@/helpers/featureFlags', async (importOriginal) => ({
...await importOriginal(),
shareTerminologyEnabled: vi.fn(),
followNotesEnabled: vi.fn(),
}));

describe('when share terminology flag is off', () => {
Expand Down Expand Up @@ -64,8 +65,31 @@ describe('MyProfileView.vue', () => {
});
});

describe('grant activity preference', () => {
it('should show grant activity terminology', () => {
describe('when follow notes flag is off', () => {
beforeEach(() => {
vi.mocked(followNotesEnabled).mockReturnValue(false);
});

it('should not show grant activity preference', () => {
const wrapper = shallowMount(MyProfileView, {
global: {
plugins: [store],
},
});
const text = wrapper.text();
expect(text).not.toContain('Grant Activity');
expect(text).not.toContain(
'Send me a daily summary of new activity for grants that I follow.',
);
});
});

describe('when follow notes flag is on', () => {
beforeEach(() => {
vi.mocked(followNotesEnabled).mockReturnValue(true);
});

it('should show grant activity preference', () => {
const wrapper = shallowMount(MyProfileView, {
global: {
plugins: [store],
Expand Down
7 changes: 4 additions & 3 deletions packages/client/src/views/MyProfileView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

<script>
import { mapGetters, mapActions } from 'vuex';
import { shareTerminologyEnabled } from '@/helpers/featureFlags';
import { shareTerminologyEnabled, followNotesEnabled } from '@/helpers/featureFlags';
import EditUserModal from '@/components/Modals/EditUser.vue';
import UserAvatar from '@/components/UserAvatar.vue';
Expand All @@ -83,6 +83,7 @@ export default {
},
data() {
const shareTerminologyEnabledFlag = shareTerminologyEnabled() === true;
const followNotesEnabledFlag = followNotesEnabled() === true;
const grantAssignmentDescription = 'Send me notifications if a grant has been assigned to my USDR Grants team.';
const grantShareDescription = 'Send me an email notification when someone shares a grant with my team.';
Expand All @@ -98,11 +99,11 @@ export default {
key: 'GRANT_ASSIGNMENT',
description: shareTerminologyEnabledFlag ? grantShareDescription : grantAssignmentDescription,
},
{
...(followNotesEnabledFlag ? [{
name: 'Grant Activity',
key: 'GRANT_ACTIVITY',
description: 'Send me a daily summary of new activity for grants that I follow.',
},
}] : []),
],
breadcrumb_items: [
{
Expand Down

0 comments on commit 12ed230

Please sign in to comment.