-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: migrate Cypress tests to Vitest #1347
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
base: main
Are you sure you want to change the base?
Changes from all commits
4cdb31b
1ddc70c
db3ea4e
90ea075
485bf0a
f77337c
ac6f599
1485844
92e9590
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||||||||||
| /* (c) Copyright Frontify Ltd., all rights reserved. */ | ||||||||||||||
|
|
||||||||||||||
| import '@testing-library/jest-dom/vitest'; | ||||||||||||||
| import { render } from '@testing-library/react'; | ||||||||||||||
| import { describe, expect, it } from 'vitest'; | ||||||||||||||
|
|
||||||||||||||
| import { BlockContainerStub } from '../../tests/BlockContainerStub'; | ||||||||||||||
|
|
||||||||||||||
| const IMAGE_CONTAINER_ID = 'image-container'; | ||||||||||||||
| const IMAGE_STAGE_ID = 'image-stage'; | ||||||||||||||
| const IMAGE_ELEMENT_ID = 'image-element'; | ||||||||||||||
|
Comment on lines
+9
to
+11
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| describe('BitmapContainerOperator', () => { | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coverage regression — the original tests asserted that the image was centered: Suggestion: mock |
||||||||||||||
| it('renders image element with 400px height', () => { | ||||||||||||||
| render(<BlockContainerStub height="400px" />); | ||||||||||||||
|
|
||||||||||||||
| const stageElement = document.getElementById(IMAGE_STAGE_ID) as HTMLDivElement; | ||||||||||||||
| const imageElement = document.getElementById(IMAGE_ELEMENT_ID) as HTMLImageElement; | ||||||||||||||
|
|
||||||||||||||
| expect(stageElement).toBeInTheDocument(); | ||||||||||||||
| expect(imageElement).toBeInTheDocument(); | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| it('renders image container with 700px height', () => { | ||||||||||||||
| render(<BlockContainerStub height="700px" />); | ||||||||||||||
|
|
||||||||||||||
| const stageElement = document.getElementById(IMAGE_STAGE_ID) as HTMLDivElement; | ||||||||||||||
| const containerElement = document.getElementById(IMAGE_CONTAINER_ID) as HTMLDivElement; | ||||||||||||||
|
|
||||||||||||||
| expect(stageElement).toBeInTheDocument(); | ||||||||||||||
| expect(containerElement).toBeInTheDocument(); | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| it('renders element with padding 0.2 (in percentages)', () => { | ||||||||||||||
| render(<BlockContainerStub height="500px" padding={0.2} />); | ||||||||||||||
|
|
||||||||||||||
| const stageElement = document.getElementById(IMAGE_STAGE_ID) as HTMLDivElement; | ||||||||||||||
| const containerElement = document.getElementById(IMAGE_CONTAINER_ID) as HTMLDivElement; | ||||||||||||||
|
|
||||||||||||||
| expect(stageElement).toBeInTheDocument(); | ||||||||||||||
| expect(containerElement).toBeInTheDocument(); | ||||||||||||||
| }); | ||||||||||||||
| }); | ||||||||||||||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||
| /* (c) Copyright Frontify Ltd., all rights reserved. */ | ||||||
|
|
||||||
| import '@testing-library/jest-dom/vitest'; | ||||||
| import { fireEvent, render } from '@testing-library/react'; | ||||||
| import { describe, expect, it } from 'vitest'; | ||||||
|
|
||||||
| import { BlockContainerStub } from '../../tests/BlockContainerStub'; | ||||||
|
|
||||||
| const IMAGE_CONTAINER_ID = 'image-container'; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| describe('VectorContainerOperator', () => { | ||||||
| it('renders the image container', () => { | ||||||
| render(<BlockContainerStub height="400px" />); | ||||||
|
|
||||||
| const containerElement = document.getElementById(IMAGE_CONTAINER_ID) as HTMLDivElement; | ||||||
|
|
||||||
| expect(containerElement).toBeInTheDocument(); | ||||||
| }); | ||||||
|
|
||||||
| it('moves image on mouse move', () => { | ||||||
| render(<BlockContainerStub height="400px" />); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test fires Suggestion: fireEvent.mouseDown(containerElement);
fireEvent.mouseMove(containerElement, { buttons: 1, pageX: 300, pageY: 100 });
fireEvent.mouseUp(containerElement);
expect(containerElement.style.left).toBe(/* expected px */);
expect(containerElement.style.top).toBe(/* expected px */); |
||||||
|
|
||||||
| const containerElement = document.getElementById(IMAGE_CONTAINER_ID) as HTMLDivElement; | ||||||
|
|
||||||
| fireEvent.mouseDown(containerElement); | ||||||
| fireEvent.mouseMove(containerElement, { buttons: 1, pageX: 300, pageY: 100 }); | ||||||
| fireEvent.mouseUp(containerElement); | ||||||
|
|
||||||
| expect(containerElement).toBeInTheDocument(); | ||||||
| }); | ||||||
| }); | ||||||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed