Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/TourStep/DefaultPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,28 @@ export default function DefaultPanel(props: DefaultPanelProps) {
style={styles?.actions}
>
{current !== 0 ? (
<button className={`${prefixCls}-prev-btn`} onClick={onPrev}>
<button
type="button"
className={`${prefixCls}-prev-btn`}
onClick={onPrev}
>
Prev
</button>
) : null}
{current === total - 1 ? (
<button className={`${prefixCls}-finish-btn`} onClick={onFinish}>
<button
type="button"
className={`${prefixCls}-finish-btn`}
onClick={onFinish}
>
Finish
</button>
) : (
<button className={`${prefixCls}-next-btn`} onClick={onNext}>
<button
type="button"
className={`${prefixCls}-next-btn`}
onClick={onNext}
>
Next
</button>
)}
Expand Down
16 changes: 16 additions & 0 deletions tests/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ exports[`Tour animated placeholder true 1`] = `
>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down Expand Up @@ -294,6 +295,7 @@ exports[`Tour animated true 1`] = `
>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down Expand Up @@ -586,6 +588,7 @@ exports[`Tour rootClassName 1`] = `
>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down Expand Up @@ -709,6 +712,7 @@ exports[`Tour run in strict mode 1`] = `
>
<button
class="rc-tour-next-btn"
type="button"
>
Next
</button>
Expand Down Expand Up @@ -877,11 +881,13 @@ exports[`Tour run in strict mode 2`] = `
>
<button
class="rc-tour-prev-btn"
type="button"
>
Prev
</button>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down Expand Up @@ -995,11 +1001,13 @@ exports[`Tour should keep current when controlled 1`] = `
>
<button
class="rc-tour-prev-btn"
type="button"
>
Prev
</button>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down Expand Up @@ -1113,6 +1121,7 @@ exports[`Tour should return step 1 when reopen 1`] = `
>
<button
class="rc-tour-next-btn"
type="button"
>
Next
</button>
Expand Down Expand Up @@ -1268,6 +1277,7 @@ exports[`Tour should update position when window resize 1`] = `
>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down Expand Up @@ -1423,6 +1433,7 @@ exports[`Tour should update position when window scroll 1`] = `
>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down Expand Up @@ -1572,6 +1583,7 @@ exports[`Tour showArrow should show tooltip arrow default 1`] = `
>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down Expand Up @@ -1725,6 +1737,7 @@ exports[`Tour single 1`] = `
>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down Expand Up @@ -1880,6 +1893,7 @@ exports[`Tour use custom builtinPlacements 1`] = `
>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down Expand Up @@ -2035,6 +2049,7 @@ exports[`Tour use custom builtinPlacements 2`] = `
>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down Expand Up @@ -2201,6 +2216,7 @@ exports[`Tour use custom builtinPlacements 3`] = `
>
<button
class="rc-tour-finish-btn"
type="button"
>
Finish
</button>
Expand Down
10 changes: 8 additions & 2 deletions tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,20 @@ describe('Tour', () => {
};
const { getByText, baseElement } = render(<Demo />);
expect(getByText('更新一条数据')).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Prev' }));
const prevButton = screen.getByRole('button', { name: 'Prev' });
const nextButton = screen.getByRole('button', { name: 'Next' });
expect(prevButton).toHaveAttribute('type', 'button');
expect(nextButton).toHaveAttribute('type', 'button');
fireEvent.click(prevButton);
expect(getByText('创建一条数据')).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
expect(getByText('更新一条数据')).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
expect(getByText('危险操作:删除一条数据')).toBeTruthy();
expect(document.querySelector('.rc-tour')).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Finish' }));
const finishButton = screen.getByRole('button', { name: 'Finish' });
expect(finishButton).toHaveAttribute('type', 'button');
fireEvent.click(finishButton);
expect(document.querySelector('.rc-tour')).toBeFalsy();
expect(baseElement).toMatchSnapshot();
});
Expand Down