awsLambdaCloudformation.spec.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import selectEvent from 'react-select-event';
  2. import * as qs from 'query-string';
  3. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  4. import AwsLambdaCloudformation from 'sentry/views/integrationPipeline/awsLambdaCloudformation';
  5. describe('AwsLambdaCloudformation', () => {
  6. let windowAssignMock;
  7. beforeEach(() => {
  8. windowAssignMock = jest.fn();
  9. window.location.assign = windowAssignMock;
  10. window.localStorage.setItem('AWS_EXTERNAL_ID', 'my-id');
  11. });
  12. it('submit arn', async () => {
  13. render(
  14. <AwsLambdaCloudformation
  15. organization={TestStubs.Organization()}
  16. baseCloudformationUrl="https://console.aws.amazon.com/cloudformation/home#/stacks/create/review"
  17. templateUrl="https://example.com/file.json"
  18. stackName="Sentry-Monitoring-Stack"
  19. regionList={['us-east-1', 'us-west-1']}
  20. accountNumber=""
  21. region=""
  22. initialStepNumber={0}
  23. />
  24. );
  25. // Open configuration fields
  26. await userEvent.click(screen.getByRole('button', {name: "I've created the stack"}));
  27. // Fill out fields
  28. await userEvent.type(
  29. screen.getByRole('textbox', {name: 'AWS Account Number'}),
  30. '599817902985'
  31. );
  32. await selectEvent.select(screen.getByRole('textbox', {name: 'AWS Region'}), [
  33. 'us-west-1',
  34. ]);
  35. expect(screen.getByRole('button', {name: 'Next'})).toBeEnabled();
  36. await userEvent.click(screen.getByRole('button', {name: 'Next'}));
  37. const query = qs.stringify({
  38. accountNumber: '599817902985',
  39. region: 'us-west-1',
  40. awsExternalId: 'my-id',
  41. });
  42. expect(windowAssignMock).toHaveBeenCalledWith(
  43. `${window.location.origin}/extensions/aws_lambda/setup/?${query}`
  44. );
  45. });
  46. });