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

ERM-3395, Complete absent test cases for stripes-erm-components document filter #709

Merged
merged 15 commits into from
Nov 19, 2024

Conversation

MonireRasouli
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Nov 7, 2024

License CLA Stuck? (Developer should make sure that it is really stuck before clicking)

Copy link

github-actions bot commented Nov 7, 2024

Jest Unit Test Results

  1 files  ± 0   42 suites  ±0   1m 20s ⏱️ +5s
339 tests +21  339 ✅ +21  0 💤 ±0  0 ❌ ±0 
340 runs  +21  340 ✅ +21  0 💤 ±0  0 ❌ ±0 

Results for commit 92815e4. ± Comparison against base commit 241dc35.

This pull request removes 24 and adds 45 tests. Note that renamed tests count towards both.
DocumentFilterField Render DocumentFilterField with 0 in the array displays attibute label(s) ‑ DocumentFilterField Render DocumentFilterField with 0 in the array displays attibute label(s)
DocumentFilterField Render DocumentFilterField with 0 in the array displays operator label(s) ‑ DocumentFilterField Render DocumentFilterField with 0 in the array displays operator label(s)
DocumentFilterField Render DocumentFilterField with 0 in the array displays value label(s) ‑ DocumentFilterField Render DocumentFilterField with 0 in the array displays value label(s)
DocumentFilterField Render DocumentFilterField with 1 in the array displays attibute label(s) ‑ DocumentFilterField Render DocumentFilterField with 1 in the array displays attibute label(s)
DocumentFilterField Render DocumentFilterField with 1 in the array displays operator label(s) ‑ DocumentFilterField Render DocumentFilterField with 1 in the array displays operator label(s)
DocumentFilterField Render DocumentFilterField with 1 in the array displays value label(s) ‑ DocumentFilterField Render DocumentFilterField with 1 in the array displays value label(s)
DocumentFilterField Render DocumentFilterField with 1 in the array renders the add rule button ‑ DocumentFilterField Render DocumentFilterField with 1 in the array renders the add rule button
DocumentFilterField Render DocumentFilterField with 2 in the array displays attibute label(s) ‑ DocumentFilterField Render DocumentFilterField with 2 in the array displays attibute label(s)
DocumentFilterField Render DocumentFilterField with 2 in the array displays operator label(s) ‑ DocumentFilterField Render DocumentFilterField with 2 in the array displays operator label(s)
DocumentFilterField Render DocumentFilterField with 2 in the array displays value label(s) ‑ DocumentFilterField Render DocumentFilterField with 2 in the array displays value label(s)
…
DocumentFilter ActiveFilter tests with active filters should clear the selected document filters by clicking on the clear button ‑ DocumentFilter ActiveFilter tests with active filters should clear the selected document filters by clicking on the clear button
DocumentFilter ActiveFilter tests with multiple active filters should clear the selected document filters by clicking on the clear button ‑ DocumentFilter ActiveFilter tests with multiple active filters should clear the selected document filters by clicking on the clear button
DocumentFilter ActiveFilter tests without active filters should clear the selected document filters by clicking on the clear button ‑ DocumentFilter ActiveFilter tests without active filters should clear the selected document filters by clicking on the clear button
DocumentFilterField Render 0 DocumentFilterField component(s) DocumentFilterRule interactions does not render the add rule button ‑ DocumentFilterField Render 0 DocumentFilterField component(s) DocumentFilterRule interactions does not render the add rule button
DocumentFilterField Render 0 DocumentFilterField component(s) DocumentFilterRule interactions renders 0 DocumentFilterRule components ‑ DocumentFilterField Render 0 DocumentFilterField component(s) DocumentFilterRule interactions renders 0 DocumentFilterRule components
DocumentFilterField Render 0 DocumentFilterField component(s) displays attribute label(s) ‑ DocumentFilterField Render 0 DocumentFilterField component(s) displays attribute label(s)
DocumentFilterField Render 0 DocumentFilterField component(s) displays operator label(s) ‑ DocumentFilterField Render 0 DocumentFilterField component(s) displays operator label(s)
DocumentFilterField Render 0 DocumentFilterField component(s) displays value label(s) ‑ DocumentFilterField Render 0 DocumentFilterField component(s) displays value label(s)
DocumentFilterField Render 1 DocumentFilterField component(s) DocumentFilterRule interactions clicking add rule button a rule has been added ‑ DocumentFilterField Render 1 DocumentFilterField component(s) DocumentFilterRule interactions clicking add rule button a rule has been added
DocumentFilterField Render 1 DocumentFilterField component(s) DocumentFilterRule interactions renders 1 DocumentFilterRule component ‑ DocumentFilterField Render 1 DocumentFilterField component(s) DocumentFilterRule interactions renders 1 DocumentFilterRule component
…

♻️ This comment has been updated with latest results.

@MonireRasouli MonireRasouli marked this pull request as ready for review November 12, 2024 16:39
@@ -139,7 +126,4 @@ describe('DocumentFilter', () => {
});
});
});

Copy link
Contributor

Choose a reason for hiding this comment

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

This todo hasn't been done yet, so shouldn't be removed

if (expectedFields > 0) {
test('renders the add rule button', async () => {
await Button('Add rule').exists();
it('renders DocumentFilterRule component with the correct number of times by clicking the "Add rule" button', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a little overcomplicated. The big if/else isn't needed here. We can instead test:

  • Does the right number of DocumentFilterRule exist? (Use queryAllByText so the 0 case works)
  • Does add rule exist
  • Describe clicking add rule
    • Has number of DocumentFilterRules gone up by one?

Copy link
Contributor

Choose a reason for hiding this comment

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

In general the point of the .each at the top is so that this kind of case by case logic isn't needed inside the tests themselves. Let me know if you wan tme to walk through this case with you cos it's an interesting shift in test writing

await Button('Add filter').exists();
await waitFor(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't do this in a test.

Describe is for actions, test is for outcomes

lib/DocumentFilter/DocumentFilterFieldArray.test.js Outdated Show resolved Hide resolved
lib/DocumentFilter/DocumentFilterFieldArray.test.js Outdated Show resolved Hide resolved
@@ -51,52 +54,65 @@ describe('DocumentFilterRule', () => {
await Button('Submit').exists();
});

it('renders Name option', () => {
test('renders the correct options for the Attribute dropdown', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I separated these deliberately... I want each test to be a single granular check. If this fails we don't know which field broke.

lib/DocumentFilter/DocumentFilterRule.test.js Outdated Show resolved Hide resolved
});

it('renders is option', () => {
test('renders the correct options for the Comparator dropdown', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing as above though... pleasee keep individual checks in their own test/it

lib/DocumentFilter/DocumentFilterRule.test.js Outdated Show resolved Hide resolved
lib/DocumentFilter/DocumentFilterRule.test.js Outdated Show resolved Hide resolved
@EthanFreestone EthanFreestone merged commit accf810 into master Nov 19, 2024
15 checks passed
@EthanFreestone EthanFreestone deleted the ERM-3395 branch November 19, 2024 16:20
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.

2 participants