-
Notifications
You must be signed in to change notification settings - Fork 4
Testing #30
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
Testing #30
Changes from all commits
9f675f3
7ff71cc
7f3ced2
8155293
5421483
f6d9bf2
29d4d9d
2f1d0c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| name: CI Test Pipeline | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| continue-on-error: false | ||
|
|
||
| env: | ||
| PYTHONPATH: ${{ github.workspace }} | ||
| NEXT_PUBLIC_MOCK_GEMINI: true | ||
| NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
| NEXT_PUBLIC_SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | ||
|
|
||
| steps: | ||
| - name: 🧾 Checkout code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: ⚙️ Setup Node.js | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: 18 | ||
|
|
||
| - name: ⚙️ Setup Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.10' | ||
|
|
||
| - name: ♻️ Cache Python dependencies | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
| restore-keys: ${{ runner.os }}-pip- | ||
|
|
||
| - name: ♻️ Cache Node modules | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ./fitcheck/node_modules | ||
| key: ${{ runner.os }}-node-${{ hashFiles('fitcheck/package-lock.json') }} | ||
| restore-keys: ${{ runner.os }}-node- | ||
|
|
||
| - name: Install Python dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install pytest pytest-cov playwright | ||
| playwright install | ||
|
|
||
| - name: Install frontend dependencies | ||
| working-directory: ./fitcheck | ||
| run: npm install | ||
|
|
||
| - name: Build Next.js app | ||
| working-directory: ./fitcheck | ||
| env: | ||
| NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
| NEXT_PUBLIC_SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | ||
| NEXT_PUBLIC_MOCK_GEMINI: true | ||
| run: npm run build | ||
|
|
||
| - name: Start Next.js server in background | ||
| working-directory: ./fitcheck | ||
| env: | ||
| NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
| NEXT_PUBLIC_SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | ||
| NEXT_PUBLIC_MOCK_GEMINI: true | ||
| run: | | ||
| nohup npm start > ../nextjs.log 2>&1 & | ||
|
|
||
| - name: Wait for server to be ready | ||
| run: | | ||
| for i in {1..10}; do | ||
| curl --fail http://localhost:3000/login && break || sleep 3 | ||
| done || (echo "Server failed to start or /login not reachable" && cat fitcheck/../nextjs.log && exit 1) | ||
|
|
||
| - name: Run Python tests with coverage | ||
| run: pytest --cov=./ --cov-report=html | ||
|
|
||
| - name: Run Playwright E2E test (Login + Dashboard) | ||
| run: python tests/test_login_e2e.py | ||
|
|
||
| - name: Run Playwright E2E test (Extension UI) | ||
| run: xvfb-run -a python tests/test_popup_ui.py | ||
|
|
||
| - name: Upload coverage report | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: coverage-report | ||
| path: htmlcov | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,3 +43,5 @@ node_modules/ | |
| babel.config.js | ||
| .env.local | ||
|
|
||
| __pycache__/ | ||
| *.py[cod] | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| fastapi | ||
| requests | ||
| pytest | ||
| pytest-cov | ||
| pytest-asyncio | ||
| pytest-tornasync | ||
| pytest-trio | ||
| pytest-twisted | ||
| playwright | ||
| python-dotenv | ||
| twisted | ||
| git+https://github.com/supabase-community/supabase-py.git |
|
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. These integration tests are thorough and test different edge cases!! Good work |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,65 @@ | ||||||||||||||||||||||||||||||||||||||||||
| import pytest | ||||||||||||||||||||||||||||||||||||||||||
| import requests | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| BASE_URL = "http://localhost:3000/api/auth" | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| TEST_EMAIL = "gafocoy789@dmener.com" | ||||||||||||||||||||||||||||||||||||||||||
| TEST_PASSWORD = "password123" | ||||||||||||||||||||||||||||||||||||||||||
| TEST_USER = { | ||||||||||||||||||||||||||||||||||||||||||
| "email": TEST_EMAIL, | ||||||||||||||||||||||||||||||||||||||||||
| "password": TEST_PASSWORD, | ||||||||||||||||||||||||||||||||||||||||||
| "first_name": "Test", | ||||||||||||||||||||||||||||||||||||||||||
| "last_name": "User", | ||||||||||||||||||||||||||||||||||||||||||
| "gender": "Other" | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| @pytest.fixture(scope="module") | ||||||||||||||||||||||||||||||||||||||||||
| def cleanup_user(): | ||||||||||||||||||||||||||||||||||||||||||
| yield | ||||||||||||||||||||||||||||||||||||||||||
| print("Cleanup after tests") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| def test_successful_signup_and_login(cleanup_user): | ||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||
| response = requests.post(f"{BASE_URL}/signup", json=TEST_USER) | ||||||||||||||||||||||||||||||||||||||||||
| print("Signup response:", response.status_code, response.json()) | ||||||||||||||||||||||||||||||||||||||||||
| if response.status_code not in (200, 400): | ||||||||||||||||||||||||||||||||||||||||||
| pytest.skip("Signup failed unexpectedly") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+27
|
||||||||||||||||||||||||||||||||||||||||||
| def test_successful_signup_and_login(cleanup_user): | |
| try: | |
| response = requests.post(f"{BASE_URL}/signup", json=TEST_USER) | |
| print("Signup response:", response.status_code, response.json()) | |
| if response.status_code not in (200, 400): | |
| pytest.skip("Signup failed unexpectedly") | |
| def test_successful_signup(cleanup_user): | |
| try: | |
| response = requests.post(f"{BASE_URL}/signup", json=TEST_USER) | |
| print("Signup response:", response.status_code, response.json()) | |
| if response.status_code not in (200, 400): | |
| pytest.skip("Signup failed unexpectedly") | |
| assert response.status_code == 200 | |
| assert response.json()["message"] in ["Please verify your email"] | |
| except Exception as e: | |
| pytest.skip(f"Test skipped due to exception: {e}") | |
| def test_successful_login(cleanup_user): | |
| try: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| const { JSDOM } = require("jsdom"); | ||
|
|
||
| // 📦 Realistic Amazon-like mock HTML | ||
| const html = ` | ||
| <div class="order-card__list"> | ||
| <div class="a-row">Order # 123-4567890-1234567</div> | ||
| <div> | ||
| <span class="a-size-base a-color-secondary aok-break-word">Jan 1, 2024</span> | ||
| <span class="a-size-base a-color-secondary aok-break-word">$19.99</span> | ||
| </div> | ||
| <a class="a-link-normal" href="/dp/ABC123">Product 1</a> | ||
| </div> | ||
| `; | ||
|
|
||
| // 🧠 Create JSDOM first | ||
| const dom = new JSDOM(html); | ||
| global.document = dom.window.document; | ||
| global.window = dom.window; | ||
| global.Node = dom.window.Node; | ||
|
|
||
| // ✅ Shim innerText after DOM is initialized | ||
| Object.defineProperty(global.window.HTMLElement.prototype, 'innerText', { | ||
| get() { | ||
| return this.textContent; | ||
| } | ||
| }); | ||
|
|
||
| // 🛠️ Mock Chrome extension API | ||
| global.chrome = { | ||
| runtime: { | ||
| onMessage: { | ||
| addListener: () => {}, | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| // ✅ Now import the logic AFTER mocks are in place | ||
| const { extractOrders } = require("../amazon-order-csv/content.js"); | ||
|
|
||
| // 🧪 Run test | ||
| extractOrders().then(result => { | ||
| console.log("✅ Extracted Orders:\n", JSON.stringify(result, null, 2)); | ||
| }).catch(err => { | ||
| console.error("❌ Error during extraction:", err); | ||
| }); |
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.
[nitpick] Using 'nohup' for server startup might complicate process management; consider utilizing a dedicated process manager or GitHub Actions background job control instead.