cli icon indicating copy to clipboard operation
cli copied to clipboard

fix: improved help message of 'new' command

Open lakshz opened this issue 3 years ago • 7 comments

Description

  • Improved the help message of 'new' command with examples

Related issue(s)

Fixes #162

lakshz avatar Jul 11 '22 17:07 lakshz

@LakshyaSatpal looking good man! Please just add a unit test that validates if list of examples is rendered? I'm just pretty sure that in few months someone will say "why do we use sync function here, lemme refactor" 😆

in the test, please do not "hardcode" list of examples as the tests will be affected by changes in examples list. So in test also read examples dynamically

derberg avatar Jul 21 '22 08:07 derberg

Hi @derberg ! I was going through oclif documentation for testing for commands. I'm finding it challenging to write a test to check if a file is rendered. I mean, I couldn't get what do I have to actually test, validate if the user entered the correct example name from available examples? or only check the working of loadExampleFile synchronous function that we wrote? Btw, this is the first time I am writing unit tests. Please bear with me 😅

lakshz avatar Jul 29 '22 10:07 lakshz

@LakshyaSatpal no worries. Happy to help you if you need.

  • you need to provide test for new functionality. New functionality is: much better help message with list of examples. We need to have a test, that will evaluate if the list of examples from /assets/examples is included in the help message that you just created.
  • have a look on existing tests https://github.com/asyncapi/cli/tree/master/test/commands for commands. See how we check if certain message appears in the console

I recommend, especially if it is your first time, first create a test, where you basically hardcode the expected message in the text, so you check if the message printed in terminal match the message that you hardcode in test (with list of examples).

Once ☝🏼 works, then work on making sure that the list of examples is not hardcoded, but you read in dynamically inside the test, from examples dir

derberg avatar Jul 29 '22 10:07 derberg

@derberg I wrote this simple test in the new.test.ts file where I checked for help message to contain the first example which I hard coded.

test
		.stdout()
		.command(['new', '--help'])
		.it('help includes available examples', (ctx, done) => {
			expect(ctx.stdout).to.contain('- simple.yml');
			done();
		});

This shows me an error of AssertionError: expected '' to include '- simple.yml'. I believe, it is not getting that I'm checking for help flag command. Am I moving in the right direction?

lakshz avatar Jul 29 '22 13:07 lakshz

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Jul 31 '22 05:07 sonarqubecloud[bot]

@LakshyaSatpal hey, you need a hand? I was out on holidays, but now back 💪🏼

derberg avatar Aug 16 '22 12:08 derberg

@LakshyaSatpal hey, you need a hand? I was out on holidays, but now back 💪🏼

Hi @derberg, still stuck now the same problem - not able to write a test with help flag 😥, discussed it with @Souvikns as well

lakshz avatar Aug 21 '22 12:08 lakshz

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Nov 21 '22 15:11 sonarqubecloud[bot]

@LakshyaSatpal I hope you are still interested with this one. It helps with DX and as you see it is ok that we drop testing part

derberg avatar Dec 08 '22 10:12 derberg

@derberg Okay, I removed the test and addressed other feedbacks. Please see if we can merge now

lakshz avatar Dec 08 '22 14:12 lakshz

@Souvikns ping 😉

derberg avatar Dec 15 '22 09:12 derberg

@LakshyaSatpal hay can you fix linter issues please

derberg avatar Dec 20 '22 13:12 derberg

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Dec 21 '22 20:12 sonarqubecloud[bot]

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Feb 06 '23 16:02 sonarqubecloud[bot]

I have no idea why tests are failing 😭 it is not random, it is always [ERR_INVALID_ARG_TYPE]: The "warning" argument must be of type string or an instance of Error. Received an instance of TypeError but why.......#$%

@LakshyaSatpal maybe you could switch to readFile that is already used in the same file, instead of importing readFileSync? or was sync selected because description: await getExamplesFlagDescription() was not possible?

derberg avatar Feb 06 '23 16:02 derberg

@LakshyaSatpal not sure why but you are having a lot of linter issues. Do you want to continue with this PR?

derberg avatar Mar 27 '23 09:03 derberg

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Apr 04 '23 14:04 sonarqubecloud[bot]

@LakshyaSatpal can you specify if you plan to continue with this one, or should that be released to other contributors?

derberg avatar Apr 24 '23 13:04 derberg

no reaction so closing, hope someone will pick it up from https://github.com/asyncapi/cli/issues/162

derberg avatar Jul 19 '23 11:07 derberg

done with https://github.com/asyncapi/cli/pull/758

derberg avatar Sep 04 '23 13:09 derberg