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(dropdown): added unit tests #435

Merged
merged 15 commits into from
Dec 1, 2023

Conversation

alfredskeden
Copy link
Contributor

Describe pull-request
Followed the test steps in ticket/excel to test.

Solving issue
Fixes: CDEP-2960

How to test

  1. Navigate to packages/core.
  2. Check the code for tests in dropdown component.
  3. Make sure docker is running.
  4. Then run npm run test in core to run the tests. Make sure they run.

Additional context
We are still in exploration for good testing.

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-435.d3fazya28914g3.amplifyapp.com

@alfredskeden alfredskeden marked this pull request as draft November 24, 2023 13:34
@alfredskeden alfredskeden marked this pull request as ready for review November 24, 2023 14:23
Copy link
Contributor

@nathalielindqvist nathalielindqvist left a comment

Choose a reason for hiding this comment

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

Nice work! LGTM :)

@alfredskeden alfredskeden marked this pull request as draft November 28, 2023 10:43
@alfredskeden alfredskeden marked this pull request as ready for review November 28, 2023 14:18
const dropdownListElementOneButton = page
.locator('tds-dropdown-option')
.filter({ hasText: /Option 1/ })
.locator('tds-checkbox');
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 here as what I mentioned with the tds-icon in the error text actually. Maybe we could just remove the .locator('tds-checkbox') and it would still work right?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah you're looking for the checked attribute 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, there is a ".toBeChecked()" might be better (assuming it works with our component)
https://playwright.dev/docs/input#checkboxes-and-radio-buttons

Copy link
Contributor

@alexandereneroth alexandereneroth Nov 29, 2023

Choose a reason for hiding this comment

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

I guess this might be impossible if we haven't properly made it accessible. But worth checking out (no pun intended)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can check on it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

3537a14
Found this solution, what do you think? there are 4 places that updates when something gets checked.

tds-dropdown-option get aria-selected
tds-checkbox gets the checked
input gets the aria-checked
and the dropdown value becomes updates with all checked values...

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, I think that works. I believe it always needs the aria-selected attribute since they can never be just native checkboxes.
Lets go with this if you agree 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool sounds cool with me.

Copy link
Contributor

@alexandereneroth alexandereneroth left a comment

Choose a reason for hiding this comment

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

LGTM 💯

@alfredskeden alfredskeden merged commit cca05b1 into develop Dec 1, 2023
1 check was pending
@alfredskeden alfredskeden deleted the test/CDEP-2960-dropdown-start-test branch December 1, 2023 13:52
Copy link

sonarcloud bot commented Dec 1, 2023

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

theJohnnyMe pushed a commit that referenced this pull request Dec 7, 2023
* chore(dropdown): wip unit tests for no-result-text

* test(dropdown): added tests

* test(dropdown): updated tests after meeting to follow standards

* test(dropdown): update so that label outside test work with also helpertext

* test(dropdown): add some screenshot testing and update some test names

* test(dropdown): update test to not use implementation details

* test(dropdown): test correctly

* test(dropdown): new tests for dropdown multiselect

* test(dropdown): update all tests to have less implementation details

* test(dropdown): update dropdown to use hidden and add basic dropdown

* test(dropdown): update tests to be less implementation detail oriented

---------

Co-authored-by: Default <alex.john.eneroth@gmail.om>
theJohnnyMe added a commit that referenced this pull request Dec 7, 2023
* test(button): added unit tests (#433)

* feat(button): add unit tests for basic and disabled button

* test: button tests to check for colors and other things to find a good pattern

* test: adding more tests for more test cases in button

* test: small update to button tests

* test: make sure disabled button has the correct cursor when disabled test

* fix: update pr with button without text and icon and check for width

* chore(all tests): update to componentTestPath instead of componentName

* test(button): update test text to be correct after pr comment

* test(button): update small text

---------

Co-authored-by: Lindqvist Nathalie <nathalie.lindqvist@scania.com>

* test(message): added unit tests (#437)

* test(message): added unit tests

* fix: review update

* test(button): refactor unit tests (#440)

* test(button): updates all tests for less implementation details

* test(button): update to better reflect how we should test

* test(button): remove id from index on tests since its not used

* test(dropdown): added unit tests (#435)

* chore(dropdown): wip unit tests for no-result-text

* test(dropdown): added tests

* test(dropdown): updated tests after meeting to follow standards

* test(dropdown): update so that label outside test work with also helpertext

* test(dropdown): add some screenshot testing and update some test names

* test(dropdown): update test to not use implementation details

* test(dropdown): test correctly

* test(dropdown): new tests for dropdown multiselect

* test(dropdown): update all tests to have less implementation details

* test(dropdown): update dropdown to use hidden and add basic dropdown

* test(dropdown): update tests to be less implementation detail oriented

---------

Co-authored-by: Default <alex.john.eneroth@gmail.om>

* fix(chip): double click for radio type (#441)

* fix(chip): set checked to true for radio

* fix: mutable for checked prop

* fix: throw error instead of warning

* build(deps-dev): bump @adobe/css-tools in /packages/angular

Bumps [@adobe/css-tools](https://github.com/adobe/css-tools) from 4.3.1 to 4.3.2.
- [Changelog](https://github.com/adobe/css-tools/blob/main/History.md)
- [Commits](https://github.com/adobe/css-tools/commits)

---
updated-dependencies:
- dependency-name: "@adobe/css-tools"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* test(textarea): added unit tests (#436)

* test(textarea): adding unit tests

* test(textarea): remove hydrated class check from tests

* test(textarea): update tests with some comments on all the expect

* test(textarea): update check on component to be truthy

* test(textarea): update after pr comments

* test(textarea): remove test for filling or clicking readonly textarea since it does not work

* test(textarea): updates after reading article

* test(textarea): added basic test and also update test to use getByRole

* test(textarea): added screenshot for when adding text to textarea

* test(textarea): add tests for label and update some screenshot names

* fix(popover-core): show prop read on an initial load (#439)

* fix(textarea): remove only on tests read-only textarea (#443)

* test(table): added unit tests (#438)

* test(table): added unit tests

* test(table): added a bunch more unit tests

* test(table): change toBeTruthy to toHaveCount instead

* test(table): update all tests to follow less implementation details

* test(table): update tests to reflect hidden

* chore: typo correction just to trigger SonarCloud

* test(table): rename basic to default

* test(table): update name of test in multiselect

---------

Co-authored-by: theJohnnyMe <nikola.johnny.mirkovic@scania.com>

* fix(css): headline-05 updated to correct value (#445)

* fix(css): headline-05 updated to correct value

* fix(headline-05): updated typography in tegel

* fix(message): updated storybook to now have two mode-variant (#446)

* feat(dropdown): added support for normalized text when searching (#444)

* feat(dropdown): added support for normalized text when searching

* test(dropdown): move some files around

* fix(dropdown: filter): line height increase

---------

Co-authored-by: theJohnnyMe <nikola.johnny.mirkovic@scania.com>

* docs(table): added tds-table-body to the filtering and pagination (#447)

* feat(css): update from rem to px on utility classes (#448)

* Release of @scania/tegel@1.3.2

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Alfred Skedebäck <alfred.skedeback@umain.com>
Co-authored-by: Lindqvist Nathalie <nathalie.lindqvist@scania.com>
Co-authored-by: theJohnnyMe <nikola.johnny.mirkovic@scania.com>
Co-authored-by: Default <alex.john.eneroth@gmail.om>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: theJohnnyMe <theJohnnyMe@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants