Skip to content

Commit

Permalink
Fix gui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSazonov committed Apr 25, 2024
1 parent e865a1d commit 0a0518f
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 32 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
python -m pip install numpy lmfit numdifftools
python -m pip install orjson jsbeautifier
python -m pip install pyinstaller requests dephell_licenses
python -m pip install pytest pytest-image-diff
python -m pip install git+https://github.com/ikibalin/cryspy.git@beta
python -m pip install git+https://github.com/easyscience/EasyApp.git@new-easy-app2
Expand Down Expand Up @@ -113,6 +114,19 @@ jobs:
- name: Run QML GUI tests
run: python ${{ env.PACKAGE_NAME }}/main.py --testmode

- name: Run screenshots comparison tests
run: pytest tests/gui

- name: Upload zipped GUI tests screenshots
uses: actions/upload-artifact@v4
with:
name: build-installer_screenshots_${{ matrix.os }} # desired name (without .zip) of the zip file to be uploaded
path: | # all files from these paths are zipped into file with name from above
tests/gui/screenshots
.tests/image_diff
if-no-files-found: 'error'
compression-level: 0

- name: Create freezed python app bundle with PyInstaller
run: python ${{ env.SCRIPTS_PATH }}/FreezeApp.py

Expand Down Expand Up @@ -296,7 +310,7 @@ jobs:
- name: Upload zipped GUI tests screenshots
uses: actions/upload-artifact@v4
with:
name: test-screenshots_${{ matrix.os }} # desired name (without .zip) of the zip file to be uploaded
name: test-installer_screenshots_${{ matrix.os }} # desired name (without .zip) of the zip file to be uploaded
path: | # all files from these paths are zipped into file with name from above
tests/gui/screenshots
.tests/image_diff
Expand Down
23 changes: 1 addition & 22 deletions easyDiffractionApp/Gui/Components/GuiTestsController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,10 @@ EaElements.RemoteController {

// Tests

function saveImage(fileName, path='../tests/gui/screenshots/actual') {
function saveImage(fileName, path='tests/gui/screenshots/actual') {
saveScreenshot(parent, `${path}/${fileName}`)
}

function startGuiTest_() {
console.debug('Start basic suit of GUI tests (step 1 of 2)')
rc.posToCenter()
rc.showPointer()
rc.wait(1000)

const saveImagesDir = '../tests/gui/basic/actual'
saveImage(saveImagesDir, 'HomePage.png')

rc.wait(1000)
Globals.Proxies.main.status.fitStatus = true
}

function finishGuiTest_() {
console.debug('Finish basic suit of GUI tests (step 2 of 2)')
res.push( rc.compare('58 (6 free, 52 fixed)', '58 (6 free, 52 fixed)') )
res.push( rc.compare('341.99 → 4.41', '341.99 → 4.41') )
res.push( rc.compare('Success', 'Success') )
rc.hidePointer()
}

function startGuiTest() {
console.debug('Start basic suit of GUI tests (step 1 of 2)')

Expand Down
Binary file modified tests/gui/screenshots/actual/AnalysisPage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/gui/screenshots/actual/ExperimentPage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/gui/screenshots/actual/HomePage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/gui/screenshots/actual/ModelPage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/gui/screenshots/actual/ProjectPage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/gui/screenshots/actual/SummaryPage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/gui/screenshots/desired/HomePage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/gui/screenshots/desired/HomePage_.png
Binary file not shown.
9 changes: 0 additions & 9 deletions tests/gui/test__TutorialFitTwoPhases.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import os
import pathlib

# Help functions

def change_cwd_to_tests():
"""Changes the current directory to the directory of this script file."""
os.chdir(os.path.dirname(__file__))

def desired_img_path(fname:str):
return os.path.join('screenshots', 'desired', fname)

def actual_img_path(fname:str):
return os.path.join('screenshots', 'actual', fname)

# Set up paths

change_cwd_to_tests()

# Tests

def test__HomePage(image_diff):
Expand Down

0 comments on commit 0a0518f

Please sign in to comment.