Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build issue when building frontend #1771

Closed
delphij opened this issue May 16, 2024 · 1 comment · Fixed by #1777
Closed

Build issue when building frontend #1771

delphij opened this issue May 16, 2024 · 1 comment · Fixed by #1777
Labels
Milestone

Comments

@delphij
Copy link
Contributor

delphij commented May 16, 2024

I got the following errors when trying to build frontend with "npm run build" under frontend/apps/remark42:


ERROR in ./app/components/comment-form/__subscribe-by-email/comment-form__subscribe-by-email.test.tsx:201:15
TS2722: Cannot invoke an object which is possibly 'undefined'.
    199 |     expect(typeof onInputEmail === 'function').toBe(true);
    200 |
  > 201 |     act(() => onInputEmail(makeInputEvent('[email protected]')));
        |               ^^^^^^^^^^^^
    202 |
    203 |     form.simulate('submit');
    204 |

ERROR in ./app/components/comment-form/__subscribe-by-email/comment-form__subscribe-by-email.test.tsx:201:15
TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'never'.
    199 |     expect(typeof onInputEmail === 'function').toBe(true);
    200 |
  > 201 |     act(() => onInputEmail(makeInputEvent('[email protected]')));
        |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    202 |
    203 |     form.simulate('submit');
    204 |

ERROR in ./app/components/comment-form/__subscribe-by-email/comment-form__subscribe-by-email.test.tsx:227:15
TS2722: Cannot invoke an object which is possibly 'undefined'.
    225 |     expect(typeof onClick === 'function').toBe(true);
    226 |
  > 227 |     act(() => onClick());
        |               ^^^^^^^
    228 |
    229 |     expect(unsubscribeFromEmailUpdatesMock).toHaveBeenCalled();
    230 |

ERROR in ./app/components/comment-form/__subscribe-by-email/comment-form__subscribe-by-email.test.tsx:227:15
TS2554: Expected 1 arguments, but got 0.
    225 |     expect(typeof onClick === 'function').toBe(true);
    226 |
  > 227 |     act(() => onClick());
        |               ^^^^^^^^^
    228 |
    229 |     expect(unsubscribeFromEmailUpdatesMock).toHaveBeenCalled();
    230 |

I don't think I know TypeScript enough to confidently contribute a fix, but the following patch seems to fix the build issue and allowed tests to pass:

diff --git a/frontend/apps/remark42/app/components/comment-form/__subscribe-by-email/comment-form__subscribe-by-email.test.tsx b/frontend/apps/remark42/app/components/comment-form/__subscribe-by-email/comment-form__subscribe-by-email.test.tsx
index 8aa999ea..77e16fb1 100644
--- a/frontend/apps/remark42/app/components/comment-form/__subscribe-by-email/comment-form__subscribe-by-email.test.tsx
+++ b/frontend/apps/remark42/app/components/comment-form/__subscribe-by-email/comment-form__subscribe-by-email.test.tsx
@@ -193,7 +193,7 @@ describe('<SubscribeByEmailForm/>', () => {
 
   it('should send form by paste valid token', async () => {
     const wrapper = createWrapper();
-    const onInputEmail = wrapper.find(Input).prop('onInput');
+    const onInputEmail = wrapper.find(Input).prop('onInput') as Function;
     const form = wrapper.find('form');
 
     expect(typeof onInputEmail === 'function').toBe(true);
@@ -220,7 +220,7 @@ describe('<SubscribeByEmailForm/>', () => {
   it('should pass throw unsubscribe process', async () => {
     const store = mockStore({ ...initialStore, user: { email_subscription: true } });
     const wrapper = createWrapper(store);
-    const onClick = wrapper.find(Button).prop('onClick');
+    const onClick = wrapper.find(Button).prop('onClick') as Function;
 
     expect(typeof onClick === 'function').toBe(true);
 
@paskal
Copy link
Collaborator

paskal commented May 21, 2024

Good catch! Could you please make a PR with the changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants