Skip to content

Refactor code#987

Merged
wswebcreation merged 30 commits into
ws/rewrite-corefrom
ws/image-comparison-core-refactor
Jul 17, 2025
Merged

Refactor code#987
wswebcreation merged 30 commits into
ws/rewrite-corefrom
ws/image-comparison-core-refactor

Conversation

@wswebcreation

@wswebcreation wswebcreation commented Jun 26, 2025

Copy link
Copy Markdown
Member

This pull request includes various updates to the image-comparison-core package, including enhancements to folder and file path interfaces, improvements to test readability by removing redundant comments, and minor configuration updates. Below are the most important changes grouped by theme:

Enhancements to Interfaces:

  • Introduced FolderPaths and FilePaths interfaces in base.interfaces.ts to provide clear definitions for folder and file paths used in image comparison workflows. These interfaces include properties for actual, baseline, and diff paths.

Test Code Simplifications:

  • Removed redundant comments from the drawTabbableOnCanvas test file to improve readability and maintainability. This includes removing comments explaining mocked properties, DOM resets, and verification steps. [1] [2] [3]
  • Simplified test cases in hideRemoveElements.test.ts by removing unnecessary comments that described straightforward assertions. [1] [2]

Mocking and Configuration Updates:

  • Updated the mock implementation for rmSync in base.test.ts to streamline the mocking process while retaining the actual implementations of other fs methods.
  • Added .vitest-ui to the ESLint ignore patterns in eslint.config.cjs to exclude Vitest UI artifacts from linting.

These changes collectively enhance code clarity, maintainability, and functionality across the package.

@changeset-bot

changeset-bot Bot commented Jun 26, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 240fe83

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

- implemented for saveWebScreen
was broken due to incorrect calculation, also fixed UT's
- afterscreenshot for readability
- make takeElementScreenshot more readable
- fix UT for afterscreenshot
- add check on calling logger for afterscreenshot
- adjust files
- create UT's
- adjust methods
- add and adjust UTs
- added buildBaseExecuteCompareOptions
- added and adjusted UT's
- updated interfaces
- made code more dry and maintainable
- updated UTs
@wswebcreation
wswebcreation marked this pull request as ready for review July 17, 2025 15:32
@wswebcreation
wswebcreation merged commit a7ec171 into ws/rewrite-core Jul 17, 2025
19 checks passed
@wswebcreation
wswebcreation deleted the ws/image-comparison-core-refactor branch July 17, 2025 15:32
wswebcreation added a commit that referenced this pull request Jul 22, 2025
* feat: add new package @wdio/image-comparison-core
Started
- migrating code
- optimize types
- remove executor and replace by wdio methods

* feat: update getMobileViewPortPosition

- fix tests

* chore: replaced takeBase64Screenshot implementation

- updated tests

* chore: fixed afterScreenshot

- updated tests

* chore: updated beforeScreenshot

- fixed and added UT's

* chore: clean saveWebScreen from methods

- fix UT's

* chore: update checkScreen

* chore: fix checkWebScreen

* chore: fix saveElement and checkElement

* chore: add full/tabbable page

* chore: remove methods

* chore: adjust the visual service to use the new core

* chore: migrated the service to the new module

- fixed UTs and imports

* chore: add browserInstance to the commands

* chore: added the browserinstance back and fix UTs

* fix UT's

* fix tests

* chore: cleanup methods

* chore: remove webdriver-image-comparison

* chore: multiple fixes

- fix BiDi check
- fix determining iOS currentOffsets
- fix calculating remaining content for mobile fullpage screenshots
- add extra debug logging when the fullpage scroll becomes negative
- updated baselines

* chore: fix UT's

* chore: optimize types

* test: add tests vor checkAppElement

* chore: make private package public

* test: add checkAppScreen tests

* tesT: add new tests

* chore: refactor mocks

* chore: simplify checks

* test: add checkScreen tests

* test: add checkTabbablePage

* test: add checkWebElement

fix some styling

* chore: revert Sauce tests

* test: add checkWebScreen

* test: add checkWebScreen tests
- some linting shit

* chore: update eslint

* test: add saveAppElement

* chore: fix folders

