diff --git a/.github/workflows/browser-chrome.yml b/.github/workflows/browser-chrome.yml index 0b8c6180a00..6d3eec100de 100644 --- a/.github/workflows/browser-chrome.yml +++ b/.github/workflows/browser-chrome.yml @@ -9,7 +9,7 @@ on: branches: [ master ] jobs: - build: + chrome-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/browser-firefox.yml b/.github/workflows/browser-firefox.yml index e428d6bbc2c..a05d4131031 100644 --- a/.github/workflows/browser-firefox.yml +++ b/.github/workflows/browser-firefox.yml @@ -9,7 +9,7 @@ on: branches: [ master ] jobs: - build: + firefox-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -23,4 +23,3 @@ jobs: uses: GabrielBB/xvfb-action@v1 with: run: npm run testem:ci -- --port 8080 -f testem.json -l Firefox - diff --git a/.github/workflows/build.js.yml b/.github/workflows/build.js.yml index 82539bed99d..26309aa9b70 100644 --- a/.github/workflows/build.js.yml +++ b/.github/workflows/build.js.yml @@ -1,6 +1,6 @@ # This workflow will install Uglify and verify that fabric can be build with it -name: Building with uglify +name: Pr quality check on: push: @@ -10,13 +10,37 @@ on: jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Uglyfied build uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 12.x - run: npm install uglify-js@3.3.x - run: npm run build + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Linting + uses: actions/setup-node@v1 + with: + node-version: 12.x + - run: npm install eslint@4.7.x + - run: npm run lint + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Coverage report + uses: actions/setup-node@v1 + with: + node-version: 12.x + - run: npm ci + - run: npm run build:fast + - run: npm run test:coverage && npm run test:visual:coverage + - uses: ChristiaanScheermeijer/jest-reporter-action@v0.4.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + test-command: "npm run coverage:report" diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml deleted file mode 100644 index 4c78b696587..00000000000 --- a/.github/workflows/linting.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This workflow will install eslint and lint the code. -name: Linting - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Linting - uses: actions/setup-node@v1 - with: - node-version: 14.x - - run: npm install eslint@4.7.x - - run: npm run lint diff --git a/.github/workflows/node-unit-tests.yml b/.github/workflows/node-unit-tests.yml index dce6a431dc2..9b5dacb8ccd 100644 --- a/.github/workflows/node-unit-tests.yml +++ b/.github/workflows/node-unit-tests.yml @@ -10,12 +10,12 @@ on: branches: [ master ] jobs: - build: + node-unit-tests: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - node-version: [12.x, 14.x, 15.x] + node-version: [14.x, 15.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/visual-node.yml b/.github/workflows/visual-node.yml index 31b41b8484a..271f965f5db 100644 --- a/.github/workflows/visual-node.yml +++ b/.github/workflows/visual-node.yml @@ -10,12 +10,12 @@ on: branches: [ master ] jobs: - build: + node-visual-tests: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - node-version: [12.x, 14.x, 15.x] + node-version: [14.x, 15.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/visual-test-chrome.yml b/.github/workflows/visual-test-chrome.yml index 14bf6690115..aacd9cc6a03 100644 --- a/.github/workflows/visual-test-chrome.yml +++ b/.github/workflows/visual-test-chrome.yml @@ -9,7 +9,7 @@ on: branches: [ master ] jobs: - build: + chrome-visual-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/visual-test-firefox.yml b/.github/workflows/visual-test-firefox.yml index 54b3cd7e77c..23050837c9c 100644 --- a/.github/workflows/visual-test-firefox.yml +++ b/.github/workflows/visual-test-firefox.yml @@ -9,7 +9,7 @@ on: branches: [ master ] jobs: - build: + firefox-visual-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/package.json b/package.json index 1608f44c272..df0cad59946 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,10 @@ "build_with_gestures": "node build.js modules=ALL exclude=accessors", "build_export": "npm run build:fast && npm run export_dist_to_site", "test:single": "qunit test/node_test_setup.js test/lib", - "test": "nyc qunit test/node_test_setup.js test/lib test/unit", + "test:coverage": "nyc --silent qunit test/node_test_setup.js test/lib test/unit", + "test:visual:coverage": "nyc --silent --no-clean qunit test/node_test_setup.js test/lib test/visual", + "coverage:report": "nyc report --reporter=lcov --reporter=text", + "test": "qunit test/node_test_setup.js test/lib test/unit", "test:visual": "qunit test/node_test_setup.js test/lib test/visual", "test:visual:single": "qunit test/node_test_setup.js test/lib", "test:all": "npm run test && npm run test:visual", @@ -58,7 +61,6 @@ "export_tests_to_site": "cp test/unit/*.js ../fabricjs.com/test/unit && cp -r test/visual/* ../fabricjs.com/test/visual && cp -r test/fixtures/* ../fabricjs.com/test/fixtures && cp -r test/lib/* ../fabricjs.com/test/lib", "all": "npm run build && npm run test && npm run test:visual && npm run lint && npm run lint_tests && npm run export_dist_to_site && npm run export_tests_to_site", "testem": "testem .", - "testem:visual": "testem --file testem-visual.json", "testem:ci": "testem ci" }, "optionalDependencies": { diff --git a/src/canvas.class.js b/src/canvas.class.js index 1d346ee88e4..3826dec6544 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -497,13 +497,6 @@ target.render(ctx); ctx.restore(); - target === this._activeObject && target._renderControls(ctx, { - hasBorders: false, - transparentCorners: false - }, { - hasBorders: false, - }); - target.selectionBackgroundColor = originalColor; var isTransparent = fabric.util.isTransparent( @@ -765,18 +758,19 @@ activeObject = this._activeObject, aObjects = this.getActiveObjects(), activeTarget, activeTargetSubs, - isTouch = isTouchEvent(e); + isTouch = isTouchEvent(e), + shouldLookForActive = (aObjects.length > 1 && !skipGroup) || aObjects.length === 1; // first check current group (if one exists) // active group does not check sub targets like normal groups. // if active group just exits. this.targets = []; - if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) { + // if we hit the corner of an activeObject, let's return that. + if (shouldLookForActive && activeObject._findTargetCorner(pointer, isTouch)) { return activeObject; } - // if we hit the corner of an activeObject, let's return that. - if (aObjects.length === 1 && activeObject._findTargetCorner(pointer, isTouch)) { + if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) { return activeObject; } if (aObjects.length === 1 && @@ -812,7 +806,7 @@ obj.evented && // http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u32.html // http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html - (obj.containsPoint(pointer) || !!obj._findTargetCorner(pointer)) + obj.containsPoint(pointer) ) { if ((this.perPixelTargetFind || obj.perPixelTargetFind) && !obj.isEditing) { var isTransparent = this.isTargetTransparent(obj, globalPointer.x, globalPointer.y); diff --git a/test/unit/canvas.js b/test/unit/canvas.js index d1fba56d96e..1594d29ee53 100644 --- a/test/unit/canvas.js +++ b/test/unit/canvas.js @@ -2452,9 +2452,9 @@ assert.equal(canvas.isTargetTransparent(rect, 1, 1), false, 'opaque on 1,1'); assert.equal(canvas.isTargetTransparent(rect, 2, 2), false, 'opaque on 2,2'); assert.equal(canvas.isTargetTransparent(rect, 3, 3), false, 'opaque on 3,3'); - assert.equal(canvas.isTargetTransparent(rect, 4, 4), false, 'opaque on 4,4'); - assert.equal(canvas.isTargetTransparent(rect, 5, 5), false, 'opaque on 5, 5'); - assert.equal(canvas.isTargetTransparent(rect, 6, 6), false, 'opaque on 6, 6'); + assert.equal(canvas.isTargetTransparent(rect, 4, 4), true, 'transparent on 4,4'); + assert.equal(canvas.isTargetTransparent(rect, 5, 5), true, 'transparent on 5, 5'); + assert.equal(canvas.isTargetTransparent(rect, 6, 6), true, 'transparent on 6, 6'); assert.equal(canvas.isTargetTransparent(rect, 7, 7), true, 'transparent on 7, 7'); assert.equal(canvas.isTargetTransparent(rect, 8, 8), true, 'transparent on 8, 8'); assert.equal(canvas.isTargetTransparent(rect, 9, 9), true, 'transparent on 9, 9'); @@ -2465,20 +2465,20 @@ assert.equal(canvas.isTargetTransparent(rect, 14, 14), true, 'transparent 14, 14'); assert.equal(canvas.isTargetTransparent(rect, 15, 15), true, 'transparent 15, 15'); assert.equal(canvas.isTargetTransparent(rect, 16, 16), true, 'transparent 16, 16'); - assert.equal(canvas.isTargetTransparent(rect, 17, 17), false, 'opaque 17, 17'); - assert.equal(canvas.isTargetTransparent(rect, 18, 18), false, 'opaque 18, 18'); - assert.equal(canvas.isTargetTransparent(rect, 19, 19), false, 'opaque 19, 19'); + assert.equal(canvas.isTargetTransparent(rect, 17, 17), true, 'transparent 17, 17'); + assert.equal(canvas.isTargetTransparent(rect, 18, 18), true, 'transparent 18, 18'); + assert.equal(canvas.isTargetTransparent(rect, 19, 19), true, 'transparent 19, 19'); assert.equal(canvas.isTargetTransparent(rect, 20, 20), false, 'opaque 20, 20'); assert.equal(canvas.isTargetTransparent(rect, 21, 21), false, 'opaque 21, 21'); assert.equal(canvas.isTargetTransparent(rect, 22, 22), false, 'opaque 22, 22'); assert.equal(canvas.isTargetTransparent(rect, 23, 23), false, 'opaque 23, 23'); - assert.equal(canvas.isTargetTransparent(rect, 24, 24), false, 'opaque 24, 24'); - assert.equal(canvas.isTargetTransparent(rect, 25, 25), false, 'opaque 25, 25'); - assert.equal(canvas.isTargetTransparent(rect, 26, 26), false, 'opaque 26, 26'); - assert.equal(canvas.isTargetTransparent(rect, 27, 27), false, 'opaque 27, 27'); - assert.equal(canvas.isTargetTransparent(rect, 28, 28), false, 'opaque 28, 28'); - assert.equal(canvas.isTargetTransparent(rect, 29, 29), false, 'opaque 29, 29'); - assert.equal(canvas.isTargetTransparent(rect, 30, 30), false, 'opaque 30, 30'); + assert.equal(canvas.isTargetTransparent(rect, 24, 24), true, 'transparent 24, 24'); + assert.equal(canvas.isTargetTransparent(rect, 25, 25), true, 'transparent 25, 25'); + assert.equal(canvas.isTargetTransparent(rect, 26, 26), true, 'transparent 26, 26'); + assert.equal(canvas.isTargetTransparent(rect, 27, 27), true, 'transparent 27, 27'); + assert.equal(canvas.isTargetTransparent(rect, 28, 28), true, 'transparent 28, 28'); + assert.equal(canvas.isTargetTransparent(rect, 29, 29), true, 'transparent 29, 29'); + assert.equal(canvas.isTargetTransparent(rect, 30, 30), true, 'transparent 30, 30'); assert.equal(canvas.isTargetTransparent(rect, 31, 31), true, 'transparent 31, 31'); });