feat: enhance Playwright testing setup with E2E tests, new skills, and improved documentation
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 1m44s
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 1m44s
- Added E2E test setup in `auth_api.py` with `/e2e-seed` endpoint for database reset and test user creation. - Integrated Playwright for end-to-end testing in the frontend with necessary dependencies in `package.json` and `package-lock.json`. - Created Playwright configuration in `playwright.config.ts` to manage test execution and server setup. - Developed new skills for Playwright best practices, visual regression, smoke test generation, and self-healing tests. - Implemented new test cases for chore creation in `chores-create.smoke.spec.ts` and `chores-create.spec.ts`. - Added page object models for `ChildEditPage` and `LandingPage` to streamline test interactions. - Updated `.gitignore` to exclude Playwright reports and test results. - Enhanced documentation in `copilot-instructions.md` for testing and E2E setup.
This commit is contained in:
@@ -25,7 +25,11 @@ from api.error_codes import (
|
||||
INVALID_CREDENTIALS, NOT_VERIFIED, ACCOUNT_MARKED_FOR_DELETION,
|
||||
REFRESH_TOKEN_REUSE, REFRESH_TOKEN_EXPIRED, MISSING_REFRESH_TOKEN,
|
||||
)
|
||||
from db.db import users_db, refresh_tokens_db
|
||||
from db.db import (
|
||||
users_db, refresh_tokens_db, child_db, task_db, reward_db, image_db,
|
||||
pending_reward_db, pending_confirmations_db, tracking_events_db,
|
||||
child_overrides_db, chore_schedules_db, task_extensions_db,
|
||||
)
|
||||
from api.utils import normalize_email
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -35,6 +39,9 @@ TokenQuery = Query()
|
||||
TOKEN_EXPIRY_MINUTES = 60 * 4
|
||||
RESET_PASSWORD_TOKEN_EXPIRY_MINUTES = 10
|
||||
ACCESS_TOKEN_EXPIRY_MINUTES = 15
|
||||
E2E_TEST_EMAIL = 'e2e@test.com'
|
||||
E2E_TEST_PASSWORD = 'E2eTestPass1!'
|
||||
E2E_TEST_PIN = '1234'
|
||||
|
||||
|
||||
def send_verification_email(to_email, token):
|
||||
@@ -460,3 +467,37 @@ def logout():
|
||||
resp = jsonify({'message': 'Logged out'})
|
||||
_clear_auth_cookies(resp)
|
||||
return resp, 200
|
||||
|
||||
|
||||
@auth_api.route('/e2e-seed', methods=['POST'])
|
||||
def e2e_seed():
|
||||
"""Reset the database and insert a verified test user. Only available outside production."""
|
||||
if os.environ.get('DB_ENV', 'prod') == 'prod':
|
||||
return jsonify({'error': 'Not available in production'}), 403
|
||||
|
||||
child_db.truncate()
|
||||
task_db.truncate()
|
||||
reward_db.truncate()
|
||||
image_db.truncate()
|
||||
pending_reward_db.truncate()
|
||||
pending_confirmations_db.truncate()
|
||||
users_db.truncate()
|
||||
tracking_events_db.truncate()
|
||||
child_overrides_db.truncate()
|
||||
chore_schedules_db.truncate()
|
||||
task_extensions_db.truncate()
|
||||
refresh_tokens_db.truncate()
|
||||
|
||||
norm_email = normalize_email(E2E_TEST_EMAIL)
|
||||
user = User(
|
||||
first_name='E2E',
|
||||
last_name='Tester',
|
||||
email=norm_email,
|
||||
password=generate_password_hash(E2E_TEST_PASSWORD),
|
||||
verified=True,
|
||||
role='user',
|
||||
pin=E2E_TEST_PIN,
|
||||
)
|
||||
users_db.insert(user.to_dict())
|
||||
|
||||
return jsonify({'email': norm_email}), 201
|
||||
|
||||
Reference in New Issue
Block a user