Skip to content

Add test for behaviour around expanded state#1972

Merged
norascheuch merged 5 commits intomainfrom
nora/expanded-tests
Jan 17, 2023
Merged

Add test for behaviour around expanded state#1972
norascheuch merged 5 commits intomainfrom
nora/expanded-tests

Conversation

@norascheuch
Copy link
Copy Markdown
Contributor

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@norascheuch norascheuch requested a review from a team as a code owner January 16, 2023 16:33
Copy link
Copy Markdown
Contributor

@charisk charisk left a comment

Choose a reason for hiding this comment

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

Thanks for improving our test coverage! Just some small comments.

Comment thread extensions/ql-vscode/test/unit-tests/databases/db-manager.test.ts Outdated
Comment thread extensions/ql-vscode/test/unit-tests/databases/db-manager.test.ts Outdated
expandedItems![0] as VariantAnalysisUserDefinedListExpandedDbItem;
expect(expandedItem.listName).toEqual(listName);

// Trigger adding an item that is not in the config
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be more realistic if the test added a different item (that exists), and checked that the other one (that doesn't exist) was removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍 Good idea

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(Optional) I think this is slightly confusing because there are 3 different lists at play. I would do the following:

  • Have expanded state have only 1 item (the removedVariantAnalysisList)
  • Trigger adding a new item in the config (the variantAnalysisList)
  • Check that the expanded state no longer contains the removedVariantAnalysisList

});

await dbManager.addDbItemToExpandedState(dbItem);
const expandedItems = await app.workspaceState.get<ExpandedDbItem[]>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this need the await? I was under the impression it's a synchronous operation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I just checked and indeed this is synchronous, so we can remove the await.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Thanks

Copy link
Copy Markdown
Contributor Author

@norascheuch norascheuch left a comment

Choose a reason for hiding this comment

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

Thanks @charisk , changes are pushed!

Comment thread extensions/ql-vscode/test/unit-tests/databases/db-manager.test.ts Outdated
Comment thread extensions/ql-vscode/test/unit-tests/databases/db-manager.test.ts Outdated
expandedItems![0] as VariantAnalysisUserDefinedListExpandedDbItem;
expect(expandedItem.listName).toEqual(listName);

// Trigger adding an item that is not in the config
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍 Good idea

Copy link
Copy Markdown
Contributor

@charisk charisk left a comment

Choose a reason for hiding this comment

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

Looks good! Just a couple of minor suggestions.

expandedItems![0] as VariantAnalysisUserDefinedListExpandedDbItem;
expect(expandedItem.listName).toEqual(listName);

// Trigger adding an item that is not in the config
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(Optional) I think this is slightly confusing because there are 3 different lists at play. I would do the following:

  • Have expanded state have only 1 item (the removedVariantAnalysisList)
  • Trigger adding a new item in the config (the variantAnalysisList)
  • Check that the expanded state no longer contains the removedVariantAnalysisList

});

await dbManager.addDbItemToExpandedState(dbItem);
const expandedItems = await app.workspaceState.get<ExpandedDbItem[]>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I just checked and indeed this is synchronous, so we can remove the await.

@norascheuch norascheuch enabled auto-merge January 17, 2023 12:30
@norascheuch norascheuch merged commit c5722d7 into main Jan 17, 2023
@norascheuch norascheuch deleted the nora/expanded-tests branch January 17, 2023 13:23
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.

2 participants