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

test: use unified github action yml #868

Merged
merged 9 commits into from
Aug 28, 2024

Conversation

Layouwen
Copy link
Contributor

@Layouwen Layouwen commented Aug 27, 2024

ant-design/ant-design#50461

Summary by CodeRabbit

  • 新功能

    • 引入了 bunfig.toml 配置文件,允许用户自定义依赖安装选项。
  • 改进

    • 更新了 GitHub Actions 工作流,简化了 CI/CD 流程,提升了可维护性。
    • .gitignore 文件中添加了临时文件和锁文件的忽略规则,改善了项目整洁性。
    • 更新了 cellRender 函数的类型注解,增强了函数的灵活性。
    • 更新了 rtl 组件的类型引用和函数签名,提高了类型安全性和清晰度。
    • 修改了 customize 组件中的面板变更回调函数类型,增强了类型安全性,并调整了当前日期显示方式。
  • 测试

    • 对键盘交互测试进行了重大修改,移除了不再使用的模拟函数,调整了测试策略。
    • 注释掉了与 moment 选择器相关的类型导入和声明,反映出代码结构的变化。

Copy link

vercel bot commented Aug 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
picker ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2024 1:10am

Copy link

coderabbitai bot commented Aug 27, 2024

Walkthrough

此次更改涉及多个文件的结构和配置调整,包括简化GitHub Actions工作流、更新.gitignore文件以排除临时文件、引入bunfig.toml配置文件,以及在TypeScript示例文件中添加禁用类型检查的指令。此外,测试文件进行了重构,移除了某些键盘交互功能,并临时注释掉了相关类型声明。同时,cellRenderrtl函数的参数类型也进行了更新,以支持更灵活的输入和更严格的类型安全。

Changes

