|
@@ -10,6 +10,7 @@ import {
|
|
|
import OrganizationStore from 'sentry/stores/organizationStore';
|
|
|
import TeamStore from 'sentry/stores/teamStore';
|
|
|
import {Organization} from 'sentry/types';
|
|
|
+import * as useExperiment from 'sentry/utils/useExperiment';
|
|
|
import {CreateProject} from 'sentry/views/projectInstall/createProject';
|
|
|
|
|
|
function renderFrameworkModalMockRequests({
|
|
@@ -84,11 +85,28 @@ describe('CreateProject', function () {
|
|
|
expect(container).toSnapshot();
|
|
|
});
|
|
|
|
|
|
- it('can create a new team', async function () {
|
|
|
+ it('can create a new team as admin', async function () {
|
|
|
+ const {organization} = initializeOrg({
|
|
|
+ organization: {
|
|
|
+ access: ['project:admin'],
|
|
|
+ },
|
|
|
+ });
|
|
|
+ renderFrameworkModalMockRequests({organization, teamSlug: 'team-two'});
|
|
|
+ TeamStore.loadUserTeams([
|
|
|
+ TestStubs.Team({id: 2, slug: 'team-two', access: ['team:admin']}),
|
|
|
+ ]);
|
|
|
+
|
|
|
render(<CreateProject />, {
|
|
|
context: TestStubs.routerContext([
|
|
|
- {organization: {id: '1', slug: 'testOrg', access: ['project:read']}},
|
|
|
+ {
|
|
|
+ organization: {
|
|
|
+ id: '1',
|
|
|
+ slug: 'testOrg',
|
|
|
+ access: ['project:read'],
|
|
|
+ },
|
|
|
+ },
|
|
|
]),
|
|
|
+ organization,
|
|
|
});
|
|
|
|
|
|
renderGlobalModal();
|
|
@@ -104,6 +122,73 @@ describe('CreateProject', function () {
|
|
|
await userEvent.click(screen.getByRole('button', {name: 'Close Modal'}));
|
|
|
});
|
|
|
|
|
|
+ it('can create a new project without team as org member', async function () {
|
|
|
+ const {organization} = initializeOrg({
|
|
|
+ organization: {
|
|
|
+ access: ['project:read'],
|
|
|
+ features: ['organizations:team-project-creation-all'],
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ jest.spyOn(useExperiment, 'useExperiment').mockReturnValue({
|
|
|
+ experimentAssignment: 1,
|
|
|
+ logExperiment: jest.fn(),
|
|
|
+ });
|
|
|
+ renderFrameworkModalMockRequests({organization, teamSlug: 'team-two'});
|
|
|
+ TeamStore.loadUserTeams([TestStubs.Team({id: 2, slug: 'team-two', access: []})]);
|
|
|
+
|
|
|
+ render(<CreateProject />, {
|
|
|
+ context: TestStubs.routerContext([
|
|
|
+ {
|
|
|
+ organization: {
|
|
|
+ id: '1',
|
|
|
+ slug: 'testOrg',
|
|
|
+ access: ['project:read'],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]),
|
|
|
+ organization,
|
|
|
+ });
|
|
|
+
|
|
|
+ renderGlobalModal();
|
|
|
+ await userEvent.click(screen.getByTestId('platform-apple-ios'));
|
|
|
+ const createTeamButton = screen.queryByRole('button', {name: 'Create a team'});
|
|
|
+ expect(createTeamButton).not.toBeInTheDocument();
|
|
|
+ expect(screen.getByRole('button', {name: 'Create Project'})).toBeEnabled();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('can create a new team before project creation if org owner', async function () {
|
|
|
+ const {organization} = initializeOrg({
|
|
|
+ organization: {
|
|
|
+ access: ['project:admin'],
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ render(<CreateProject />, {
|
|
|
+ context: TestStubs.routerContext([
|
|
|
+ {
|
|
|
+ organization: {
|
|
|
+ id: '1',
|
|
|
+ slug: 'testOrg',
|
|
|
+ access: ['project:read'],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]),
|
|
|
+ organization,
|
|
|
+ });
|
|
|
+
|
|
|
+ renderGlobalModal();
|
|
|
+ await userEvent.click(screen.getByRole('button', {name: 'Create a team'}));
|
|
|
+
|
|
|
+ expect(
|
|
|
+ await screen.findByText(
|
|
|
+ 'Members of a team have access to specific areas, such as a new release or a new application feature.'
|
|
|
+ )
|
|
|
+ ).toBeInTheDocument();
|
|
|
+
|
|
|
+ await userEvent.click(screen.getByRole('button', {name: 'Close Modal'}));
|
|
|
+ });
|
|
|
+
|
|
|
it('should only allow teams which the user is a team-admin', async function () {
|
|
|
const organization = TestStubs.Organization();
|
|
|
renderFrameworkModalMockRequests({organization, teamSlug: 'team-two'});
|