* chore: fix some tests

* test: add saveAppScreen

* test: add saveElement

* tesT: add saveFullPageScreen test

* test: add saveScreen tests

* test: add saveTabbablePage tests

* test: add saveWebElement tests

* test: add saveWebScreen tests

* chore: create BEFORE_SCREENSHOT_MOCK

* chore: optimize mocks

- saveWebElement
- saveAppScreen
- saveAppElement
- saveWebScreen
- saveTabbablePage
- saveElement
- mocks file

* test: add drawTabbableOnCanvas tests

* test: add more tests drawTabbableOnCanvas

* test: add more tests for drawTabbableOnCanvas

* test: update drawTabbableOnCanvas

- add comments for whats's not properly testable

* chore: added todo's

* test: add scrollElementIntoView tests

- fix screendimentions test

* test: add scrollToPosition tests

* test: add createCompareReport tests

* test: add processDiffPixels

* test: add makeCroppedBase64Image tests

* test: add executeImageCompare tests

* test: add makeFullPageBase64Image tests

* test: add takeResizedBase64Screenshot tests

* fix: fix object comparison and add proper logging for takeBase64ElementScreenshot

- add new UT's for takeBase64ElementScreenshot part 1

* test: add more tests for takeBase64ElementScreenshot

* fix: fix images tests

* chore: use snapshots

* test: add takeWebElementScreenshot tests

* test: add logHiddenRemovedError

* test: add getDesktopFullPageScreenshotsData

* test: add getAndroidChromeDriverFullPageScreenshotsData

* test: add getMobileFullPageNativeWebScreenshotsData

* chore: some small fixes

* Refactor code (#987)

* feat: refactor getBase64FullPageScreenshotsData router

- update ut's

* chore: update tests

* chore: refactor beforeOptions

- update saveFullPageScreen and tests

* feat: adjust saveWebScreen with createBeforeScreenshotOptions

* feat: adjust saveWebElement for createBeforeScreenshotOptions

* chore: optimise saveWebElement

* chore: restructure interface

* chore: refactor afterScreenshot options

- implemented for saveWebScreen

* chore: refactor for saveWebElement

* chore: refactor saveFullPageScreen

* chore: refactor saveAppScreen

* chore: refactor saveAppElement

* chore: refactor saveWebScreen

* chore: refactor screenshot interfaces

* chore: and the rest

* chore: use snapshots for tests

* fix: fallback for elementscreeshots

was broken due to incorrect calculation, also fixed UT's

* chore: fix local desktop run

* chore: fix some comments

* chore: code optimisation

- afterscreenshot for readability

* chore: optimisations

- make takeElementScreenshot more readable
- fix UT for afterscreenshot
- add check on calling logger for afterscreenshot

* chore: then also commit the afterscreenshot stuff

* chore: refactor a CommonCheckVariables

- adjust files
- create UT's

* chore: refactor to use buildFolderOptions

- adjust methods
- add and adjust UTs

* chore: refactor methods options

- added buildBaseExecuteCompareOptions
- added and adjusted UT's

* chore: refactor checkAppElement and checkAppScreen

* chore: refactored images and report code

- updated interfaces
- made code more dry and maintainable
- updated UTs

* chore: fix linting

* chore: fix build

* Chore: remove comments

* chore: update deps

* chore: add release notes
wswebcreation added a commit that referenced this pull request Jul 22, 2025
* feat: add new package @wdio/image-comparison-core
Started
- migrating code
- optimize types
- remove executor and replace by wdio methods

* feat: update getMobileViewPortPosition

- fix tests

* chore: replaced takeBase64Screenshot implementation

- updated tests

* chore: fixed afterScreenshot

- updated tests

* chore: updated beforeScreenshot

- fixed and added UT's

* chore: clean saveWebScreen from methods

- fix UT's

* chore: update checkScreen

* chore: fix checkWebScreen

* chore: fix saveElement and checkElement

* chore: add full/tabbable page

* chore: remove methods

* chore: adjust the visual service to use the new core

* chore: migrated the service to the new module

- fixed UTs and imports

* chore: add browserInstance to the commands

* chore: added the browserinstance back and fix UTs

* fix UT's

* fix tests

* chore: cleanup methods

* chore: remove webdriver-image-comparison

* chore: multiple fixes

- fix BiDi check
- fix determining iOS currentOffsets
- fix calculating remaining content for mobile fullpage screenshots
- add extra debug logging when the fullpage scroll becomes negative
- updated baselines

* chore: fix UT's

* chore: optimize types

* test: add tests vor checkAppElement

* chore: make private package public

* test: add checkAppScreen tests

* tesT: add new tests

* chore: refactor mocks

* chore: simplify checks

* test: add checkScreen tests

* test: add checkTabbablePage

* test: add checkWebElement

fix some styling

* chore: revert Sauce tests

* test: add checkWebScreen

* test: add checkWebScreen tests
- some linting shit

* chore: update eslint

* test: add saveAppElement

* chore: fix folders

* chore: fix some tests

* test: add saveAppScreen

* test: add saveElement

* tesT: add saveFullPageScreen test

* test: add saveScreen tests

* test: add saveTabbablePage tests

* test: add saveWebElement tests

* test: add saveWebScreen tests

* chore: create BEFORE_SCREENSHOT_MOCK

* chore: optimize mocks

- saveWebElement
- saveAppScreen
- saveAppElement
- saveWebScreen
- saveTabbablePage
- saveElement
- mocks file

* test: add drawTabbableOnCanvas tests

* test: add more tests drawTabbableOnCanvas

* test: add more tests for drawTabbableOnCanvas

* test: update drawTabbableOnCanvas

- add comments for whats's not properly testable

* chore: added todo's

* test: add scrollElementIntoView tests

- fix screendimentions test

* test: add scrollToPosition tests

* test: add createCompareReport tests

* test: add processDiffPixels

* test: add makeCroppedBase64Image tests

* test: add executeImageCompare tests

* test: add makeFullPageBase64Image tests

* test: add takeResizedBase64Screenshot tests

* fix: fix object comparison and add proper logging for takeBase64ElementScreenshot

- add new UT's for takeBase64ElementScreenshot part 1

* test: add more tests for takeBase64ElementScreenshot

* fix: fix images tests

* chore: use snapshots

* test: add takeWebElementScreenshot tests

* test: add logHiddenRemovedError

* test: add getDesktopFullPageScreenshotsData

* test: add getAndroidChromeDriverFullPageScreenshotsData

* test: add getMobileFullPageNativeWebScreenshotsData

* chore: some small fixes

* Refactor code (#987)

* feat: refactor getBase64FullPageScreenshotsData router

- update ut's

* chore: update tests

* chore: refactor beforeOptions

- update saveFullPageScreen and tests

* feat: adjust saveWebScreen with createBeforeScreenshotOptions

* feat: adjust saveWebElement for createBeforeScreenshotOptions

* chore: optimise saveWebElement

* chore: restructure interface

* chore: refactor afterScreenshot options

- implemented for saveWebScreen

* chore: refactor for saveWebElement

* chore: refactor saveFullPageScreen

* chore: refactor saveAppScreen

* chore: refactor saveAppElement

* chore: refactor saveWebScreen

* chore: refactor screenshot interfaces

* chore: and the rest

* chore: use snapshots for tests

* fix: fallback for elementscreeshots

was broken due to incorrect calculation, also fixed UT's

* chore: fix local desktop run

* chore: fix some comments

* chore: code optimisation

- afterscreenshot for readability

* chore: optimisations

- make takeElementScreenshot more readable
- fix UT for afterscreenshot
- add check on calling logger for afterscreenshot

* chore: then also commit the afterscreenshot stuff

* chore: refactor a CommonCheckVariables

- adjust files
- create UT's

* chore: refactor to use buildFolderOptions

- adjust methods
- add and adjust UTs

* chore: refactor methods options

- added buildBaseExecuteCompareOptions
- added and adjusted UT's

* chore: refactor checkAppElement and checkAppScreen

* chore: refactored images and report code

- updated interfaces
- made code more dry and maintainable
- updated UTs

* chore: fix linting

* chore: fix build

* Chore: remove comments

* chore: update deps

* chore: add release notes
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.

1 participant