mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-10-30 14:49:14 +00:00
FSL-1.0-Apache-2.0 grants us the code, not the name. "Sentry" is Functional Software's trademark, so every place the running app says it to a user -- page titles, onboarding, empty states, toasts, settings copy, the self-hosted footer -- now says Sentinel. Attribution is the other half of the deal and stays untouched: upstream copyright headers, LICENSE, NOTICE. So does anything where the mark is a fact rather than a brand -- @sentry/* packages, sentry-cli, the wizard and bundler plugins, docs.sentry.io, the whole gettingStartedDocs tree. Renaming those would leave instructions that no longer work. Nothing structural moved. No import, identifier, route path, feature flag, API field or test id changed; the diff is 312 lines in and 312 out. Colocated specs were updated in lockstep with the copy they assert. Marketing and community links point at hanzo.ai, only where a real page exists to point at. Co-authored-by: Hanzo Dev <[email protected]>
292 lines
7.6 KiB
TypeScript
292 lines
7.6 KiB
TypeScript
import moment from 'moment';
|
|
import {MemberFixture} from 'sentry-fixture/member';
|
|
import {MissingMembersFixture} from 'sentry-fixture/missingMembers';
|
|
import {OrganizationFixture} from 'sentry-fixture/organization';
|
|
|
|
import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
|
|
|
|
import {DEFAULT_SNOOZE_PROMPT_DAYS} from 'sentry/utils/promptIsDismissed';
|
|
import {InviteBanner} from 'sentry/views/settings/organizationMembers/inviteBanner';
|
|
|
|
const missingMembers = {
|
|
integration: 'github',
|
|
users: MissingMembersFixture(),
|
|
};
|
|
|
|
const noMissingMembers = {
|
|
integration: 'github',
|
|
users: [],
|
|
};
|
|
|
|
describe('inviteBanner', function () {
|
|
beforeEach(function () {
|
|
MockApiClient.clearMockResponses();
|
|
MockApiClient.addMockResponse({
|
|
url: '/organizations/org-slug/missing-members/',
|
|
method: 'GET',
|
|
body: [missingMembers],
|
|
});
|
|
MockApiClient.addMockResponse({
|
|
url: '/organizations/org-slug/prompts-activity/',
|
|
method: 'GET',
|
|
body: {
|
|
dismissed_ts: undefined,
|
|
snoozed_ts: undefined,
|
|
},
|
|
});
|
|
});
|
|
|
|
it('render banners with feature flag', async function () {
|
|
const org = OrganizationFixture({
|
|
features: ['integrations-gh-invite'],
|
|
githubNudgeInvite: true,
|
|
});
|
|
|
|
render(
|
|
<InviteBanner
|
|
onSendInvite={() => {}}
|
|
organization={org}
|
|
allowedRoles={[]}
|
|
onModalClose={() => {}}
|
|
/>
|
|
);
|
|
|
|
expect(
|
|
await screen.findByRole('heading', {
|
|
name: 'Bring your full GitHub team on board in Sentinel',
|
|
})
|
|
).toBeInTheDocument();
|
|
expect(screen.queryAllByTestId('invite-missing-member')).toHaveLength(5);
|
|
expect(screen.getByText('See all 5 missing members')).toBeInTheDocument();
|
|
});
|
|
|
|
it('does not render banner if no feature flag', function () {
|
|
const org = OrganizationFixture({
|
|
features: [],
|
|
});
|
|
|
|
const {container} = render(
|
|
<InviteBanner
|
|
onSendInvite={() => {}}
|
|
organization={org}
|
|
allowedRoles={[]}
|
|
onModalClose={() => {}}
|
|
/>
|
|
);
|
|
|
|
expect(container).toBeEmptyDOMElement();
|
|
});
|
|
|
|
it('does not render banner if no option', function () {
|
|
const org = OrganizationFixture({
|
|
features: ['integrations-gh-invite'],
|
|
});
|
|
|
|
const {container} = render(
|
|
<InviteBanner
|
|
onSendInvite={() => {}}
|
|
organization={org}
|
|
allowedRoles={[]}
|
|
onModalClose={() => {}}
|
|
/>
|
|
);
|
|
|
|
expect(container).toBeEmptyDOMElement();
|
|
});
|
|
|
|
it('does not render banner if no missing members', async function () {
|
|
const org = OrganizationFixture({
|
|
features: ['integrations-gh-invite'],
|
|
githubNudgeInvite: true,
|
|
});
|
|
|
|
const mock = MockApiClient.addMockResponse({
|
|
url: '/organizations/org-slug/missing-members/',
|
|
method: 'GET',
|
|
body: [noMissingMembers],
|
|
});
|
|
|
|
const {container} = render(
|
|
<InviteBanner
|
|
onSendInvite={() => {}}
|
|
organization={org}
|
|
allowedRoles={[]}
|
|
onModalClose={() => {}}
|
|
/>
|
|
);
|
|
|
|
await waitFor(() => expect(mock).toHaveBeenCalledTimes(1));
|
|
expect(container).toBeEmptyDOMElement();
|
|
});
|
|
|
|
it('does not render banner if no integration', async function () {
|
|
const org = OrganizationFixture({
|
|
features: ['integrations-gh-invite'],
|
|
githubNudgeInvite: true,
|
|
});
|
|
|
|
const mock = MockApiClient.addMockResponse({
|
|
url: '/organizations/org-slug/missing-members/',
|
|
method: 'GET',
|
|
body: [],
|
|
});
|
|
|
|
const {container} = render(
|
|
<InviteBanner
|
|
onSendInvite={() => {}}
|
|
organization={org}
|
|
allowedRoles={[]}
|
|
onModalClose={() => {}}
|
|
/>
|
|
);
|
|
|
|
await waitFor(() => expect(mock).toHaveBeenCalledTimes(1));
|
|
expect(container).toBeEmptyDOMElement();
|
|
});
|
|
|
|
it('does not render banner if lacking org:write', function () {
|
|
const org = OrganizationFixture({
|
|
features: ['integrations-gh-invite'],
|
|
access: [],
|
|
githubNudgeInvite: true,
|
|
});
|
|
|
|
const {container} = render(
|
|
<InviteBanner
|
|
onSendInvite={() => {}}
|
|
organization={org}
|
|
allowedRoles={[]}
|
|
onModalClose={() => {}}
|
|
/>
|
|
);
|
|
|
|
expect(container).toBeEmptyDOMElement();
|
|
});
|
|
|
|
it('renders banner if snoozed_ts days is longer than threshold', async function () {
|
|
const org = OrganizationFixture({
|
|
features: ['integrations-gh-invite'],
|
|
githubNudgeInvite: true,
|
|
});
|
|
const promptResponse = {
|
|
dismissed_ts: undefined,
|
|
snoozed_ts: moment
|
|
.utc()
|
|
.subtract(DEFAULT_SNOOZE_PROMPT_DAYS + 1, 'days')
|
|
.unix(),
|
|
};
|
|
MockApiClient.addMockResponse({
|
|
url: `/organizations/${org.slug}/prompts-activity/`,
|
|
method: 'GET',
|
|
body: {data: promptResponse},
|
|
});
|
|
|
|
render(
|
|
<InviteBanner
|
|
onSendInvite={() => {}}
|
|
organization={org}
|
|
allowedRoles={[]}
|
|
onModalClose={() => {}}
|
|
/>
|
|
);
|
|
|
|
expect(
|
|
await screen.findByRole('heading', {
|
|
name: 'Bring your full GitHub team on board in Sentinel',
|
|
})
|
|
).toBeInTheDocument();
|
|
});
|
|
|
|
it('does not render banner if snoozed_ts days is shorter than threshold', async function () {
|
|
const org = OrganizationFixture({
|
|
features: ['integrations-gh-invite'],
|
|
githubNudgeInvite: true,
|
|
});
|
|
const promptResponse = {
|
|
dismissed_ts: undefined,
|
|
snoozed_ts: moment
|
|
.utc()
|
|
.subtract(DEFAULT_SNOOZE_PROMPT_DAYS - 1, 'days')
|
|
.unix(),
|
|
};
|
|
const mockPrompt = MockApiClient.addMockResponse({
|
|
url: `/organizations/${org.slug}/prompts-activity/`,
|
|
method: 'GET',
|
|
body: {data: promptResponse},
|
|
});
|
|
|
|
const {container} = render(
|
|
<InviteBanner
|
|
onSendInvite={() => {}}
|
|
organization={org}
|
|
allowedRoles={[]}
|
|
onModalClose={() => {}}
|
|
/>
|
|
);
|
|
|
|
await waitFor(() => expect(mockPrompt).toHaveBeenCalled());
|
|
expect(container).toBeEmptyDOMElement();
|
|
});
|
|
|
|
it('invites member from banner', async function () {
|
|
const newMember = MemberFixture({
|
|
id: '6',
|
|
email: '[email protected]',
|
|
teams: [],
|
|
teamRoles: [],
|
|
flags: {
|
|
'idp:provisioned': false,
|
|
'idp:role-restricted': false,
|
|
'member-limit:restricted': false,
|
|
'partnership:restricted': false,
|
|
'sso:invalid': false,
|
|
'sso:linked': true,
|
|
},
|
|
});
|
|
|
|
MockApiClient.addMockResponse({
|
|
url: '/organizations/org-slug/missing-members/',
|
|
method: 'GET',
|
|
body: [
|
|
{
|
|
integration: 'github',
|
|
users: MissingMembersFixture().slice(0, 5),
|
|
},
|
|
],
|
|
});
|
|
|
|
MockApiClient.addMockResponse({
|
|
url: '/organizations/org-slug/members/?referrer=github_nudge_invite',
|
|
method: 'POST',
|
|
body: newMember,
|
|
});
|
|
|
|
const org = OrganizationFixture({
|
|
features: ['integrations-gh-invite'],
|
|
githubNudgeInvite: true,
|
|
});
|
|
|
|
render(
|
|
<InviteBanner
|
|
onSendInvite={() => {}}
|
|
organization={org}
|
|
allowedRoles={[]}
|
|
onModalClose={() => {}}
|
|
/>
|
|
);
|
|
|
|
expect(
|
|
await screen.findByRole('heading', {
|
|
name: 'Bring your full GitHub team on board in Sentinel',
|
|
})
|
|
).toBeInTheDocument();
|
|
expect(screen.queryAllByTestId('invite-missing-member')).toHaveLength(5);
|
|
expect(screen.getByText('See all 5 missing members')).toBeInTheDocument();
|
|
|
|
const inviteButton = screen.queryAllByTestId('invite-missing-member')[0];
|
|
await userEvent.click(inviteButton);
|
|
expect(screen.queryAllByTestId('invite-missing-member')).toHaveLength(4);
|
|
expect(screen.getByText('See all 4 missing members')).toBeInTheDocument();
|
|
});
|
|
});
|