cli icon indicating copy to clipboard operation
cli copied to clipboard

[FEATURE] Addition of tests for the commands that depend on browser interaction.

Open neoandmatrix opened this issue 9 months ago • 8 comments

Why do we need this improvement?

Currently none of the commands like the one related to studio can be tested properly as there is a lack of mechanism to test these command that open a browser.

How will this change help?

This change will allow us to properly test the commands like asyncapi start studio and another commands like asyncapi new which require interaction with browser.

Screenshots

No response

How could it be implemented/designed?

As this is browser interaction related we can use libraries like Puppeteer but first discussions with maintainers are required to figure out a correct approach.

🚧 Breaking changes

No

👀 Have you checked for similar open issues?

  • [x] I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

Yes I am willing to submit a PR!

neoandmatrix avatar Mar 05 '25 14:03 neoandmatrix

Good Enhancement for the Gsoc program, we can take during that time

AayushSaini101 avatar Mar 07 '25 03:03 AayushSaini101

Hey @AayushSaini101 @Shurtu-gal taking this up as in testing suit this is a major missing part.

Rest commands have some kind of test these lack that.

neoandmatrix avatar May 26 '25 12:05 neoandmatrix

Thanks @neoandmatrix

Shurtu-gal avatar May 26 '25 12:05 Shurtu-gal

@neoandmatrix can you define the scope of this issue ?

AayushSaini101 avatar Jun 06 '25 01:06 AayushSaini101

Hey @Shurtu-gal @AayushSaini101 did some research on this and here is what i believe can be covered in this :-

First as we need to increase test coverage with this one hence the testing needs to be integrated with current tests only. Now current tests use mocha so these tests will be needed to be integrated with that only.

Second i believe the following can be tested currently :-

  • When we test studio with start studio command the presence of elements such as sidebar , editor etc. can be checked to confirm that correct mode is opened.
  • When we test studio with start preview command absence of elements such as editor and presence of preview panel can be tested to confirm that correct mode is opened.

One missing thing is testing websockets as they might be bit tricky to test. First to test websocket one would need to check that if files are modified correctly or not which involves reading from files and also comparing them and testing them both way might be bit difficult and in real-time during tests so these can be added later or after above are implemented in my opinion.

Another thing is what framework to use for this. Currently i explored cypress , puppeteer and playwright out of these I found cypress to be best supported with mocha and chai currently.

Puppeteer also have an example of usage with mocha but is quite outdated .

Also one needs to manage that the commands open up a browser instance and a http websocket server in same process which will required to be safely terminated and not the whole running test.

Let me know if i missed something or anything can be added to this.

CC:- @Souvikns

neoandmatrix avatar Jun 06 '25 16:06 neoandmatrix

We can test websockets by mocking stuff if I am not wrong.

Shurtu-gal avatar Jun 11 '25 05:06 Shurtu-gal

We can test websockets by mocking stuff if I am not wrong.

Thanks will try,

Anything else that i might have missed in scope for this @Shurtu-gal ?

neoandmatrix avatar Jun 11 '25 05:06 neoandmatrix

Did some testing with puppeteer and worked good along with by default being in headless mode. Continuing the implementation with that only.

neoandmatrix avatar Jun 16 '25 07:06 neoandmatrix