|
@@ -41,7 +41,7 @@ describe('CreateAlertFromViewButton', () => {
|
|
|
expect(onClickMock).toHaveBeenCalledTimes(1);
|
|
|
});
|
|
|
|
|
|
- it('disables the create alert button for members', () => {
|
|
|
+ it('disables the button for org-member', () => {
|
|
|
const eventView = EventView.fromSavedQuery({
|
|
|
...DEFAULT_EVENT_VIEW,
|
|
|
});
|
|
@@ -49,13 +49,17 @@ describe('CreateAlertFromViewButton', () => {
|
|
|
...organization,
|
|
|
access: [],
|
|
|
};
|
|
|
+ const noAccessProj = {
|
|
|
+ ...TestStubs.Project(),
|
|
|
+ access: [],
|
|
|
+ };
|
|
|
|
|
|
render(
|
|
|
<CreateAlertFromViewButton
|
|
|
location={location}
|
|
|
- organization={organization}
|
|
|
+ organization={noAccessOrg}
|
|
|
eventView={eventView}
|
|
|
- projects={[TestStubs.Project()]}
|
|
|
+ projects={[noAccessProj]}
|
|
|
onClick={onClickMock}
|
|
|
/>,
|
|
|
{
|
|
@@ -67,7 +71,73 @@ describe('CreateAlertFromViewButton', () => {
|
|
|
expect(screen.getByRole('button', {name: 'Create Alert'})).toBeDisabled();
|
|
|
});
|
|
|
|
|
|
- it('shows a guide for members', () => {
|
|
|
+ it('enables the button for org-owner/manager', () => {
|
|
|
+ const eventView = EventView.fromSavedQuery({
|
|
|
+ ...DEFAULT_EVENT_VIEW,
|
|
|
+ });
|
|
|
+ const noAccessProj = {
|
|
|
+ ...TestStubs.Project(),
|
|
|
+ access: [],
|
|
|
+ };
|
|
|
+
|
|
|
+ render(
|
|
|
+ <CreateAlertFromViewButton
|
|
|
+ location={location}
|
|
|
+ organization={organization}
|
|
|
+ eventView={eventView}
|
|
|
+ projects={[noAccessProj]}
|
|
|
+ onClick={onClickMock}
|
|
|
+ />,
|
|
|
+ {
|
|
|
+ context: TestStubs.routerContext([{organization}]),
|
|
|
+ organization,
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ expect(screen.getByRole('button', {name: 'Create Alert'})).toBeEnabled();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('enables the button for team-admin', () => {
|
|
|
+ const eventView = EventView.fromSavedQuery({
|
|
|
+ ...DEFAULT_EVENT_VIEW,
|
|
|
+ });
|
|
|
+ const noAccessOrg = {
|
|
|
+ ...organization,
|
|
|
+ access: [],
|
|
|
+ };
|
|
|
+ const projects = [
|
|
|
+ {
|
|
|
+ ...TestStubs.Project(),
|
|
|
+ id: 1,
|
|
|
+ slug: 'admin-team',
|
|
|
+ access: ['alerts:write'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ...TestStubs.Project(),
|
|
|
+ id: 2,
|
|
|
+ slug: 'contributor-team',
|
|
|
+ access: ['alerts:read'],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ render(
|
|
|
+ <CreateAlertFromViewButton
|
|
|
+ location={location}
|
|
|
+ organization={noAccessOrg}
|
|
|
+ eventView={eventView}
|
|
|
+ projects={projects}
|
|
|
+ onClick={onClickMock}
|
|
|
+ />,
|
|
|
+ {
|
|
|
+ context: TestStubs.routerContext([{organization: noAccessOrg}]),
|
|
|
+ organization: noAccessOrg,
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ expect(screen.getByRole('button', {name: 'Create Alert'})).toBeEnabled();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('shows a guide for org-member', () => {
|
|
|
const noAccessOrg = {
|
|
|
...organization,
|
|
|
access: [],
|
|
@@ -80,7 +150,7 @@ describe('CreateAlertFromViewButton', () => {
|
|
|
expect(GuideStore.state.anchors).toEqual(new Set(['alerts_write_member']));
|
|
|
});
|
|
|
|
|
|
- it('shows a guide for owners/admins', () => {
|
|
|
+ it('shows a guide for org-owner/manager', () => {
|
|
|
const adminAccessOrg = {
|
|
|
...organization,
|
|
|
access: ['org:write'],
|