diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d975224b85..e0c0666aca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,9 @@ name: Test pipeline -on: pull_request +on: + pull_request: + paths: + - pmm-app/** jobs: build: @@ -29,6 +32,28 @@ jobs: path: pmm-app/dist/ if-no-files-found: error + unit_tests: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run with Node 18 + uses: actions/setup-node@v4 + with: + node-version: "18" + cache: "yarn" + cache-dependency-path: pmm-app/yarn.lock + + - name: Install deps + run: make prepare_release + + - name: Run lint + run: cd pmm-app && yarn lint:check + + - name: Run unit tests + run: cd pmm-app && yarn test:ci + code_coverage: needs: build runs-on: ubuntu-latest @@ -57,7 +82,7 @@ jobs: run: make generate_coverage workflow_success: - needs: [code_coverage, build] + needs: [unit_tests, code_coverage, build] name: Slack Notification success runs-on: ubuntu-latest env: @@ -77,7 +102,7 @@ jobs: workflow_failure: if: ${{ failure() }} - needs: [code_coverage, build] + needs: [unit_tests, code_coverage, build] name: Slack Notification failure runs-on: ubuntu-latest env: diff --git a/.github/workflows/setup-page.yml b/.github/workflows/setup-page.yml new file mode 100644 index 0000000000..aab76a27d5 --- /dev/null +++ b/.github/workflows/setup-page.yml @@ -0,0 +1,29 @@ +name: Setup Page pipeline + +on: + pull_request: + paths: + - setup-page/** + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run with Node 18 + uses: actions/setup-node@v4 + with: + node-version: "18" + cache: "npm" + cache-dependency-path: setup-page/package-lock.json + + - name: Install deps + run: cd setup-page && npm ci + + - name: Run lint + run: cd setup-page && npm run lint + + - name: Run build + run: cd setup-page && npm run build diff --git a/pmm-app/package.json b/pmm-app/package.json index 52e94b3370..bf74a3fd96 100644 --- a/pmm-app/package.json +++ b/pmm-app/package.json @@ -16,6 +16,7 @@ "dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development", "jest": "jest", "lint": "yarn lint:dev", + "lint:check": "eslint --ext .tsx,.ts src/", "lint:dev": "eslint --ext .tsx,.ts --fix src/", "lint:fix": "yarn run lint --fix", "server": "docker-compose up --build", diff --git a/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.test.tsx b/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.test.tsx index 2b3dac8a7b..decffd3fd3 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.test.tsx +++ b/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.test.tsx @@ -11,9 +11,10 @@ jest.mock('shared/components/helpers/notification-manager'); jest.mock('antd/es/tooltip', () =>
); jest.mock('./hooks/useHistogram', () => ({ - useHistogram: jest.fn(({ theme }) => ( - [getChartDataFromHistogramItems([{ frequency: 6175, range: '(0-3)' }], theme), true] - )), + useHistogram: jest.fn(({ theme }) => [ + getChartDataFromHistogramItems([{ frequency: 6175, range: '(0-3)' }], theme), + true, + ]), })); const originalConsoleError = console.error; @@ -2696,6 +2697,10 @@ const panelState = { describe('useFilters::', () => { beforeEach(() => { console.error = jest.fn(); + // TODO: Grafana Tooltip component uses a react 18 hook - useId + // due to enzyme we are currently stuck at react 17, mocking for now + // @ts-ignore + React.useId = () => ''; }); afterEach(() => { @@ -2717,7 +2722,6 @@ describe('useFilters::', () => { textMetrics={textMetrics} loading={false} /> - , , ); @@ -2731,14 +2735,7 @@ describe('useFilters::', () => { panelState, }} > - - , + , ); @@ -2760,7 +2757,6 @@ describe('useFilters::', () => { textMetrics={textMetrics} loading={false} /> - , , ); diff --git a/pmm-app/src/shared/components/Elements/Charts/TimeDistribution/__snapshots__/TimeDistribution.test.tsx.snap b/pmm-app/src/shared/components/Elements/Charts/TimeDistribution/__snapshots__/TimeDistribution.test.tsx.snap index def78a5ccd..ea18da4b5a 100644 --- a/pmm-app/src/shared/components/Elements/Charts/TimeDistribution/__snapshots__/TimeDistribution.test.tsx.snap +++ b/pmm-app/src/shared/components/Elements/Charts/TimeDistribution/__snapshots__/TimeDistribution.test.tsx.snap @@ -4,14 +4,14 @@ exports[`TimeDistributionChart chart test Renders correct 1`] = ` } - transitionName="zoom-big-fast" > - + } builtinPlacements={ - Object { - "bottom": Object { - "ignoreShake": true, - "offset": Array [ - 0, - 4, - ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + { + "bottom": { + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ + 0, + 12, + ], + "overflow": { + "adjustY": true, + "shiftX": 40, + "shiftY": true, }, - "points": Array [ + "points": [ "tc", "bc", ], - "targetOffset": Array [ - 0, - 0, - ], }, - "bottomLeft": Object { - "ignoreShake": true, - "offset": Array [ + "bottomLeft": { + "autoArrow": false, + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ 0, - 4, + 12, ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + "overflow": { + "adjustX": true, + "adjustY": true, }, - "points": Array [ + "points": [ "tl", "bl", ], - "targetOffset": Array [ - 0, - 0, - ], }, - "bottomRight": Object { - "ignoreShake": true, - "offset": Array [ + "bottomRight": { + "autoArrow": false, + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ 0, - 4, + 12, ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + "overflow": { + "adjustX": true, + "adjustY": true, }, - "points": Array [ + "points": [ "tr", "br", ], - "targetOffset": Array [ - 0, - 0, - ], }, - "left": Object { - "ignoreShake": true, - "offset": Array [ - -4, + "left": { + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ + -12, 0, ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + "overflow": { + "adjustX": true, + "shiftX": true, + "shiftY": 32, }, - "points": Array [ + "points": [ "cr", "cl", ], - "targetOffset": Array [ - 0, - 0, - ], }, - "leftBottom": Object { - "ignoreShake": true, - "offset": Array [ - -4, + "leftBottom": { + "autoArrow": false, + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ + -12, 0, ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + "overflow": { + "adjustX": true, + "adjustY": true, }, - "points": Array [ + "points": [ "br", "bl", ], - "targetOffset": Array [ - 0, - 0, - ], }, - "leftTop": Object { - "ignoreShake": true, - "offset": Array [ - -4, + "leftTop": { + "autoArrow": false, + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ + -12, 0, ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + "overflow": { + "adjustX": true, + "adjustY": true, }, - "points": Array [ + "points": [ "tr", "tl", ], - "targetOffset": Array [ - 0, - 0, - ], }, - "right": Object { - "ignoreShake": true, - "offset": Array [ - 4, + "right": { + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ + 12, 0, ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + "overflow": { + "adjustX": true, + "shiftX": true, + "shiftY": 32, }, - "points": Array [ + "points": [ "cl", "cr", ], - "targetOffset": Array [ - 0, - 0, - ], }, - "rightBottom": Object { - "ignoreShake": true, - "offset": Array [ - 4, + "rightBottom": { + "autoArrow": false, + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ + 12, 0, ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + "overflow": { + "adjustX": true, + "adjustY": true, }, - "points": Array [ + "points": [ "bl", "br", ], - "targetOffset": Array [ - 0, - 0, - ], }, - "rightTop": Object { - "ignoreShake": true, - "offset": Array [ - 4, + "rightTop": { + "autoArrow": false, + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ + 12, 0, ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + "overflow": { + "adjustX": true, + "adjustY": true, }, - "points": Array [ + "points": [ "tl", "tr", ], - "targetOffset": Array [ - 0, - 0, - ], }, - "top": Object { - "ignoreShake": true, - "offset": Array [ + "top": { + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ 0, - -4, + -12, ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + "overflow": { + "adjustY": true, + "shiftX": 40, + "shiftY": true, }, - "points": Array [ + "points": [ "bc", "tc", ], - "targetOffset": Array [ - 0, - 0, - ], }, - "topLeft": Object { - "ignoreShake": true, - "offset": Array [ + "topLeft": { + "autoArrow": false, + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ 0, - -4, + -12, ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + "overflow": { + "adjustX": true, + "adjustY": true, }, - "points": Array [ + "points": [ "bl", "tl", ], - "targetOffset": Array [ - 0, - 0, - ], }, - "topRight": Object { - "ignoreShake": true, - "offset": Array [ + "topRight": { + "autoArrow": false, + "dynamicInset": true, + "htmlRegion": "visibleFirst", + "offset": [ 0, - -4, + -12, ], - "overflow": Object { - "adjustX": 1, - "adjustY": 1, + "overflow": { + "adjustX": true, + "adjustY": true, }, - "points": Array [ + "points": [ "br", "tr", ], - "targetOffset": Array [ - 0, - 0, - ], }, } } destroyTooltipOnHide={false} + motion={ + { + "motionDeadline": 1000, + "motionName": "ant-zoom-big-fast", + } + } mouseEnterDelay={0.1} mouseLeaveDelay={0.1} - onPopupAlign={[Function]} onVisibleChange={[Function]} overlay={ - - test tooltip text - -
-
- - Some text - + + + test tooltip text +
-
-
+ + + } + overlayClassName="css-dev-only-do-not-override-42nv3w" + overlayInnerStyle={{}} + overlayStyle={{}} placement="topLeft" prefixCls="ant-tooltip" + showArrow={true} style={ - Object { + { "background": "deepskyblue", } } @@ -330,7 +313,7 @@ exports[`PluginTooltip Renders with right props 1`] = ` href="/test-url" rel="noopener noreferrer" style={ - Object { + { "color": "white", "textDecoration": "underline", } @@ -343,303 +326,242 @@ exports[`PluginTooltip Renders with right props 1`] = `
} - transitionName="zoom-big-fast" - trigger={ - Array [ - "hover", - ] - } visible={false} > - test tooltip text - -
-
- - Some text - -
-
- - } popup={[Function]} - popupAlign={Object {}} - popupClassName="" + popupAlign={{}} + popupClassName="css-dev-only-do-not-override-42nv3w" + popupMotion={ + { + "motionDeadline": 1000, + "motionName": "ant-zoom-big-fast", + } + } popupPlacement="topLeft" - popupStyle={Object {}} - popupTransitionName="zoom-big-fast" + popupStyle={{}} popupVisible={false} prefixCls="ant-tooltip" - showAction={Array []} style={ - Object { + { "background": "deepskyblue", } } @@ -653,7 +575,7 @@ exports[`PluginTooltip Renders with right props 1`] = ` href="/test-url" rel="noopener noreferrer" style={ - Object { + { "color": "white", "textDecoration": "underline", } @@ -668,61 +590,210 @@ exports[`PluginTooltip Renders with right props 1`] = ` } visible={false} > - + + + + + + + + + + + + + + + + + - - - - - - + + + + } + targetHeight={0} + targetWidth={0} + > + +
- + `; diff --git a/setup-page/.gitignore b/setup-page/.gitignore index b9e0dbb228..8357ce1b88 100644 --- a/setup-page/.gitignore +++ b/setup-page/.gitignore @@ -23,3 +23,4 @@ yarn-error.log* yarn.lock .parcel-cache dist +build