文件路径 更改摘要
.github/workflows/main.yml 将工作流重构为单一作业test,使用外部工作流替代原有多个作业。
.gitignore 新增.dumi/tmp-productionbun.lockb以忽略临时文件和Bun锁文件。
bunfig.toml 新增bunfig.toml配置文件,包含[install]节和peer = false键值对。
docs/examples/*.tsx 在多个TypeScript示例文件中添加// @ts-nocheck指令以禁用类型检查。
tests/keyboard.spec.tsx 移除键盘交互函数keyDownpanelKeyDown,并注释掉相关测试用例。
tests/util/commonUtil.tsx 多个与moment相关的类型导入和声明被注释掉,表明这些功能正在重新考虑或不再需要。
docs/examples/cellRender.tsx 更新cellRender函数的参数类型,以支持`number
docs/examples/rtl.tsx 更新rtl文件中的多处类型引用和函数签名,以增强类型安全和清晰度。
docs/examples/customize.tsx 引入OnPanelChange类型以增强changePanelCallBack函数的类型安全,并调整PickerPanel组件的属性。

Sequence Diagram(s)

sequenceDiagram
    participant CI as CI/CD Pipeline
    participant Workflow as External Workflow
    CI->>Workflow: Trigger test job
    Workflow-->>CI: Execute tests
    CI->>CI: Report results
Loading

在代码的世界里,兔子欢跳,
简化流程,真是妙不可言,
临时文件不再烦恼,
依赖管理变得更轻松,
让我们一起庆祝这些变化,
代码如兔子般灵动,飞跃每一行! 🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between edb2ab7 and 9644432.

Files selected for processing (8)
  • .github/workflows/main.yml (1 hunks)
  • .gitignore (1 hunks)
  • bunfig.toml (1 hunks)
  • docs/examples/cellRender.tsx (1 hunks)
  • docs/examples/customize.tsx (1 hunks)
  • docs/examples/rtl.tsx (1 hunks)
  • tests/keyboard.spec.tsx (2 hunks)
  • tests/util/commonUtil.tsx (2 hunks)
Files skipped from review due to trivial changes (5)
  • .github/workflows/main.yml
  • .gitignore
  • bunfig.toml
  • docs/examples/cellRender.tsx
  • docs/examples/customize.tsx

@@ -1,3 +1,4 @@
// @ts-nocheck
Copy link

Choose a reason for hiding this comment

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

谨慎使用 // @ts-nocheck

添加 // @ts-nocheck 会禁用整个文件的类型检查,这可能会隐藏潜在的类型错误。建议在解决类型问题后移除该指令。

Comment on lines 29 to 39
// import type { PickerBaseProps, PickerDateProps, PickerTimeProps } from '../../src/Picker';
// import type {
// PickerPanelBaseProps,
// PickerPanelDateProps,
// PickerPanelTimeProps,
// } from '../../src/PickerPanel';
// import {
// type RangePickerBaseProps,
// type RangePickerDateProps,
// type RangePickerTimeProps,
// } from '../../src/RangePicker';
Copy link

Choose a reason for hiding this comment

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

谨慎注释类型导入

注释掉类型导入可能是为了重构或测试,但这会导致类型安全性丧失和潜在的运行时错误。建议在完成重构或测试后重新启用这些类型。

Comment on lines 82 to 105
// interface MomentDefaultProps {
// locale?: PickerProps<Moment>['locale'];
// generateConfig?: PickerProps<Moment>['generateConfig'];
// }

type InjectDefaultProps<Props> = Omit<Props, 'locale' | 'generateConfig'> & MomentDefaultProps;
// type InjectDefaultProps<Props> = Omit<Props, 'locale' | 'generateConfig'> & MomentDefaultProps;

// Moment Picker
export type MomentPickerProps =
| InjectDefaultProps<PickerBaseProps<Moment>>
| InjectDefaultProps<PickerDateProps<Moment>>
| InjectDefaultProps<PickerTimeProps<Moment>>;

// Moment Panel Picker
export type MomentPickerPanelProps =
| InjectDefaultProps<PickerPanelBaseProps<Moment>>
| InjectDefaultProps<PickerPanelDateProps<Moment>>
| InjectDefaultProps<PickerPanelTimeProps<Moment>>;

// Moment Range Picker
export type MomentRangePickerProps =
| InjectDefaultProps<RangePickerBaseProps<Moment>>
| InjectDefaultProps<RangePickerDateProps<Moment>>
| InjectDefaultProps<RangePickerTimeProps<Moment>>;
// export type MomentPickerProps =
// | InjectDefaultProps<PickerBaseProps<Moment>>
// | InjectDefaultProps<PickerDateProps<Moment>>
// | InjectDefaultProps<PickerTimeProps<Moment>>;

// // Moment Panel Picker
// export type MomentPickerPanelProps =
// | InjectDefaultProps<PickerPanelBaseProps<Moment>>
// | InjectDefaultProps<PickerPanelDateProps<Moment>>
// | InjectDefaultProps<PickerPanelTimeProps<Moment>>;

// // Moment Range Picker
// export type MomentRangePickerProps =
// | InjectDefaultProps<RangePickerBaseProps<Moment>>
// | InjectDefaultProps<RangePickerDateProps<Moment>>
// | InjectDefaultProps<RangePickerTimeProps<Moment>>;
Copy link

Choose a reason for hiding this comment

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

谨慎注释类型接口和导出

注释掉类型接口和导出可能是为了重构或测试,但这会导致类型安全性丧失和潜在的运行时错误。建议在完成重构或测试后重新启用这些类型。

Comment on lines 8 to 30
// function keyDown(keyCode: number, info?: object, index = 0) {
// const input = document.querySelectorAll('input')[index];
// const event = createEvent.keyDown(input, {
// keyCode,
// which: keyCode,
// charCode: keyCode,
// ...info,
// });

// fireEvent(input, event);

// return event;
// }

// function panelKeyDown(keyCode: number, info?: object) {
// fireEvent.keyDown(document.querySelector('.rc-picker-panel') as HTMLElement, {
// keyCode,
// which: keyCode,
// charCode: keyCode,
// ...info,
// });
// document.querySelector('.rc-picker-panel').simulate('keyDown', { which: keyCode, ...info });
// }
Copy link

Choose a reason for hiding this comment

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

谨慎注释键盘交互函数

注释掉键盘交互函数可能是为了重构或测试,但这会导致测试覆盖率丧失和潜在的问题未被检测到。建议在完成重构或测试后重新启用这些函数。

Comment on lines 139 to 639
// keyDown(KeyCode.ESC);
// expect(container.querySelector('input').value).toEqual('');
// });

// it('move based on current date on first keyboard event', () => {
// const onCalendarChange = jest.fn();
// const onChange = jest.fn();
// const { container } = render(
// <DayRangePicker onCalendarChange={onCalendarChange} onChange={onChange} />,
// );

// // Start Date
// openPicker(container);
// // wrapper
// // .find('input')
// // .first()
// // .simulate('change', { target: { value: '' } });
// fireEvent.change(container.querySelector('input'), { target: { value: '' } });
// keyDown(KeyCode.TAB);
// keyDown(KeyCode.RIGHT);
// keyDown(KeyCode.ENTER);
// expect(onCalendarChange.mock.calls[0][1]).toEqual(['1990-09-04', '']);
// expect(onChange).not.toHaveBeenCalled();
// });
// });

// it('enter should prevent default to avoid form submit', () => {
// render(<DayPicker />);
// const event = keyDown(KeyCode.ENTER);

// expect(event.defaultPrevented).toBeTruthy();
// });

// describe('keyboard should not trigger on disabledDate', () => {
// it('picker', () => {
// const onChange = jest.fn();
// const onSelect = jest.fn();
// const { container } = render(
// <DayPicker
// showTime
// onSelect={onSelect}
// onChange={onChange}
// disabledDate={(date) => date.date() % 2 === 0}
// />,
// );
// // document.querySelector('input').simulate('focus');
// fireEvent.focus(container.querySelector('input'));
// keyDown(KeyCode.ENTER);
// keyDown(KeyCode.TAB);
// keyDown(KeyCode.TAB);
// keyDown(KeyCode.DOWN);
// expect(isSame(onSelect.mock.calls[0][0], '1990-09-10')).toBeTruthy();

// // Not enter to change
// keyDown(KeyCode.ENTER);
// expect(onChange).not.toHaveBeenCalled();

// // Not button enabled
// expect(
// document.querySelector<HTMLButtonElement>('.rc-picker-ok button').disabled,
// ).toBeTruthy();

// // Another can be enter
// keyDown(KeyCode.RIGHT);
// expect(
// document.querySelector<HTMLButtonElement>('.rc-picker-ok button').disabled,
// ).toBeFalsy();
// keyDown(KeyCode.ENTER);
// expect(onChange).toHaveBeenCalled();
// });

// it('panel', () => {
// const onChange = jest.fn();
// const onSelect = jest.fn();
// render(
// <DayPickerPanel
// onSelect={onSelect}
// onChange={onChange}
// disabledDate={(date) => date.date() % 2 === 0}
// />,
// );

// fireEvent.focus(document.querySelector('.rc-picker-panel'));
// // 9-02、9-04、9-10 is disabled
// panelKeyDown(KeyCode.LEFT);
// panelKeyDown(KeyCode.RIGHT);
// panelKeyDown(KeyCode.DOWN);
// expect(onSelect).not.toHaveBeenCalled();

// // 7-27、8-27 is enabled
// panelKeyDown(KeyCode.UP);
// expect(isSame(onSelect.mock.calls[0][0], '1990-08-27')).toBeTruthy();
// onSelect.mockReset();
// panelKeyDown(KeyCode.PAGE_UP);
// expect(isSame(onSelect.mock.calls[0][0], '1990-07-27')).toBeTruthy();
// onSelect.mockReset();
// panelKeyDown(KeyCode.PAGE_DOWN);
// expect(isSame(onSelect.mock.calls[0][0], '1990-08-27')).toBeTruthy();
// });

Copy link

Choose a reason for hiding this comment

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

谨慎注释测试用例

注释掉测试用例可能是为了重构或测试,但这会导致测试覆盖率丧失和潜在的问题未被检测到。建议在完成重构或测试后重新启用这些测试用例。

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.42%. Comparing base (edb2ab7) to head (deec470).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #868   +/-   ##
=======================================
  Coverage   95.42%   95.42%           
=======================================
  Files          64       64           
  Lines        2711     2711           
  Branches      758      731   -27     
=======================================
  Hits         2587     2587           
  Misses        121      121           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9644432 and 0fe90a8.

Files selected for processing (1)
  • docs/examples/cellRender.tsx (2 hunks)
Additional comments not posted (2)
docs/examples/cellRender.tsx (2)

153-156: 更改参数类型以提高灵活性

current 参数的类型从 Moment 更改为 number | string 提高了函数的灵活性。渲染逻辑也正确处理了新的类型。

代码更改已批准。


176-182: 更改参数类型以提高灵活性

current 参数的类型从 Moment 更改为更通用的类型提高了函数的灵活性。渲染逻辑也正确处理了新的类型。

代码更改已批准。

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0fe90a8 and 8e7b4cd.

Files selected for processing (1)
  • docs/examples/rtl.tsx (3 hunks)
Additional comments not posted (4)
docs/examples/rtl.tsx (4)

4-4: 导入类型检查通过

新导入的类型 PickerRefRangePickerRefNoUndefinedRangeValueType 是为了更新文件中的类型引用,符合预期。

这些导入更改是合理的。

Also applies to: 10-11


22-22: 类型更新通过

weekRef 现在的类型是 PickerRef 而不是 Picker<Moment>,这使得引用类型与其预期用途保持一致。

类型更新是合理的。


28-31: 函数签名更新通过

onChange 函数签名更新为接受类型为 NoUndefinedRangeValueType<Moment>newValue 和类型为 string | [string, string]formatString,这引入了更具体的类型约束,改进了范围值的处理,并允许更大的格式选项灵活性。

函数签名更新是合理的。


45-45: 类型更新通过

rangePickerRef 现在的类型是 RangePickerRef 而不是 RangePicker<Moment>,这确保了组件中类型使用的一致性。

类型更新是合理的。

// export type MomentRangePickerProps =
// | InjectDefaultProps<RangePickerBaseProps<Moment>>
// | InjectDefaultProps<RangePickerDateProps<Moment>>
// | InjectDefaultProps<RangePickerTimeProps<Moment>>;
Copy link
Member

Choose a reason for hiding this comment

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

这是干啥。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Picker 似乎改版过, 这些是旧的类型定义. 没有用到, 并且部分类型已经不存在了.
测试用例部分是直接 return 了的, 我看很多逻辑是没完全调整完.
直接删掉不知道会不会影响后续重构, 就先注释没删掉.

Copy link
Member

Choose a reason for hiding this comment

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

没有用就直接删掉吧。

Copy link
Member

Choose a reason for hiding this comment

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

直接删了吧

@Layouwen
Copy link
Contributor Author

no-check 部分已做处理 @zombieJ

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8e7b4cd and eba0a36.

Files selected for processing (1)
  • docs/examples/customize.tsx (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • docs/examples/customize.tsx

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
tests/keyboard.spec.tsx (1)

Line range hint 1-111: 谨慎注释键盘交互函数和测试用例

注释掉键盘交互函数和测试用例可能是为了重构或测试,但这会导致测试覆盖率丧失和潜在的问题未被检测到。建议在完成重构或测试后重新启用这些函数和测试用例。

请确保在重构完成后重新启用或替换这些注释掉的测试用例。

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eba0a36 and deec470.

Files selected for processing (3)
  • docs/examples/customize.tsx (3 hunks)
  • tests/keyboard.spec.tsx (2 hunks)
  • tests/util/commonUtil.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/util/commonUtil.tsx
Additional comments not posted (3)
tests/keyboard.spec.tsx (2)

4-4: 导入语句正确

导入语句是正确的,并且是测试所必需的。

代码更改已批准。


107-111: 测试用例正确

测试用例正确地实现了对部分日期输入的检查。

代码更改已批准。

docs/examples/customize.tsx (1)

104-104: 代码简化和重构

删除了 initValue 状态变量,并简化了 JSX 结构,表明这是一次旨在减少复杂性和提高可维护性的重构。

代码更改已批准。

@afc163 afc163 merged commit 471c86b into react-component:master Aug 28, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants