Skip to content

Commit

Permalink
feat(github-growth): FE toggle for missing member detection (#56185)
Browse files Browse the repository at this point in the history
  • Loading branch information
cathteng authored Sep 15, 2023
1 parent 8caf038 commit 62352bd
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions fixtures/js-stubs/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function Organization(params: Partial<TOrganization> = {}): TOrganization
eventsMemberAdmin: false,
githubOpenPRBot: false,
githubPRBot: false,
githubNudgeInvite: false,
isDefault: false,
isDynamicallySampled: true,
isEarlyAdopter: false,
Expand Down
1 change: 1 addition & 0 deletions static/app/types/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface OrganizationSummary {
codecovAccess: boolean;
dateCreated: string;
features: string[];
githubNudgeInvite: boolean;
githubOpenPRBot: boolean;
githubPRBot: boolean;
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ describe('IntegrationDetailedView', function () {
).toBeDisabled();
});

it('can enable github comment bots', async function () {
it('can enable github features', async function () {
org.features.push('integrations-open-pr-comment');
org.features.push('integrations-gh-invite');

MockApiClient.addMockResponse({
url: `/organizations/${org.slug}/config/integrations/?provider_key=github`,
Expand Down Expand Up @@ -288,5 +289,18 @@ describe('IntegrationDetailedView', function () {
})
);
});

await userEvent.click(
screen.getByRole('checkbox', {name: /Enable Missing Member Detection/})
);

await waitFor(() => {
expect(mock).toHaveBeenCalledWith(
ENDPOINT,
expect.objectContaining({
data: {githubNudgeInvite: true},
})
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,27 @@ class IntegrationDetailedView extends AbstractIntegrationDetailedView<
),
visible: ({features}) => features.includes('integrations-open-pr-comment'),
},
{
name: 'githubNudgeInvite',
type: 'boolean',
label: t('Enable Missing Member Detection'),
help: t(
'Allow Sentry to detect users committing to your GitHub repositories that are not part of your Sentry organization..'
),
disabled: !hasIntegration,
disabledReason: t(
'You must have a GitHub integration to enable this feature.'
),
visible: ({features}) => features.includes('integrations-gh-invite'),
},
],
},
];

const initialData = {
githubPRBot: organization.githubPRBot,
githubOpenPRBot: organization.githubOpenPRBot,
githubNudgeInvite: organization.githubNudgeInvite,
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('inviteBanner', function () {
it('render banners with feature flag', async function () {
const org = TestStubs.Organization({
features: ['integrations-gh-invite'],
githubNudgeInvite: true,
});

render(
Expand Down Expand Up @@ -127,6 +128,7 @@ describe('inviteBanner', function () {
it('renders banner if snoozed_ts days is longer than threshold', async function () {
const org = TestStubs.Organization({
features: ['integrations-gh-invite'],
githubNudgeInvite: true,
});
const promptResponse = {
dismissed_ts: undefined,
Expand Down Expand Up @@ -161,6 +163,7 @@ describe('inviteBanner', function () {
it('does not render banner if snoozed_ts days is shorter than threshold', function () {
const org = TestStubs.Organization({
features: ['integrations-gh-invite'],
githubNudgeInvite: true,
});
const promptResponse = {
dismissed_ts: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function InviteBanner({
const isEligibleForBanner =
organization.features.includes('integrations-gh-invite') &&
organization.access.includes('org:write') &&
organization.githubNudgeInvite &&
missingMembers?.users?.length > 0;
const [sendingInvite, setSendingInvite] = useState<boolean>(false);
const [showBanner, setShowBanner] = useState<boolean>(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ describe('OrganizationMembersList', function () {

const org = TestStubs.Organization({
features: ['integrations-gh-invite'],
githubNudgeInvite: true,
});

render(<OrganizationMembersList {...defaultProps} organization={org} />, {
Expand Down

0 comments on commit 62352bd

Please sign in to comment.