Skip to content

Commit

Permalink
fix(integrations): Bring back type="submit" in awsLambdaFunctionSelect (
Browse files Browse the repository at this point in the history
#76460)

This regressed in GH-76118
  • Loading branch information
evanpurkhiser authored Aug 21, 2024
1 parent 9edbb44 commit 28ba9c3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
6 changes: 5 additions & 1 deletion config/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
"moduleResolution": "node",

// We add esnext to lib to pull in types for all newer ECMAScript features
"lib": ["esnext", "dom"],
"lib": [
"esnext",
"dom",
"dom.iterable"
],

// Skip type checking of all declaration files
"skipLibCheck": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {render, screen} from 'sentry-test/reactTestingLibrary';
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';

import AwsLambdaFunctionSelect from 'sentry/views/integrationPipeline/awsLambdaFunctionSelect';

describe('AwsLambdaFunctionSelect', () => {
it('choose lambdas', () => {
it('choose lambdas', async () => {
render(
<AwsLambdaFunctionSelect
initialStepNumber={0}
Expand All @@ -16,6 +16,32 @@ describe('AwsLambdaFunctionSelect', () => {
);
expect(screen.getByRole('checkbox', {name: 'lambdaB'})).toBeInTheDocument();
expect(screen.getByRole('button', {name: 'Finish Setup'})).toBeInTheDocument();
// TODO: add assertion for form post

// Uncheck lambda A
await userEvent.click(screen.getByRole('checkbox', {name: 'lambdaA'}));

const {promise, resolve} = Promise.withResolvers<FormData>();

const submitForm = jest.fn((e: SubmitEvent) => {
e.preventDefault();
if (e.target instanceof HTMLFormElement) {
resolve(new FormData(e.target));
}
});
window.addEventListener('submit', submitForm);

// Submit form
await userEvent.click(screen.getByRole('button', {name: 'Finish Setup'}));
expect(submitForm).toHaveBeenCalled();

// Validate data was passed
const formData = await promise;
expect(Object.fromEntries(formData.entries())).toEqual({
lambdaA: 'false',
lambdaB: 'true',
lambdaC: 'true',
});

window.removeEventListener('submit', submitForm);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function FooterWithButtons({
href !== undefined ? (
<LinkButton href={href} {...buttonProps} />
) : (
<Button {...buttonProps} />
<Button type="submit" {...buttonProps} />
);

// We use a form post here to replicate what we do with standard HTML views
Expand Down

0 comments on commit 28ba9c3

Please sign in to comment.