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

refactor(monorepo): change coverage of core to 100% #17698

Merged
merged 12 commits into from
Dec 14, 2021

Conversation

zhaoyongjie
Copy link
Member

@zhaoyongjie zhaoyongjie commented Dec 9, 2021

SUMMARY

make coverage of core package to 100%

link to shortcut: https://app.shortcut.com/preset/story/32255/yongjie-with-help-get-s-ui-packages-plugins-back-to-100-test-coverage

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

After

image

TESTING INSTRUCTIONS

CI

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

@codecov
Copy link

codecov bot commented Dec 9, 2021

Codecov Report

Merging #17698 (fda8acf) into master (04e3cfa) will decrease coverage by 0.38%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17698      +/-   ##
==========================================
- Coverage   68.13%   67.75%   -0.39%     
==========================================
  Files        1653     1602      -51     
  Lines       66247    64098    -2149     
  Branches     7107     6772     -335     
==========================================
- Hits        45138    43430    -1708     
+ Misses      19220    18815     -405     
+ Partials     1889     1853      -36     
Flag Coverage Δ
javascript 54.84% <100.00%> (-1.46%) ⬇️

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

Impacted Files Coverage Δ
...set-ui-core/src/color/CategoricalColorNamespace.ts 100.00% <100.00%> (+7.14%) ⬆️
...rset-ui-core/src/connection/SupersetClientClass.ts 100.00% <100.00%> (+9.23%) ⬆️
...tend/packages/superset-ui-core/src/utils/random.ts 100.00% <100.00%> (+16.66%) ⬆️
...ugins/legacy-preset-chart-big-number/src/preset.ts 0.00% <0.00%> (-80.00%) ⬇️
...d/plugins/preset-chart-xy/src/Line/legacy/index.ts 0.00% <0.00%> (-66.67%) ⬇️
...d/plugins/preset-chart-xy/src/ScatterPlot/index.ts 0.00% <0.00%> (-66.67%) ⬇️
...ns/preset-chart-xy/src/ScatterPlot/legacy/index.ts 0.00% <0.00%> (-66.67%) ⬇️
...hart-big-number/src/BigNumberTotal/controlPanel.ts 0.00% <0.00%> (-66.67%) ⬇️
...lugins/preset-chart-xy/src/BoxPlot/legacy/index.ts 0.00% <0.00%> (-62.50%) ⬇️
...gins/preset-chart-xy/src/BoxPlot/createMetadata.ts 0.00% <0.00%> (-50.00%) ⬇️
... and 454 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 04e3cfa...fda8acf. Read the comment docs.

@pull-request-size pull-request-size bot added size/S and removed size/XS labels Dec 9, 2021
const newScale = new CategoricalColorScale(
scheme?.colors ?? [],
this.forcedItems,
);

return newScale;
return new CategoricalColorScale(scheme?.colors ?? [], this.forcedItems);
Copy link
Member Author

Choose a reason for hiding this comment

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

reformat

@pull-request-size pull-request-size bot added size/M and removed size/S labels Dec 10, 2021
Comment on lines -19 to +26
import seedrandom from 'seedrandom';

let random = seedrandom('superset-ui');
import _seedrandom from 'seedrandom';

export function seed(seed: string) {
random = seedrandom(seed);
return random;
return _seedrandom(seed);
}

export function seedRandom() {
return random();
return _seedrandom('superset-ui')();
Copy link
Member Author

Choose a reason for hiding this comment

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

minor refactor, to avoid duplicate names(seedrandom).

Comment on lines +30 to -42
jest.spyOn(logging, 'debug').mockImplementation();
jest.spyOn(logging, 'log').mockImplementation();
jest.spyOn(logging, 'info').mockImplementation();
expect(() => {
logging.debug();
logging.log();
logging.info();
}).not.toThrow();
expect(() => {
logging.warn('warn');
}).toThrow('warn');
expect(() => {
logging.error('error');
}).toThrow('error');
Copy link
Member Author

Choose a reason for hiding this comment

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

mock console output, to make clear test output.

before

(superset) yongjie.zhao@:superset-frontend$ rm -rf coverage && npx jest --clearCache && NODE_ENV=test npx jest packages/superset-ui-core/test/utils/logging.test.ts
Cleared /private/var/folders/10/0l8mvpf52jx6t3p68mndwn7m0000gn/T/jest_dx
 PASS  packages/superset-ui-core/test/utils/logging.test.ts (9.898 s)
  logging
    ✓ should pipe to `console` methods (4487 ms)
    ✓ should use noop functions when console unavailable (72 ms)

  console.debug
    undefined

      at packages/superset-ui-core/test/utils/logging.test.ts:33:15

  console.log
    undefined

      at packages/superset-ui-core/test/utils/logging.test.ts:34:15

  console.info
    undefined

      at packages/superset-ui-core/test/utils/logging.test.ts:35:15

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        10.875 s
Ran all test suites matching /packages\/superset-ui-core\/test\/utils\/logging.test.ts/i.

After

(superset) yongjie.zhao@:superset-frontend$ rm -rf coverage && npx jest --clearCache && NODE_ENV=test npx jest packages/superset-ui-core/test/utils/logging.test.ts
Cleared /private/var/folders/10/0l8mvpf52jx6t3p68mndwn7m0000gn/T/jest_dx
 PASS  packages/superset-ui-core/test/utils/logging.test.ts (8.997 s)
  logging
    ✓ should pipe to `console` methods (4409 ms)
    ✓ should use noop functions when console unavailable (84 ms)

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        9.707 s
Ran all test suites matching /packages\/superset-ui-core\/test\/utils\/logging.test.ts/i.

@@ -33,13 +33,6 @@ import {
} from './types';
import { DEFAULT_FETCH_RETRY_OPTIONS, DEFAULT_BASE_URL } from './constants';

function redirectUnauthorized() {
Copy link
Member Author

Choose a reason for hiding this comment

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

The function move into class

@zhaoyongjie zhaoyongjie reopened this Dec 14, 2021
@stephenLYZ
Copy link
Member

LGTM

Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

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

LGTM!

@zhaoyongjie zhaoyongjie merged commit 07bbe84 into apache:master Dec 14, 2021
@@ -16,7 +16,7 @@ coverage:
target: auto
threshold: 0%
core-packages-ts:
target: 95%
target: 100%
Copy link
Member

Choose a reason for hiding this comment

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

❤️

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.0 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 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants