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

Chore(test): Actor test suite #356

Merged
merged 11 commits into from
Mar 28, 2023

Conversation

bakbakbakbakbak
Copy link
Collaborator

This PR introduces tests for Actors up to Sheet level. It is not complete as I've been unable to figure all the tests out, but the test coverage should be quite high with this.

I'm putting this as a draft PR for a few days while I continue linting give a night or two of good rest to simmer.

@anthonyronda
Copy link
Member

Started on this one, requesting backup because this is in large part a refactor of recent code by @wyrmisis and of course his opinion is valued :)

Copy link
Member

@anthonyronda anthonyronda left a comment

Choose a reason for hiding this comment

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

29/36 files reviewed

I would still like to get my eyes on all of them but for now I have a few comments/questions for you to look at


export const closeDialogs = async () => {
openDialogs()?.forEach(async (o) => {
await o.close();
});
};

export const closeSheets = async () => {
openWindows("sheet").forEach(async (w) => w.close());
await delay(220);
Copy link
Member

Choose a reason for hiding this comment

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

out of curiosity was 120 not enough on your machine? (as used for the dialog closing input delay constant at the top)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My machine must have had a bad day or something, I just tried changing it to the standard and it works. So I'll put this as the standard.

Copy link
Collaborator

@wyrmisis wyrmisis left a comment

Choose a reason for hiding this comment

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

I'm going to be completely honest with you: as long as these tests pass, I'm good. There is a lot here and I don't know if I have the brain space to give them the thorough reading necessary.

What's here is a good baseline, IMO. We can fix the tests as we fix bugs related to said tests.

(commenting instead of approving since I haven't been able to read all the things)


export const closeDialogs = async () => {
openDialogs()?.forEach(async (o) => {
await o.close();
});
};

export const closeSheets = async () => {
openWindows("sheet").forEach(async (w) => w.close());
await delay(220);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we be returning this await?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added it there (and changed it based on @anthonyronda's comment to waitForInput()) so to not having to add it everywhere we're waiting for the sheets to close. But I can change that if that is preferrable?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm conflicted on if we should even have sheet tests if we plan on doing new sheets in the future.

Copy link
Member

Choose a reason for hiding this comment

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

UFT doesn't have to inherit them, the OSE project can inherit them. As long as you don't mind having them here for now, I can help separate the imports at the testing entrypoint later

game.messages.size > 0
? game.messages.documentClass.deleteDocuments([], { deleteAll: true })
export const trashChat = (): Promise<any> =>
game.messages?.size > 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we're using a question mark here, maybe we ought to check for if game.messages?.size is truthy, instead of checking for if it's greater than 0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense, I think I put the question mark there as I got warnings that it may be empty. But since we are running tests with Foundry initiated, I think we can just do a straight check here.

@bakbakbakbakbak bakbakbakbakbak force-pushed the chore/actor_test_suite branch from 3ab54c6 to 1056765 Compare March 20, 2023 17:46
@bakbakbakbakbak
Copy link
Collaborator Author

I'm going to be completely honest with you: as long as these tests pass, I'm good. There is a lot here and I don't know if I have the brain space to give them the thorough reading necessary.

What's here is a good baseline, IMO. We can fix the tests as we fix bugs related to said tests.

(commenting instead of approving since I haven't been able to read all the things)

All the tests won't pass, so it is a question if we should merge the test suite and work off the failing tests. When I run with all the fixes I've put together I get 1069/1129 tests passing right now though.

@wyrmisis
Copy link
Collaborator

I'm going to be completely honest with you: as long as these tests pass, I'm good. There is a lot here and I don't know if I have the brain space to give them the thorough reading necessary.
What's here is a good baseline, IMO. We can fix the tests as we fix bugs related to said tests.
(commenting instead of approving since I haven't been able to read all the things)

All the tests won't pass, so it is a question if we should merge the test suite and work off the failing tests. When I run with all the fixes I've put together I get 1069/1129 tests passing right now though.

Any chance you could list out what all is failing, and what all will pass when whatever PRs you have out there go in? No biggie if not, I know that's a fair bit of book-keeping.

@bakbakbakbakbak
Copy link
Collaborator Author

bakbakbakbakbak commented Mar 20, 2023

Note: Lots of the failing tests are due to large quantity of HD rolling tests.

Failing Tests

This branch as-is: 861/1128
With #359: 883/1128 tests

With HD fixes (#372 ): 1044/1129 tests, failing tests:

  • character data model:
    • #spellList
    • init()
  • monster data model:
    • isNew()
    • init()
  • actor entity:
    • update()
    • rollAppearing()
    • rollDamage()
  • actor sheet:
    • _toggleContainedItems
    • _toggleItemSummary
    • _displayItemInChat
    • _removeItemFromActor
    • _onSpellChange
    • _resetSpells
    • _rollAbility
    • _rollAttack
    • _createItem
    • _onConfigureActor
  • actor sheet: drag & drop
    • _onDragStart -> _onDrop for containers
  • character sheet:
    • generateScores()
  • Actor entity tweaks
    • defaultOptions
    • title()
  • Container data model
    • totalWeight
  • item entity
  • create()
  • prepareDerivedData
  • spendSpell
  • pushManualTag
  • show
  • party sheet
    • _onDropFolder
  • party helpers
    • update
  • treasure helpers
    • drawTreasure

With #372 & #359: 1067/1129
fixes these tests:

  • actor sheet: drag & drop
    • _onDragStart -> _onDrop for containers

I have commits to fix:

Remaining failing tests

  • character data model:
    • #spellList
    • init()
  • monster data model:
    • isNew()
    • init()
  • actor entity:
    • update()
    • rollAppearing()
    • rollDamage()
  • actor sheet:
    • _toggleContainedItems
    • _toggleItemSummary
    • _displayItemInChat
    • _removeItemFromActor
    • _onSpellChange
    • _resetSpells
    • _rollAbility
    • _rollAttack
    • _createItem
    • `_onConfigureActor
  • character sheet:
    • generateScores()
  • Container data model
    • totalWeight
  • item entity
  • create()
  • prepareDerivedData
  • spendSpell
  • pushManualTag
  • show
  • party helpers
    • update

@anthonyronda
Copy link
Member

@bakbakbakbakbak thanks for listing the failing tests. If you'd like to, please share your WIPs for the ones on a local branch :)

Copy link
Member

@anthonyronda anthonyronda left a comment

Choose a reason for hiding this comment

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

LGTM

I will be honest, I did not scour each and every test (I'm particularly worried about false positives, which are harder to pick out)

I did look over them generally. If there are some mistakes in here, it's not the end of the world or even going to affect people's games too much :)

Thanks for such a gigantic contribution 🎉

game.messages.size > 0
? game.messages.documentClass.deleteDocuments([], { deleteAll: true })
: null;
export const trashChat = (): any => {
Copy link
Member

Choose a reason for hiding this comment

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

Don't know if this passes linting for the current ESLint config. That said, we may have to revisit discussion of the FVTT Types project anyway...

@anthonyronda
Copy link
Member

I'm hoping to re-spark discussion on a path forward for accepting fixes on the remaining failing tests before merging. Let us know how we can help forge a path forward!

My own view is that it's much more helpful for us to collaborate on fixes if we have the failing tests in 1.8.x. I don't want to merge 1.8.x into main, however, until all tests are green

@bakbakbakbakbak
Copy link
Collaborator Author

bakbakbakbakbak commented Mar 28, 2023

@bakbakbakbakbak thanks for listing the failing tests. If you'd like to, please share your WIPs for the ones on a local branch :)

I've submitted the PRs #372 #373 #374 now (and references them in the comment above)!

@anthonyronda anthonyronda merged commit a0280f6 into vttred:1.8.x Mar 28, 2023
@bakbakbakbakbak bakbakbakbakbak deleted the chore/actor_test_suite branch April 9, 2023 07:16
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