awsLambdaCloudformation.spec.tsx 1.8 KB

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