diff --git a/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.test.ts b/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.test.ts index 3e31aef3bc..6fab15f59f 100644 --- a/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.test.ts +++ b/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.test.ts @@ -43,6 +43,7 @@ describe('sentry:project:create action', () => { teamSlug: string; name: string; slug?: string; + platform?: string; authToken?: string; }> => createMockActionContext({ @@ -56,12 +57,14 @@ describe('sentry:project:create action', () => { }, }); - it(`should ${examples[0].description}`, async () => { + it(`should ${examples[0].description} ${ + yaml.parse(examples[0].example).steps[2].name + }`, async () => { expect.assertions(3); let input; try { - input = yaml.parse(examples[0].example).steps[1].input; + input = yaml.parse(examples[0].example).steps[2].input; } catch (error) { console.error('Failed to parse YAML:', error); } @@ -97,7 +100,9 @@ describe('sentry:project:create action', () => { }); }); - it(`should ${examples[0].description}`, async () => { + it(`should ${examples[0].description} ${ + yaml.parse(examples[0].example).steps[0].name + }`, async () => { expect.assertions(3); let input; @@ -140,6 +145,51 @@ describe('sentry:project:create action', () => { }); }); + it(`should ${examples[0].description} ${ + yaml.parse(examples[0].example).steps[1].name + }`, async () => { + expect.assertions(3); + + let input; + try { + input = yaml.parse(examples[0].example).steps[1].input; + } catch (error) { + console.error('Failed to parse YAML:', error); + } + + const action = createSentryCreateProjectAction(createScaffolderConfig()); + const actionContext = getActionContext(); + actionContext.input = { ...actionContext.input, platform: 'platform-a' }; + + worker.use( + http.post( + `https://sentry.io/api/0/teams/${input.organizationSlug}/${input.teamSlug}/projects/`, + async ({ request }) => { + expect(request.headers.get('Authorization')).toBe( + `Bearer c25711beb516e1e910d2ede554dc1bf725654ef3c75e5a9106de9aec13d5de85`, + ); + expect(request.headers.get('Content-Type')).toBe(`application/json`); + await expect(request.json()).resolves.toEqual({ + name: 'Scaffolded project A', + platform: 'platform-a', + }); + return HttpResponse.json( + { detail: 'project creation mocked result' }, + { status: 201 }, + ); + }, + ), + ); + + await action.handler({ + ...actionContext, + input: { + ...actionContext.input, + ...input, + }, + }); + }); + it(`should ${examples[1].description}`, async () => { expect.assertions(3); diff --git a/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.ts b/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.ts index 3af88a4663..1744a995a9 100644 --- a/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.ts +++ b/plugins/scaffolder-backend-module-sentry/src/actions/createProject.examples.ts @@ -38,7 +38,20 @@ export const examples: TemplateExample[] = [ { id: 'create-sentry-project', action: 'sentry:project:create', - name: 'Create a Sentry project without providing a project slug.', + name: 'Create a Sentry project with provided platform.', + input: { + organizationSlug: 'my-org', + teamSlug: 'team-a', + name: 'Scaffolded project A', + platform: 'platform-a', + authToken: + 'c25711beb516e1e910d2ede554dc1bf725654ef3c75e5a9106de9aec13d5de85', + }, + }, + { + id: 'create-sentry-project', + action: 'sentry:project:create', + name: 'Create a Sentry project without optional parameters.', input: { organizationSlug: 'my-org', teamSlug: 'team-b',