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

Integration tests #291

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Integration tests #291

wants to merge 18 commits into from

Conversation

thotmx
Copy link

@thotmx thotmx commented Dec 10, 2024

Here is my approach for integration tests. The goal of this PR is to create a simple foundation to add integration tests for Calibre-web.

I left all the historical commits, so you can verify the different approaches for that.

Summary:

  • First we tried with a complete integration tests for IIAB, using multipass setup. It worked, but it didn't work with Github Actions.
  • The last attempt was using only Pytest-bdd locally, and with Github Actions. It works.

The whole IIAB testing would be better to setup in the IIAB project, or as a external project. But it would require setting up a CI infraestructure because the Github action constraints.

Technical part:

This approach uses:

Add a Github action workflow too.

Works with chrome browser and you can change an environment variable to verify the navigation (debugging) or use the headless approach.

Screenshot from 2024-12-10 13-07-02

@holta
Copy link
Member

holta commented Dec 10, 2024

Wow!

@deldesir & @avni please review within 24h.

If you can.

@holta
Copy link
Member

holta commented Dec 11, 2024

@deldesir can you review this❓

@deldesir
Copy link
Collaborator

I am still at it. Will follow up ASAP.

@holta holta added the enhancement New feature or request label Dec 12, 2024
And you can just run headless:

```
HEADLESS=false pytest -s
Copy link
Member

Choose a reason for hiding this comment

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

HEADLESS=false pytest -s

@thotmx is Line 175 supposed to be identical to Line 181?

(Can you clarify? If possible!)

# Fixture to save information to use through steps
@pytest.fixture
def step_context():
return {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return {}
"""Fixture to save information to use through steps."""
return {}

@then('see the information for logged users')
def _(browser):
"""see the information for logged users"""
assert browser.is_text_present('Books'), 'Book test'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider using a more descriptive error message

Suggested change
assert browser.is_text_present('Books'), 'Book test'
assert browser.is_text_present('Books'), 'Expected "Books" text to be visible on the home page'

def _(browser):
"""see the information for logged users"""
assert browser.is_text_present('Books'), 'Book test'
assert browser.is_text_present('Download to IIAB'), 'IIAB button'
Copy link
Collaborator

Choose a reason for hiding this comment

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

A more descriptive error message would be better here too

Suggested change
assert browser.is_text_present('Download to IIAB'), 'IIAB button'
assert browser.is_text_present('Download to IIAB'), 'Expected "Download to IIAB" button for logged users'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants