Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions static/app/components/pipeline/integrationGitLab/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,49 @@ describe('InstallationConfigStep', () => {
'my-app-id'
);
await userEvent.type(screen.getByLabelText('GitLab Application Secret'), 'my-secret');
await userEvent.type(
screen.getByRole('textbox', {name: 'GitLab Group Path'}),
'my-group'
);

await userEvent.click(screen.getByRole('button', {name: 'Continue'}));

await waitFor(() => {
expect(advance).toHaveBeenCalledWith({
url: undefined,
verify_ssl: undefined,
group: '',
include_subgroups: undefined,
group: 'my-group',
include_subgroups: false,
client_id: 'my-app-id',
client_secret: 'my-secret',
});
});
});

it('requires a group path before submitting', async () => {
const advance = jest.fn();
render(
<InstallationConfigStep
{...makeStepProps({stepData: {setupValues: []}, advance})}
/>
);

await userEvent.click(screen.getByRole('button', {name: 'Next'}));
await userEvent.click(screen.getByRole('button', {name: 'Next'}));

await userEvent.type(
screen.getByRole('textbox', {name: 'GitLab Application ID'}),
'my-app-id'
);
await userEvent.type(screen.getByLabelText('GitLab Application Secret'), 'my-secret');
await userEvent.type(screen.getByRole('textbox', {name: 'GitLab Group Path'}), ' ');

await userEvent.click(screen.getByRole('button', {name: 'Continue'}));

expect(await screen.findByText('Group path is required')).toBeInTheDocument();
expect(advance).not.toHaveBeenCalled();
});

it('submits with group and include_subgroups when group is set', async () => {
const advance = jest.fn();
render(
Expand Down Expand Up @@ -191,6 +219,10 @@ describe('InstallationConfigStep', () => {
'my-app-id'
);
await userEvent.type(screen.getByLabelText('GitLab Application Secret'), 'my-secret');
await userEvent.type(
screen.getByRole('textbox', {name: 'GitLab Group Path'}),
'my-group'
);

await userEvent.click(screen.getByRole('checkbox', {name: 'Self-Hosted Instance'}));

Expand Down Expand Up @@ -232,6 +264,10 @@ describe('InstallationConfigStep', () => {
'id'
);
await userEvent.type(screen.getByLabelText('GitLab Application Secret'), 'secret');
await userEvent.type(
screen.getByRole('textbox', {name: 'GitLab Group Path'}),
'my-group'
);

await userEvent.click(screen.getByRole('checkbox', {name: 'Self-Hosted Instance'}));

Expand Down
7 changes: 4 additions & 3 deletions static/app/components/pipeline/integrationGitLab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const installationConfigSchema = z
.object({
selfHosted: z.boolean(),
url: z.string(),
group: z.string(),
group: z.string().trim().min(1, t('Group path is required')),
includeSubgroups: z.boolean(),
verifySsl: z.boolean(),
clientId: z.string().min(1, t('Application ID is required')),
Expand Down Expand Up @@ -78,7 +78,7 @@ function InstallationConfigStep({
url: value.selfHosted ? value.url.replace(/\/+$/, '') : undefined,
verify_ssl: value.selfHosted ? value.verifySsl : undefined,
group: value.group,
include_subgroups: value.group ? value.includeSubgroups : undefined,
include_subgroups: value.includeSubgroups,
client_id: value.clientId,
client_secret: value.clientSecret,
});
Expand Down Expand Up @@ -122,8 +122,9 @@ function InstallationConfigStep({
<field.Layout.Stack
label={t('GitLab Group Path')}
hintText={t(
'Limit this integration to a specific group. Found in the URL of your group page (e.g. my-group/my-subgroup). Leave empty to integrate all accessible projects.'
'The group to connect, found in the URL of your group page (e.g. my-group/my-subgroup). Groups without a shared parent each need their own installation.'
)}
required
>
<field.Input
value={field.state.value}
Expand Down
Loading