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

chore(sqllab): refactor addQueryEditor for new tab #21711

Conversation

justinpark
Copy link
Member

SUMMARY

In order to get newQueryTabName, the root component must retrieve the queryEditors list.
This value is unnecessary during the rendering time but it only needs when the action is invoked.
This commit refactors this part that uses queryEditors in the action to remove this unnecessary prop in the rendering component.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

go to sqllab
create new tab and check the untitled name incremental by tab numbers

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

cc: @ktmud @EugeneTorap

@justinpark justinpark force-pushed the chore--refactor-new-query-tab-name branch from 24741cd to 14cde76 Compare October 6, 2022 00:20
@justinpark justinpark force-pushed the chore--refactor-new-query-tab-name branch from 14cde76 to 25706ae Compare October 6, 2022 00:39
@codecov
Copy link

codecov bot commented Oct 6, 2022

Codecov Report

Merging #21711 (25706ae) into master (51c54b3) will increase coverage by 0.00%.
The diff coverage is 83.33%.

@@           Coverage Diff           @@
##           master   #21711   +/-   ##
=======================================
  Coverage   66.78%   66.78%           
=======================================
  Files        1799     1799           
  Lines       68881    68882    +1     
  Branches     7319     7317    -2     
=======================================
+ Hits        46002    46005    +3     
+ Misses      20992    20991    -1     
+ Partials     1887     1886    -1     
Flag Coverage Δ
javascript 53.15% <83.33%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...frontend/src/SqlLab/components/SqlEditor/index.jsx 55.73% <0.00%> (+0.06%) ⬆️
superset-frontend/src/SqlLab/actions/sqlLab.js 63.37% <100.00%> (+0.38%) ⬆️
...d/src/SqlLab/components/TabbedSqlEditors/index.jsx 54.70% <100.00%> (+0.46%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@EugeneTorap
Copy link
Contributor

LGTM!
@michael-s-molina @kgabryje @ktmud Can we merge it?

expect(
wrapper.instance().props.actions.addQueryEditor.getCall(0).args[0].name,
).toContain(newTitle);
it('should properly increment query tab name', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

RTL best practices recommend testing what the user interacts with instead of implementation details. Here's a quote from their site:

You want to write maintainable tests that give you high confidence that your components are working for your users. As a part of this goal, you want your tests to avoid including implementation details so refactors of your components (changes to implementation but not functionality) don’t break your tests and slow you and your team down.

In this case, it would be better if we test what appears on the screen like checking if there's a new tab with the right title. Even if we change the action name or other logic in the future, the expected result would be the same. This is not a blocker for me though, it's just a suggestion.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion. However, it's a little complicated to setup entire SqlLab redux state to simulate the behavior in the screen. It'd be better to minimize the redux usage in the future for better screen testing environment.

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the improvement. I left a non-blocking comment.

Copy link
Member

@ktmud ktmud left a comment

Choose a reason for hiding this comment

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

LGTM

@michael-s-molina michael-s-molina merged commit 0c46149 into apache:master Oct 7, 2022
sadpandajoe added a commit to preset-io/superset that referenced this pull request Oct 17, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 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/L 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants