-
Notifications
You must be signed in to change notification settings - Fork 909
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
Renovate/conventional changelog angular 7.x #3725
Renovate/conventional changelog angular 7.x #3725
Conversation
Tests are failing. Did these work locally for you? |
In scope-enum, these tests still failing, I miss some overall logic about it.
|
tbh, I don't know as well. But in the past those never had issues. The only hint I have is to dig into the commits and see when those were introduced and see if the commit-message(s) and context help. I.e. if those were introduced to check for a certain bug. |
Please update me if you discover something. I would do the same. Thanks. |
89d64a9
to
785669f
Compare
Do you believe @escapedcat the problem lives in parse ? |
Hm, sorry, I don't know. I would need to dig into it as well. Currently I don't have time for that. |
785669f
to
e77fbea
Compare
0d52fda
to
17ce0e1
Compare
@@ -97,18 +100,29 @@ test('scope-enum with empty scope and never should succeed empty enum', async () | |||
|
|||
test('scope-enum with multiple scopes should succeed on message with multiple scopes', async () => { | |||
const [actual] = scopeEnum(await parsed.multiple, 'never', ['bar', 'baz']); | |||
const expected = false; | |||
const expected = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test should expect false, similar to the new test below (the message must not have any of the forbidden scopes - and in this case, it does, indicating a validation failure).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test currently passes with true expectations.
having it false will make it a failing test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it was originally expecting false per the diff though, and is now failing.
The last two tests (of the three that are failing) do seem incorrect to me also in terms of the result they expect given the test description - the current logic indicates that the validation should fail for 'never' only if all of the given scopes are included in the commit message. However, it seems more reasonable to me that one would want the validation to fail for 'never' only if any of the given scopes are included. Example:
Current logic:
Proposed logic:
There's a subtle distinction here between !every (all elements must not) and !some (any element must not); the current logic is relying on !every. Maybe can be addressed as a followup instead of in this task since it's a logic change? |
hello @joberstein , my goal was to try to speed up this commitlint PR, but I miss a lot of context of the project as a whole and I do not have so much time to dive into the reason why. |
'bar', | ||
'qux', | ||
]); | ||
const expected = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should return true per the current logic (a false result will be provided only if both 'bar' and 'baz' are in the scopes, but only 'bar' is in the scopes). This is because the current logic says: 'return the opposite of whether all message scopes - bar, baz - are included in the given scopes - bar, qux'. Both 'bar' and 'baz' are not in message scopes, and since the result evaluates to the opposite of that, the expectation should be true.
Given that, the current logic does seem incorrect, but I suggest making a new PR to update logic and test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
test('scope-enum with multiple scope should error on message with superfluous scope', async () => { | ||
const [actual, message] = scopeEnum(await parsed.multiple, 'never', ['bar']); | ||
const expected = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the above, this test should return true per the current logic (a false result will be provided only if both 'bar' and 'baz' are in the scopes, but only 'bar' is in the scopes). This is because the current logic says: 'return the opposite of whether all message scopes - bar, baz - are included in the given scopes - bar'. Both 'bar' and 'baz' are not in message scopes, and since the result evaluates to the opposite of that, the expectation should be true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
I added a comment to each of the failing test and why the expectations are reversed, causing the tests to fail. I agree that the parse package logic appears to be incorrect. If addressed in a separate PR, I imagine the logic should be:
The problem here is that the 'never' case currently evaluates to the opposite of the 'always' case right now, but that is not equivalent to what I've proposed above. @escapedcat does that seem like it should be addressed as an issue? |
Thanks for your research and proposals @joberstein ! |
Sure, and makes sense to me as a breaking change if I'm understanding the original intent of the rule correctly. |
0c60c9a
to
8fb26ae
Compare
228a38d
to
d2f8a46
Compare
Thank everyone for the support |
967b191
to
76b25fb
Compare
Sorry, so, just for a recap to understand this better. Next steps could be:
Does this sound right? |
@escapedcat this PR indeed improve tests and get v7 up and running without breaking changes. Next steps might be a bit more:
It could be a breaking change. Or a fix. When fix is done, it will be more clear if Breaking or not. |
const expected = true; | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
test('scope-enum with multiple scopes should error on message with superfluous scope', async () => { | ||
test('scope-enum with multiple scope should succeed on message with superfluous scope', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the message was technically correct before in terms of test intent, even though it doesn't describe the assertion in the test. This should be failing and it's not because the behavior is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tackled!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, but @silversonicaxel I left a comment about the test description change, not sure how important it is.
3c9c48c
to
fd1f1d3
Compare
}); | ||
|
||
test('scope-enum with multiple scopes should error on message with forbidden enum', async () => { | ||
const [actual] = scopeEnum(await parsed.multiple, 'never', ['bar', 'qux']); | ||
test('scope-enum with multiple scopes should succeed on message with forbidden enum', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test description should say it 'should error' I believe.
657c548
to
9fcfb05
Compare
…ate/conventional-changelog-angular-7.x
Thanks @silversonicaxel and @joberstein for this! Will merge |
128f5f6
into
conventional-changelog:renovate/conventional-changelog-angular-7.x
* chore: update dependency conventional-changelog-angular to v7 * Renovate/conventional changelog angular 7.x (#3725) * chore: update dependency conventional-changelog-angular to v7 * test: update conventional-changelog-angular unit tests * test: improve scope-enum unit tests --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Alessandro Rabitti <silversonicaxel@users.noreply.github.com>
Description
Improved unit tests section for migration to conventional-changelog-angular 7.0
Motivation and Context
#3698
Usage examples
/
How Has This Been Tested?
run
yarn test
locallyTypes of changes
Fixed some unit tests related to conventional-changelog-angular
Improved data unit tests suite of scope-enum, but two tests still failing, I miss some overall logic about it.
Checklist: