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

fix(KONFLUX-5886): allow unselecting default context #58

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

CryptoRodeo
Copy link
Contributor

The user should be able to unselect the default context during the creation of an integration test.

Other changes:

  • Contexts are now required (at least one)

@CryptoRodeo
Copy link
Contributor Author

Demo of the following:

  • default context can now be unselected (main bug fixed)
  • contexts are now required by the form and modal (at least 1 must be selected).
konflux-5886.mp4

@CryptoRodeo CryptoRodeo force-pushed the konflux-5886 branch 2 times, most recently from 9d36d95 to eb33e13 Compare December 18, 2024 21:10
@CryptoRodeo CryptoRodeo marked this pull request as ready for review December 18, 2024 21:16
@CryptoRodeo CryptoRodeo self-assigned this Dec 18, 2024
@CryptoRodeo
Copy link
Contributor Author

It appears that the code coverage step fails:

error - 2024-12-18 21:48:17,362 -- Report creating failed: {"message":"Token required because branch is protected"}
Error: Codecov:
                        Failed to properly create report: The process '/home/runner/work/_actions/codecov/codecov-action/v4/dist/codecov' failed with exit code 1

@testcara
Copy link
Contributor

I met the same token problem for my ci jobs but after 2 days later, retry fixed the problem. It seems the ci is not very stable for this part.

@testcara
Copy link
Contributor

LGTM

@JoaoPedroPP
Copy link
Contributor

LGTM

JoaoPedroPP
JoaoPedroPP previously approved these changes Jan 6, 2025
@CryptoRodeo CryptoRodeo added this pull request to the merge queue Jan 6, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Jan 6, 2025
@StanislavJochman
Copy link
Contributor

LGTM

@@ -0,0 +1,17 @@
import { fireEvent, screen, act } from '@testing-library/react';
Copy link
Collaborator

@sahil143 sahil143 Jan 8, 2025

Choose a reason for hiding this comment

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

move this file under __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.

File has been moved

Copy link
Contributor Author

@CryptoRodeo CryptoRodeo Jan 8, 2025

Choose a reason for hiding this comment

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

Summary of all failing tests
FAIL src/components/IntegrationTests/__tests__/test-utils.ts
  ● Test suite failed to run

    Your test suite must contain at least one test.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:133:18)
      at node_modules/@jest/core/build/TestScheduler.js:254:19
      at node_modules/emittery/index.js:363:13
          at Array.map (<anonymous>)
      at Emittery.emit (node_modules/emittery/index.js:361:23)

It looks like the test run failed because only tests are expected under __tests__... would moving this back to utils be fine? Or maybe __test-utils__?

Copy link
Contributor Author

@CryptoRodeo CryptoRodeo Jan 9, 2025

Choose a reason for hiding this comment

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

@sahil143 I reverted the change to fix the unit test step from failing (see above). If you have any recommendations on where else I should move this besides __tests__ to prevent the failure again please let me know.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My only concern is that the testing utilities should not be kept with the actual component utilities. I like the idea of creating separate utilities for opening dropdowns that can be used everywhere else. You can rename the functions to something more specific like openIntegrationTestContextDropown and move them to the common test-utils in src/utils/test-utils.ts. I am open to any other suggestions.

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 83.63636% with 9 lines in your changes missing coverage. Please review.

Project coverage is 80.09%. Comparing base (88eafd6) to head (b06bc0f).

Files with missing lines Patch % Lines
...ests/IntegrationTestForm/utils/validation-utils.ts 42.85% 4 Missing ⚠️
...onents/IntegrationTests/utils/validation-utils.tsx 62.50% 3 Missing ⚠️
.../components/IntegrationTests/ContextSelectList.tsx 50.00% 1 Missing ⚠️
...nTests/IntegrationTestForm/IntegrationTestView.tsx 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #58      +/-   ##
==========================================
- Coverage   80.15%   80.09%   -0.06%     
==========================================
  Files         569      570       +1     
  Lines       21391    21443      +52     
  Branches     5291     5307      +16     
==========================================
+ Hits        17146    17175      +29     
- Misses       4220     4244      +24     
+ Partials       25       24       -1     
Flag Coverage Δ
unittests 80.09% <83.63%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@CryptoRodeo
Copy link
Contributor Author

Code patch check looks safe to ignore IMO.

if (!contexts?.length) return [];
const getFormContextValues = (
integrateTest: IntegrationTestScenarioKind | null | undefined,
): FormContext[] => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Adding unit tests for this utility should help with the codecoverage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Test added.

@@ -0,0 +1,17 @@
import { fireEvent, screen, act } from '@testing-library/react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

My only concern is that the testing utilities should not be kept with the actual component utilities. I like the idea of creating separate utilities for opening dropdowns that can be used everywhere else. You can rename the functions to something more specific like openIntegrationTestContextDropown and move them to the common test-utils in src/utils/test-utils.ts. I am open to any other suggestions.

@CryptoRodeo CryptoRodeo force-pushed the konflux-5886 branch 2 times, most recently from f64d63d to 5aecd12 Compare January 13, 2025 17:03
@CryptoRodeo
Copy link
Contributor Author

@sahil143 That's fair. I moved the test utils to src/utils/test-utils.ts and renamed them: https://github.com/konflux-ci/konflux-ui/pull/58/files#diff-f13f3abfe65497faaec0c4ca81fa8037b6aa1094ed9e293becd345375fdcfda6R250-R261

The user should be able to unselect the default context during the
creation of an integration test.

Other changes:
- Contexts are now required (at least one)

Signed-off-by: Bryan Ramos <[email protected]>
@sahil143 sahil143 merged commit b5460e5 into konflux-ci:main Jan 15, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants