Skip to content

Update tests, Take 82#382

Open
KevinTriplett wants to merge 24 commits intodevfrom
update-tests-by-kevin-first-pass
Open

Update tests, Take 82#382
KevinTriplett wants to merge 24 commits intodevfrom
update-tests-by-kevin-first-pass

Conversation

@KevinTriplett
Copy link
Copy Markdown
Contributor

@KevinTriplett KevinTriplett commented Mar 9, 2025

Per title, my first pass at updating tests

I need help with these two errors, which affect many files.

Error 1: surely, you jest!

SyntaxError: Cannot use import statement outside a module

This seems to be related to jest and the babel/preset-env module. Here's a SO post

Error 2: DateTime oddity

Cannot read properties of undefined (reading 'indexOf')

For some reason, luxon's DateTime is throwing this error on DateTime.fromISO(post.createdAt) even when createdAt is a valid ISO string. I tried to gather clues for this one but no luck. A right head scratcher.

Other errors, I'm not qualified to touch:

I did touch a few, but feel they need a review for accuracy / intent. Like:

  • process.env.VITE_PROXY_HOST vs process.env.PROXY_HOST

Others I didn't want to touch, thank you:

  • MessageThread › marks a thread as unread if lastReadAt is older than updatedAt
  • Snapshots
  • Expected calls to a function not as actual

I'll try to find other low hanging fruit, but I'll need help on Errors 1 and 2. Once these are solved, it should help a great deal.

@tibetsprague
Copy link
Copy Markdown
Collaborator

this should probably be a draft PR, no?

@tibetsprague
Copy link
Copy Markdown
Collaborator

weird, the first issue i'm seeing is Cannot find module '@hylo/presenters/GroupPresenter' from 'src/util/navigation.js'
are you not seeing that one?

@tibetsprague
Copy link
Copy Markdown
Collaborator

oh i seem you fixed it :)

@tibetsprague
Copy link
Copy Markdown
Collaborator

it looks to me like babel is not handling the typescript files right. or maybe we need to add typescript support to jest...

@tibetsprague
Copy link
Copy Markdown
Collaborator

pushed fix for the import issue!

@tibetsprague
Copy link
Copy Markdown
Collaborator

oops, never mind, i thought it was working, but still broken

@tibetsprague
Copy link
Copy Markdown
Collaborator

ok for real fixed the import and luxon issues!

@KevinTriplett KevinTriplett marked this pull request as draft March 10, 2025 02:34
Some ai assistance, I tried to keep mocks reasonable but it really helped figure out tough bugs in the tests
when running, they seem to spawn child threads that persist like zombies and never complete. Something to do with useState setters causing problems. /shrug
@KevinTriplett
Copy link
Copy Markdown
Contributor Author

KevinTriplett commented Mar 13, 2025

Okay, I've gone as far as I can -- @tibetsprague can you take this over the finish line?

IF NOT -- PLEASE review a couple of tests, they point to some potential bugs:

  • search.test.js
  • TopicSelector.test.js

These on my machine seem to run infinite. I tracked it down to an interaction between useState and useEffect: when any set function is call in a useEffect hook, it goes into some weird place and never returns. Odd. Really odd because in TopicSelector, if I comment out all the code of the second useEffect and only set the one boolean isEdited it goes into that infinite loop.

Also -- and this should be quick to fix -- check the these tests, bc either the tests are wrong or the app is wrong. I suspect the tests but I didn't have time to sleuth the answer:

  • MessageThread.test.js
  • Messages.store.test.js

@KevinTriplett KevinTriplett changed the title Update tests by kevin first pass Update tests, Take 82 Mar 13, 2025
@KevinTriplett
Copy link
Copy Markdown
Contributor Author

KevinTriplett commented Mar 14, 2025

Also -- I packaged all the app code changes into separate commits to make it easier to review those changes:

b534835

c3b86f3

0829fde

@KevinTriplett KevinTriplett marked this pull request as ready for review March 14, 2025 11:27
@KevinTriplett
Copy link
Copy Markdown
Contributor Author

@tibetsprague what would you like me to do with this PR?

Copy link
Copy Markdown
Collaborator

@tibetsprague tibetsprague left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did a more detailed review of all the code changes and there are few more things to look at

/>
<Tooltip
delay={550}
id={`pinned-post-tt-${id}`}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this added? is it it used anywhere?

className='border-2 border-foreground/30 bg-foreground/30 px-2 py-1 rounded flex items-center'
dataTipHtml={!valid ? invalidMessage : ''}
dataFor='submit-tt'
label='submit'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this changes the text of the submit button? i dont think we want this

if (centerColumn) centerColumn.scrollTop = 0
}, [pathMatchParams?.context, pathMatchParams?.groupSlug, pathMatchParams?.view])

/* First time viewing a group redirect to welcome page if it exists, otherwise home view */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this being added on this branch? maybe a merge issue?

function RolesSettingsTab ({ group, commonRoles }) {
const dispatch = useDispatch()
const suggestions = useSelector(state => state.RoleSettings.map(personId => getPerson(state, { personId })))
const suggestions = createSelector([state => state.RoleSettings], state => state.RoleSettings.map(personId => getPerson(state, { personId })))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change? we dont use this pattern in other places really

}

function AddMemberToRole ({
export function AddMemberToRole ({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally we only export one component per file, so that the hot module reloading works. so we should move these into their own files to test them

const fetchSearchResultsAction = () => {
return fetchSearchResultsDebounced({ search: searchForInput || searchFromQueryString, filter })
}
const updateQueryParam = useCallback(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did i make these changes? 🤪

@tibetsprague
Copy link
Copy Markdown
Collaborator

@KevinTriplett im down to take it to the finish line, unless you want to!

@KevinTriplett
Copy link
Copy Markdown
Contributor Author

Yeah, you should take it over -- I think all that weirdness happened when I merged dev into the branch. Sorry about that, maybe you can roll the merge back?

@KevinTriplett
Copy link
Copy Markdown
Contributor Author

Should I delete this PR and redo getting tests working? If I do, I'd vote to do a PR in chunks, like critical / obvious first and then questionable last, everything else in between?

@hylobot
Copy link
Copy Markdown

hylobot commented Jun 14, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants