Skip to content

Commit

Permalink
fix: upload addOnPasting can't work in Sidesheet, close #2478 (#2480)
Browse files Browse the repository at this point in the history
* fix: remove e.target body limit when handlePasting of Upload, close #2478
* chore: cypress video false
* test: fix table、datepicker、slider e2e test
---------

Co-authored-by: DaiQiangReal <[email protected]>
  • Loading branch information
pointhalo and DaiQiangReal authored Sep 9, 2024
1 parent bdcc7fc commit f399585
Show file tree
Hide file tree
Showing 6 changed files with 996 additions and 957 deletions.
2 changes: 1 addition & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "cypress";
export default defineConfig({
projectId: "k83u7j",
scrollBehavior: false,

video: false,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/datePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ describe('DatePicker', () => {
cy.get('[data-cy=dateTimeRange] .semi-input').first().click();
cy.get('[data-cy=dateTimeRange] .semi-input').eq(0).clear().type('2021-0');
cy.get('.semi-datepicker-footer .semi-button').eq(0).click();
cy.wait(300);
cy.get('[data-cy=dateTimeRange] .semi-input').first().click();
cy.get('.semi-popover .semi-datepicker-day-selected-start').contains('8');
cy.get('.semi-popover .semi-datepicker-day-selected-end').contains('9');
Expand Down
22 changes: 11 additions & 11 deletions cypress/e2e/slider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('slider', () => {
const parentSelector = '[data-cy=horizontalNoChangeSlider]';
const sliderTrackSelector = `${parentSelector} .semi-slider-rail`;
const sliderHandleSelector = `${parentSelector} .semi-slider-handle`;

// test track click
let handleInitialPos;
cy.get(sliderHandleSelector).then(($handle) => {
Expand All @@ -18,7 +18,7 @@ describe('slider', () => {

cy.get(sliderTrackSelector).trigger('click', 'right');
cy.get('@consoleLog').should('be.calledWith', 'value改变了100');

cy.get(sliderHandleSelector).should(($button) => {
expect($button.position()).deep.equal(handleInitialPos);
});
Expand All @@ -28,7 +28,7 @@ describe('slider', () => {
.trigger('mousedown')
.trigger('mousemove', { pageX: 600, pageY: 0 })
.trigger('mouseup', { force: true });

cy.get(sliderHandleSelector).should(($button) => {
expect($button.position()).deep.equal(handleInitialPos);
});
Expand All @@ -53,14 +53,14 @@ describe('slider', () => {
// test knob slide (pageX 300 = 32%)
cy.get(sliderHandleSelector)
.realMouseDown()
.realMouseMove(-530, 0, { position: "center" })
.realMouseMove(-(774 - 774 * 0.32), 0, { position: "center" })
.realMouseUp({ force: true });

// left 32% = 247.68px;
// cy.get(sliderHandleSelector).should('have.css', 'left', '247.68px');
// cy.get(sliderHandleSelector).should('have.css', 'left', '32%');
cy.window().then(window => {
const style = window.getComputedStyle(window.document.querySelector(sliderHandleSelector));
expect(Math.ceil(parseFloat(style.left))).eq(248);
const left = (window.document.querySelector(sliderHandleSelector))['style']['left'];
expect(left).eq("32%");
});
});

Expand Down Expand Up @@ -140,7 +140,7 @@ describe('slider', () => {
.trigger('mousedown')
.trigger('mousemove', { pageX: 0, pageY: 600 })
.trigger('mouseup', { force: true });

cy.get(sliderHandleSelector).should(($button) => {
expect($button.position()).deep.equal(handleInitialPos);
});
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('slider', () => {
cy.get('.semi-slider-handle').eq(2).should('have.attr', 'aria-valuenow', '50');
cy.get('.semi-slider-handle').eq(2).type('{Home}');
cy.get('.semi-slider-handle').eq(2).should('have.attr', 'aria-valuenow', '0');
});
});

it('should show tooltip when hovering slider handler', () => {
cy.visit('http://127.0.0.1:6006/iframe.html?id=slider--controlled-slider-demo&args=&viewMode=story', {
Expand All @@ -231,4 +231,4 @@ describe('slider', () => {
cy.get('.semi-slider-handle').eq(0).trigger('mouseover');
cy.get('.semi-slider-handle-tooltip').eq(0).should('have.text', '0');
});
});
});
4 changes: 3 additions & 1 deletion cypress/e2e/table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,12 @@ describe('table', () => {
cy.get('.semi-input').type('12');
cy.get('.semi-button').contains('筛选+关闭').click();
cy.get('.semi-table-tbody .semi-table-row').should('have.length', 1);
cy.get('.semi-table-column-filter').eq(0).click();
cy.wait(200);
cy.get('.semi-table-column-filter').eq(0).click();
cy.get('.semi-input').should('be.focused');
cy.get('.semi-button').contains('清除+关闭').click();
cy.get('.semi-table-tbody .semi-table-row').should('have.length', 10);
cy.wait(200);
cy.get('.semi-table-column-filter').eq(0).click();
cy.get('.semi-input').should('be.focused');
cy.get('.semi-button').contains('直接关闭').click();
Expand All @@ -280,6 +281,7 @@ describe('table', () => {
cy.get('.semi-button').contains('清除后不关闭').click();
cy.get('.semi-table-pagination-info').should('contain', '显示第 1 条-第 10 条,共 46 条');
cy.get('.semi-dropdown').should('exist');
cy.wait(200);
cy.get('.semi-table-column-filter').eq(1).click();
cy.get('.semi-input').type('郝宣');
cy.get('.semi-button').contains('筛选后不关闭').click();
Expand Down
3 changes: 1 addition & 2 deletions packages/semi-foundation/upload/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,8 @@ class UploadFoundation<P = Record<string, any>, S = Record<string, any>> extends
const isMac = this._adapter.isMac();
const isCombineKeydown = isMac ? e.metaKey : e.ctrlKey;
const { addOnPasting } = this.getProps();

if (addOnPasting) {
if (isCombineKeydown && e.code === 'KeyV' && e.target === document.body) {
if (isCombineKeydown && e.code === 'KeyV') {
// https://github.com/microsoft/TypeScript/issues/33923
const permissionName = 'clipboard-read' as PermissionName;
// The main thread should not be blocked by clipboard, so callback writing is required here. No await here
Expand Down
Loading

0 comments on commit f399585

Please sign in to comment.