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

feat(query-generation): modal for specifying default values INTELLIJ-198 #133

Merged
merged 12 commits into from
Jan 28, 2025

Conversation

kmruiz
Copy link
Contributor

@kmruiz kmruiz commented Jan 24, 2025

Description

This PR is bigger than usual because it required a pretty big refactor on our test code due to incompatibilities between how tests in IntelliJ and AssertJ Swing handle headless mode.

  • Removed CodeInsightsTestExtension, now all tests that are not UI tests will use the IntegrationTest extension.
  • IntegrationTest now uses a synthetic project, instead of loading basic-java-project. It's faster and safer.
  • Projects are loaded by default on beforeAll instead of beforeEach, speeding up the tests.
  • Removed a lot of boilerplate for parsing tests (imports on code tests).
  • Added integration with AssertJ for Swing tests.

Checklist

Open Questions

@kmruiz kmruiz requested a review from himanshusinghs January 24, 2025 15:48
@kmruiz kmruiz marked this pull request as ready for review January 27, 2025 22:16
@github-actions github-actions bot added the feat label Jan 27, 2025
@kmruiz kmruiz changed the title feat(query-generation): modal for specifying default values feat(query-generation): modal for specifying default values INTELLIJ-198 Jan 27, 2025
Copy link

github-actions bot commented Jan 27, 2025

Coverage Report

Overall Project 80.47% -1.5%
Files changed 73.66%

File Coverage
MongoshDialectFormatter.kt 93.67%
NamespaceSelector.kt 93.5% -6.5%
Node.kt 89.1% -8.53% 🚫
DependencyInjection.kt 86.82% -7.36% 🚫
BsonType.kt 83.48% -2.17% 🚫
JavaDriverDialectFormatter.kt 83.19%
MongoshBackend.kt 79.62% -5.8% 🚫
PsiMdbTreeUtil.kt 74.89% -0.22%
RunQueryModal.kt 64.42% -34.48% 🚫
Context.kt 61.88% -8.29%
HasFieldReference.kt 59.48% -2.33%
References.kt 48.92% -16.02% 🚫
RunQueryCodeActionBridge.kt 17.59% -22.09% 🚫

@github-actions github-actions bot added feat and removed feat labels Jan 27, 2025
@github-actions github-actions bot added feat and removed feat labels Jan 27, 2025
@github-actions github-actions bot added feat and removed feat labels Jan 27, 2025
@github-actions github-actions bot added feat and removed feat labels Jan 27, 2025
@github-actions github-actions bot added feat and removed feat labels Jan 27, 2025
Copy link

🤖 Benchmark Comparison for chore: use a virtual ui env for component tests

Benchmark Previous Current Change
com.mongodb.jbplugin.jmh.SampleBenchmark.init 2,671,020,884.71 ops/s 2,622,077,105.18 ops/s -1.83%

Copy link

🤖 Benchmark Comparison for chore: rename task, it's running tests, not preparing the environment

Benchmark Previous Current Change
com.mongodb.jbplugin.jmh.SampleBenchmark.init 2,671,020,884.71 ops/s 2,626,084,235.06 ops/s -1.68%

Copy link
Contributor

@himanshusinghs himanshusinghs left a comment

Choose a reason for hiding this comment

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

Pretty amazing work @kmruiz! I left a few small suggestions but overall it looks really great.

Comment on lines +44 to +48
class RunQueryModal(
private val query: Node<PsiElement>,
private val dataSource: LocalDataSource,
private val coroutineScope: CoroutineScope
) : DialogWrapper(query.source.project, false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make this UI component consistent with the way NamespaceSelector and the others are built? Keeping the actual swing component (DialogWrapper in this case) internal to the class and exposing only what is needed on the interface. I noticed that it helps a lot in keeping the coupling loose when composing components together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. I don't have a strong opinion, do you want to discuss this and see tradeoffs? I can book some time today and we can have some quality conversation on this 😄 .

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea that sounds good. Lets do that.

Comment on lines +59 to +61
databaseComboBox.requireEnabled()
.requireItemCount(1)
.requireSelection("db1")
Copy link
Contributor

Choose a reason for hiding this comment

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

The API looks pretty amazing, great find <3

Comment on lines -30 to -31
@Nested
@DisplayName("when execute is triggered")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it because the new annotation does not support nested test or in general we don't want to use nested tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if we want to use nested test after my findings. I've found that the nested tests don't inherit the whole context of the parent class, and parts of the IntegrationTestExtension were not working properly. I guess if we don't need context and the tests can run in parallel we can use nested without issues, but with extensions, it seems to be pretty flaky.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. I did come across some issues using nested tests alongside CodeInsight tests but did not dig deeper back then. Seems like the problem is the same with them not being able to share the parent context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, maybe we can specify some conventions on when to use nested tests. I find them useful, so maybe we can find them a place where they are safe to use? Or should we just drop them?

@github-actions github-actions bot added feat and removed feat labels Jan 28, 2025
@github-actions github-actions bot added feat and removed feat labels Jan 28, 2025
Copy link

🤖 Benchmark Comparison for chore: add tests to the modal

Benchmark Previous Current Change
com.mongodb.jbplugin.jmh.SampleBenchmark.init 2,671,020,884.71 ops/s 2,602,171,838.67 ops/s -2.58%

@kmruiz kmruiz merged commit facd7e2 into main Jan 28, 2025
12 checks passed
@kmruiz kmruiz deleted the feat/INTELLIJ-198 branch January 28, 2025 16:29
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 this pull request may close these issues.

2 participants