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

feat: Allow tests files in /src (plus Label component tests) #10634

Merged
merged 11 commits into from
Aug 19, 2020

Conversation

rusackas
Copy link
Member

SUMMARY

This allows test files to live alongside the compnent and storybook files... trying to make things easier to find/audit/move/maintain

This also includes some unit tests for Label, which utilize the neighboring storybook stories, as a POC. I think these storybook entries will actually make it easier to write tests, and vice versa.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

a few comments, but nothing really blocking. this seems like a decent approach to follow going forward, but i'd further reiterate my concern that if we can't do a full migration to this new structure quickly, it'll cause a bunch of confusion for contributors trying to add unit tests

superset-frontend/webpack.config.js Outdated Show resolved Hide resolved
};

const bsStyleKnob = {
export const bsStyleKnob = {
Copy link
Member

Choose a reason for hiding this comment

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

maybe we should move this to a fixtures file that the stories and the test can both import from? It's a bit weird to import from a stories file in the test file, and it would also mean you don't need to tell storybook that this isn't a story too

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case (exporting the knobs), I agree it's a little weird, but I really like importing the actual stories in tests, so I figured this could come along for the ride. Mounting the story exports helps make sure your tests cover the use cases of the component properly, and means that storybook edits (i.e. when adding new features/variants to a component) might cause test failures, which I think is a good thing.

All that being said, I'll try to find a good way around the weird knob export/exclusion (probably in another PR). It is a little screwy.

@@ -230,6 +230,7 @@ const config = {
},
{
test: /\.tsx?$/,
exclude: [/\.test.tsx?$/],
Copy link
Member

Choose a reason for hiding this comment

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

Maybe make this exclude .test.jsx too since there's a decent chance we might move files around before converting them to TS?

Copy link
Member Author

Choose a reason for hiding this comment

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

Those are also excluded lower down, in the jsx (babel) loader.

@rusackas
Copy link
Member Author

a few comments, but nothing really blocking. this seems like a decent approach to follow going forward, but i'd further reiterate my concern that if we can't do a full migration to this new structure quickly, it'll cause a bunch of confusion for contributors trying to add unit tests

Agreed on the concern... I'm trying to find a good way to reduce the confusion I've already encountered. Right now, it does open up another path, but I'm going to sweep through a bunch of components to follow this pattern and move existing tests, so it becomes more prevalent/obvious.

@codecov-commenter
Copy link

codecov-commenter commented Aug 19, 2020

Codecov Report

Merging #10634 into master will decrease coverage by 4.35%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10634      +/-   ##
==========================================
- Coverage   64.30%   59.94%   -4.36%     
==========================================
  Files         778      778              
  Lines       36782    36802      +20     
  Branches     3482     3487       +5     
==========================================
- Hits        23651    22062    -1589     
- Misses      13022    14553    +1531     
- Partials      109      187      +78     
Flag Coverage Δ
#cypress ?
#javascript 60.70% <50.00%> (+0.04%) ⬆️
#python 59.49% <ø> (-0.26%) ⬇️

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

Impacted Files Coverage Δ
...et-frontend/src/components/Label/Label.stories.tsx 81.81% <50.00%> (ø)
superset-frontend/src/SqlLab/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/dashboard/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/index.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/dashboard/index.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/setup/setupColors.js 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/chart/ChartContainer.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/setup/setupFormatters.js 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/reducers/index.js 0.00% <0.00%> (-100.00%) ⬇️
... and 153 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec7874f...d4f6aa7. Read the comment docs.

@rusackas rusackas merged commit b0380be into apache:master Aug 19, 2020
@rusackas rusackas deleted the allow-tests-from-src branch August 19, 2020 19:54
amitmiran137 pushed a commit to amitmiran137/incubator-superset that referenced this pull request Aug 21, 2020
* master: (43 commits)
  feat: Getting fancier with Storybook (apache#10647)
  fix: dedup groupby in viz.py while preserving order (apache#10633)
  feat: bump superset-ui for certified tag (apache#10650)
  feat: setup react page with submenu for datasources listview  (apache#10642)
  feat: add certification to metrics (apache#10630)
  feat(viz-plugins): add date formatting to pivot-table (apache#10637)
  fix: controls scroll issue (apache#10644)
  feat: Allow tests files in  /src (plus Label component tests) (apache#10634)
  fix: remove duplicated params and cache_timeout from list_columns; add viz_type to list_columns (apache#10643)
  chore: splitting button stories into separate stories (apache#10631)
  refactor: remove slice level label_colors from dashboard init load (apache#10603)
  feat: card view bulk select (apache#10607)
  style: Label styling/storybook touchups (apache#10627)
  fix: removing unsupported modal sizes (apache#10625)
  feat(datasource): remove deleted columns and update column type on metadata refresh (apache#10619)
  improve documentation for country maps (apache#10621)
  chore: npm audit fix as of 2020-08-15 (apache#10613)
  feat: dataset REST API for distinct values (apache#10595)
  chore: bump react-redux to 5.1.2, whittling console noise (apache#10602)
  fixing console error about bad html attribute (apache#10604)
  ...

# Conflicts:
#	superset-frontend/src/explore/components/ExploreViewContainer.jsx
#	superset-frontend/src/views/App.tsx
#	superset/config.py
Ofeknielsen pushed a commit to ofekisr/incubator-superset that referenced this pull request Oct 5, 2020
…10634)

* allow tests in jest confg

* sample stories for Label component

* passing tests

* stories to tsx!

* excluding knobs exports from published stories

* ts fix

* ts fix

* Label test to TS

* explicitly ignoring test files in webpack bundling

* linting stuff

* adding comment about test file exclusions
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
…10634)

* allow tests in jest confg

* sample stories for Label component

* passing tests

* stories to tsx!

* excluding knobs exports from published stories

* ts fix

* ts fix

* Label test to TS

* explicitly ignoring test files in webpack bundling

* linting stuff

* adding comment about test file exclusions
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.38.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 0.38.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants