Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,13 @@ Object.defineProperty(globalThis.crypto, 'randomUUID', {
});

import {awsLambdaIntegrationPipeline} from './pipelineIntegrationAwsLambda';
import type {PipelineStepProps} from './types';
import {createMakeStepProps} from './testUtils';

const ProjectSelectStep = awsLambdaIntegrationPipeline.steps[0].component;
const CloudFormationStep = awsLambdaIntegrationPipeline.steps[1].component;
const InstrumentationStep = awsLambdaIntegrationPipeline.steps[2].component;

function makeStepProps<D, A>(
overrides: Partial<PipelineStepProps<D, A>> & {stepData: D}
): PipelineStepProps<D, A> {
return {
advance: jest.fn(),
advanceError: null,
isAdvancing: false,
stepIndex: 0,
totalSteps: 3,
...overrides,
};
}
const makeStepProps = createMakeStepProps({totalSteps: 3});

describe('ProjectSelectStep', () => {
it('renders project selector', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,16 @@
import {act, render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';

import {bitbucketIntegrationPipeline} from './pipelineIntegrationBitbucket';
import type {PipelineStepProps} from './types';
import {createMakeStepProps, dispatchPipelineMessage, setupMockPopup} from './testUtils';

const BitbucketAuthorizeStep = bitbucketIntegrationPipeline.steps[0].component;

function makeStepProps<D, A>(
overrides: Partial<PipelineStepProps<D, A>> & {stepData: D}
): PipelineStepProps<D, A> {
return {
advance: jest.fn(),
advanceError: null,
isAdvancing: false,
stepIndex: 0,
totalSteps: 1,
...overrides,
};
}
const makeStepProps = createMakeStepProps({totalSteps: 1});

let mockPopup: Window;

function dispatchPipelineMessage({
data,
origin = document.location.origin,
source = mockPopup,
}: {
data: Record<string, string>;
origin?: string;
source?: Window | MessageEventSource | null;
}) {
act(() => {
const event = new MessageEvent('message', {data, origin});
Object.defineProperty(event, 'source', {value: source});
window.dispatchEvent(event);
});
}

beforeEach(() => {
mockPopup = {
closed: false,
close: jest.fn(),
focus: jest.fn(),
} as unknown as Window;
jest.spyOn(window, 'open').mockReturnValue(mockPopup);
mockPopup = setupMockPopup();
});

afterEach(() => {
Expand Down Expand Up @@ -82,6 +50,7 @@ describe('BitbucketAuthorizeStep', () => {
await userEvent.click(screen.getByRole('button', {name: 'Authorize Bitbucket'}));

dispatchPipelineMessage({
source: mockPopup,
data: {
_pipeline_source: 'sentry-pipeline',
jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.test',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';

import {claudeCodeIntegrationPipeline} from './pipelineIntegrationClaudeCode';
import type {PipelineStepProps} from './types';
import {createMakeStepProps} from './testUtils';

const ClaudeCodeApiKeyStep = claudeCodeIntegrationPipeline.steps[0].component;

function makeStepProps<D, A>(
overrides: Partial<PipelineStepProps<D, A>> & {stepData: D}
): PipelineStepProps<D, A> {
return {
advance: jest.fn(),
advanceError: null,
isAdvancing: false,
stepIndex: 0,
totalSteps: 1,
...overrides,
};
}
const makeStepProps = createMakeStepProps({totalSteps: 1});

describe('ClaudeCodeApiKeyStep', () => {
it('renders the API key form', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';

import {cursorIntegrationPipeline} from './pipelineIntegrationCursor';
import type {PipelineStepProps} from './types';
import {createMakeStepProps} from './testUtils';

const CursorApiKeyStep = cursorIntegrationPipeline.steps[0].component;

function makeStepProps<D, A>(
overrides: Partial<PipelineStepProps<D, A>> & {stepData: D}
): PipelineStepProps<D, A> {
return {
advance: jest.fn(),
advanceError: null,
isAdvancing: false,
stepIndex: 0,
totalSteps: 1,
...overrides,
};
}
const makeStepProps = createMakeStepProps({totalSteps: 1});

describe('CursorApiKeyStep', () => {
it('renders the API key form', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,16 @@
import {act, render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';

import {discordIntegrationPipeline} from './pipelineIntegrationDiscord';
import type {PipelineStepProps} from './types';
import {createMakeStepProps, dispatchPipelineMessage, setupMockPopup} from './testUtils';

const DiscordOAuthLoginStep = discordIntegrationPipeline.steps[0].component;

function makeStepProps<D, A>(
overrides: Partial<PipelineStepProps<D, A>> & {stepData: D}
): PipelineStepProps<D, A> {
return {
advance: jest.fn(),
advanceError: null,
isAdvancing: false,
stepIndex: 0,
totalSteps: 1,
...overrides,
};
}
const makeStepProps = createMakeStepProps({totalSteps: 1});

let mockPopup: Window;

function dispatchPipelineMessage({
data,
origin = document.location.origin,
source = mockPopup,
}: {
data: Record<string, string>;
origin?: string;
source?: Window | MessageEventSource | null;
}) {
act(() => {
const event = new MessageEvent('message', {data, origin});
Object.defineProperty(event, 'source', {value: source});
window.dispatchEvent(event);
});
}

beforeEach(() => {
mockPopup = {
closed: false,
close: jest.fn(),
focus: jest.fn(),
} as unknown as Window;
jest.spyOn(window, 'open').mockReturnValue(mockPopup);
mockPopup = setupMockPopup();
});

afterEach(() => {
Expand Down Expand Up @@ -76,6 +44,7 @@ describe('DiscordOAuthLoginStep', () => {
await userEvent.click(screen.getByRole('button', {name: 'Authorize Discord'}));

dispatchPipelineMessage({
source: mockPopup,
data: {
_pipeline_source: 'sentry-pipeline',
code: 'auth-code-123',
Expand Down
54 changes: 10 additions & 44 deletions static/app/components/pipeline/pipelineIntegrationGitHub.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,17 @@
import {act, render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';

import {githubIntegrationPipeline} from './pipelineIntegrationGitHub';
import type {PipelineStepProps} from './types';
import {createMakeStepProps, dispatchPipelineMessage, setupMockPopup} from './testUtils';

const GitHubOAuthLoginStep = githubIntegrationPipeline.steps[0].component;
const OrgSelectionStep = githubIntegrationPipeline.steps[1].component;

function makeStepProps<D, A>(
overrides: Partial<PipelineStepProps<D, A>> & {stepData: D}
): PipelineStepProps<D, A> {
return {
advance: jest.fn(),
advanceError: null,
isAdvancing: false,
stepIndex: 0,
totalSteps: 2,
...overrides,
};
}
const makeStepProps = createMakeStepProps({totalSteps: 2});

let mockPopup: Window;

function dispatchPipelineMessage({
data,
origin = document.location.origin,
source = mockPopup,
}: {
data: Record<string, string>;
origin?: string;
source?: Window | MessageEventSource | null;
}) {
act(() => {
const event = new MessageEvent('message', {data, origin});
Object.defineProperty(event, 'source', {value: source});
window.dispatchEvent(event);
});
}

beforeEach(() => {
mockPopup = {
closed: false,
close: jest.fn(),
focus: jest.fn(),
} as unknown as Window;
jest.spyOn(window, 'open').mockReturnValue(mockPopup);
mockPopup = setupMockPopup();
});

afterEach(() => {
Expand All @@ -54,7 +22,9 @@ describe('GitHubOAuthLoginStep', () => {
it('renders the OAuth login step for GitHub', () => {
render(
<GitHubOAuthLoginStep
{...makeStepProps({stepData: {oauthUrl: 'https://github.com/login/oauth'}})}
{...makeStepProps({
stepData: {oauthUrl: 'https://github.com/login/oauth'},
})}
/>
);

Expand All @@ -75,6 +45,7 @@ describe('GitHubOAuthLoginStep', () => {
await userEvent.click(screen.getByRole('button', {name: 'Authorize GitHub'}));

dispatchPipelineMessage({
source: mockPopup,
data: {
_pipeline_source: 'sentry-pipeline',
code: 'abc123',
Expand Down Expand Up @@ -234,6 +205,7 @@ describe('OrgSelectionStep', () => {
);

dispatchPipelineMessage({
source: mockPopup,
data: {
_pipeline_source: 'sentry-pipeline',
installation_id: 'new-inst-99',
Expand Down Expand Up @@ -268,13 +240,7 @@ describe('OrgSelectionStep', () => {
});

it('disables install button when installAppUrl is not provided', () => {
render(
<OrgSelectionStep
{...makeStepProps({
stepData: {installationInfo: []},
})}
/>
);
render(<OrgSelectionStep {...makeStepProps({stepData: {installationInfo: []}})} />);

expect(screen.getByRole('button', {name: 'Install GitHub App'})).toBeDisabled();
});
Expand Down
Loading
Loading