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

test(besu): refactor jest test negative test cases #3467

Closed
jagpreetsinghsasan opened this issue Aug 8, 2024 · 4 comments · Fixed by #3468
Closed

test(besu): refactor jest test negative test cases #3467

jagpreetsinghsasan opened this issue Aug 8, 2024 · 4 comments · Fixed by #3468
Assignees
Labels
Besu enhancement New feature or request good-first-issue-100-introductory P3 Priority 3: Medium Tests Anything related to tests be that automatic or manual, integration or unit, etc.

Comments

@jagpreetsinghsasan
Copy link
Contributor

Description

Refactor all the negative test case exception assertions for cactus-plugin-ledger-connector-besu so that they do not use try-catch blocks but instead declare the requirements through Jest's (and jest-extended's) own API.

The parent issue with a much more detailed explanation of what's needed and code examples on how to do it:
Parent Issue: https://github.com/hyperledger/cacti/issues/3455

Acceptance Criteria
Test passes the same as before
Negative test case assertions have been migrated the way it is explained in the parent issue.

@jagpreetsinghsasan jagpreetsinghsasan added enhancement New feature or request Besu Tests Anything related to tests be that automatic or manual, integration or unit, etc. P3 Priority 3: Medium good-first-issue-100-introductory labels Aug 8, 2024
@jagpreetsinghsasan
Copy link
Contributor Author

@ashnashahgrover here's the issue

@jagpreetsinghsasan jagpreetsinghsasan changed the title test(plugin-besu): refactor jest test negative test cases test(besu): refactor jest test negative test cases Aug 8, 2024
@ashnashahgrover
Copy link
Contributor

Please assign me.

ashnashahgrover added a commit to ashnashahgrover/cacti that referenced this issue Aug 8, 2024
Primary Changes
----------------
1. Refactored all negative test case exception assertions for cactus-plugin-ledger-connector-besu.
Removed try-catch blocks, replaced with declarations through jest and jest-extended's own API.
2. Noted two tests within openapi-validation.test.ts
(GetPastLogsEndpoint and GetBesuRecordEndpointV1 with empty parameters) where the status
code returned should be 400 but is 200. This could be investigated in a seperate issue.

Fixes hyperledger-cacti#3467

Signed-off-by: ashnashahgrover <ashnashahgrover777@gmail.com>
ashnashahgrover added a commit to ashnashahgrover/cacti that referenced this issue Aug 8, 2024
Primary Changes
----------------
1. Refactored all negative test case exception assertions for cactus-plugin-ledger-connector-besu.
Removed try-catch blocks, replaced with declarations through jest and jest-extended's own API.
2. Noted two tests within openapi-validation.test.ts
(GetPastLogsEndpoint and GetBesuRecordEndpointV1 with empty parameters) where the status
code returned should be 400 but is 200. This could be investigated in a seperate issue.

Fixes hyperledger-cacti#3467

Signed-off-by: ashnashahgrover <ashnashahgrover777@gmail.com>
@ashnashahgrover
Copy link
Contributor

@jagpreetsinghsasan

  1. In the PR I have noted two tests in openapi-validation.test.ts where the status code returned should be 400 but is 200 - before refactoring those I wanted to confirm if this is correct. I print those status codes with comments on these lines:

https://github.com/hyperledger/cacti/blob/f70e0f5834160e22304edc39a1cfeee3945cd8b0/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/openapi/openapi-validation.test.ts#L882

https://github.com/hyperledger/cacti/blob/f70e0f5834160e22304edc39a1cfeee3945cd8b0/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/openapi/openapi-validation.test.ts#L981

  1. I left the original try-catch blocks as comments in the PR for your reference in case it is helpful while reviewing - I can take them out once you are done reviewing and/or if you don't need them.

ashnashahgrover added a commit to ashnashahgrover/cacti that referenced this issue Aug 11, 2024
Primary Changes
----------------
1. Refactored all negative test case exception assertions for cactus-plugin-ledger-connector-besu.
Removed try-catch blocks, replaced with declarations through jest and jest-extended's own API.
2. Noted two tests within openapi-validation.test.ts
(GetPastLogsEndpoint and GetBesuRecordEndpointV1 with empty parameters) where the status
code returned should be 400 but is 200. This could be investigated in a seperate issue.

Fixes hyperledger-cacti#3467

Signed-off-by: ashnashahgrover <ashnashahgrover777@gmail.com>
@jagpreetsinghsasan
Copy link
Contributor Author

jagpreetsinghsasan commented Aug 12, 2024

@ashnashahgrover

  1. Please mention this point in the PR rather than here while referencing the lines within the PR commit. That way, it will be easier to navigate
  2. You dont have to add the previous code as in code comment. This is already enabled when we review the PR (you can also check the Files Changed tab under the PR), we can see the difference.
    For example
    image

You can also utilize the git graph plugin to view commits and their diff

ashnashahgrover added a commit to ashnashahgrover/cacti that referenced this issue Aug 12, 2024
Primary Changes
----------------
1. Refactored all negative test case exception assertions for cactus-plugin-ledger-connector-besu.
Removed try-catch blocks, replaced with declarations through jest and jest-extended's own API.
2. Noted two tests within openapi-validation.test.ts
(GetPastLogsEndpoint and GetBesuRecordEndpointV1 with empty parameters) where the status
code returned should be 400 but is 200. This could be investigated in a seperate issue.

Fixes hyperledger-cacti#3467

Signed-off-by: ashnashahgrover <ashnashahgrover777@gmail.com>
ashnashahgrover added a commit to ashnashahgrover/cacti that referenced this issue Aug 12, 2024
Primary Changes
----------------
1. Refactored all negative test case exception assertions for cactus-plugin-ledger-connector-besu.
Removed try-catch blocks, replaced with declarations through jest and jest-extended's own API.
2. Noted two tests within openapi-validation.test.ts
(GetPastLogsEndpoint and GetBesuRecordEndpointV1 with empty parameters) where the status
code returned should be 400 but is 200. This could be investigated in a seperate issue.

Fixes hyperledger-cacti#3467

Signed-off-by: ashnashahgrover <ashnashahgrover777@gmail.com>
ashnashahgrover added a commit to ashnashahgrover/cacti that referenced this issue Aug 18, 2024
Primary Changes
----------------
1. Refactored all negative test case exception assertions for cactus-plugin-ledger-connector-besu.
Removed try-catch blocks, replaced with declarations through jest and jest-extended's own API.
2. Noted two tests within openapi-validation.test.ts
(GetPastLogsEndpoint and GetBesuRecordEndpointV1 with empty parameters) where the status
code returned should be 400 but is 200. This could be investigated in a seperate issue.

Fixes hyperledger-cacti#3467

Signed-off-by: ashnashahgrover <ashnashahgrover777@gmail.com>
petermetz pushed a commit to ashnashahgrover/cacti that referenced this issue Aug 29, 2024
Primary Changes
----------------
1. Refactored all negative test case exception assertions for cactus-plugin-ledger-connector-besu.
Removed try-catch blocks, replaced with declarations through jest and jest-extended's own API.
2. Noted two tests within openapi-validation.test.ts
(GetPastLogsEndpoint and GetBesuRecordEndpointV1 with empty parameters) where the status
code returned should be 400 but is 200. This could be investigated in a seperate issue.

Fixes hyperledger-cacti#3467

Signed-off-by: ashnashahgrover <ashnashahgrover777@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Besu enhancement New feature or request good-first-issue-100-introductory P3 Priority 3: Medium Tests Anything related to tests be that automatic or manual, integration or unit, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants