-
Notifications
You must be signed in to change notification settings - Fork 8
add integration tests #17
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
Open
satvik007
wants to merge
6
commits into
dev/satvik/add-unit-tests
Choose a base branch
from
dev/satvik/add-integration-tests
base: dev/satvik/add-unit-tests
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bae8854
add integration tests
satvik007 79c059a
Add typecheck to pre-commit hook and consolidate CI workflow
satvik007 b318899
remove docs
satvik007 1d248d5
Fix integration tests and improve environment variable handling
satvik007 0f7a554
Add rate limit handling for integration tests
satvik007 6298b84
Fix integration tests API endpoints and response format assertions
satvik007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # QA Sphere Integration Test Configuration | ||
| # Copy this file to .env and fill in the required values | ||
|
|
||
| # Required: API key for public API access | ||
| QASPHERE_API_KEY= | ||
|
|
||
| # Required: Authentication credentials | ||
| QASPHERE_AUTH_EMAIL= | ||
| QASPHERE_AUTH_PASSWORD= | ||
|
|
||
| # Optional: Override defaults for different environments | ||
| # QASPHERE_TENANT_URL=https://e2eqas.eu1.qasphere.com | ||
| # QASPHERE_TENANT_ID=eu1vweq68d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| npx lint-staged | ||
| npx lint-staged | ||
| npm run typecheck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { describe, it, expect, beforeAll, afterAll } from 'vitest' | ||
| import axios from 'axios' | ||
| import { | ||
| getTenantUrl, | ||
| getApiHeaders, | ||
| login, | ||
| createTestProject, | ||
| deleteTestProject, | ||
| generateProjectCode, | ||
| } from './helpers.js' | ||
|
|
||
| describe('Custom Fields API Integration Tests', () => { | ||
| let sessionToken: string | ||
| let testProjectCode: string | ||
| let testProjectId: string | ||
|
|
||
| beforeAll(async () => { | ||
| // Login and create test project | ||
| sessionToken = await login() | ||
| testProjectCode = generateProjectCode() | ||
| const project = await createTestProject( | ||
| sessionToken, | ||
| testProjectCode, | ||
| `[MCP-TEST] ${testProjectCode}` | ||
| ) | ||
| testProjectId = project.id | ||
| }) | ||
|
|
||
| afterAll(async () => { | ||
| // Clean up the test project (only if it was created) | ||
| if (sessionToken && testProjectId) { | ||
| await deleteTestProject(sessionToken, testProjectId) | ||
| } | ||
| }) | ||
|
|
||
| describe('list_custom_fields', () => { | ||
| it('should return field definitions', async () => { | ||
| const response = await axios.get( | ||
| `${getTenantUrl()}/api/public/v0/project/${testProjectCode}/custom-field`, | ||
| { | ||
| headers: getApiHeaders(), | ||
| } | ||
| ) | ||
|
|
||
| expect(response.status).toBe(200) | ||
| expect(response.data).toHaveProperty('customFields') | ||
| expect(Array.isArray(response.data.customFields)).toBe(true) | ||
| }) | ||
|
|
||
| it('should return fields with correct types', async () => { | ||
| const response = await axios.get( | ||
| `${getTenantUrl()}/api/public/v0/project/${testProjectCode}/custom-field`, | ||
| { | ||
| headers: getApiHeaders(), | ||
| } | ||
| ) | ||
|
|
||
| expect(response.status).toBe(200) | ||
|
|
||
| // If there are custom fields, verify they have the expected structure | ||
| const customFields = response.data.customFields | ||
| if (customFields.length > 0) { | ||
| const field = customFields[0] | ||
| expect(field).toHaveProperty('id') | ||
| expect(field).toHaveProperty('systemName') | ||
| expect(field).toHaveProperty('name') | ||
| expect(field).toHaveProperty('type') | ||
| expect(['text', 'dropdown']).toContain(field.type) | ||
| } | ||
| }) | ||
satvik007 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| import { describe, it, expect, beforeAll, afterAll } from 'vitest' | ||
| import axios from 'axios' | ||
| import { | ||
| getTenantUrl, | ||
| getApiHeaders, | ||
| login, | ||
| createTestProject, | ||
| deleteTestProject, | ||
| generateProjectCode, | ||
| } from './helpers.js' | ||
|
|
||
| describe('Folder API Integration Tests', () => { | ||
| let sessionToken: string | ||
| let testProjectCode: string | ||
| let testProjectId: string | ||
|
|
||
| beforeAll(async () => { | ||
| // Login and create test project | ||
| sessionToken = await login() | ||
| testProjectCode = generateProjectCode() | ||
| const project = await createTestProject( | ||
| sessionToken, | ||
| testProjectCode, | ||
| `[MCP-TEST] ${testProjectCode}` | ||
| ) | ||
| testProjectId = project.id | ||
| }) | ||
|
|
||
| afterAll(async () => { | ||
| // Clean up the test project (only if it was created) | ||
| if (sessionToken && testProjectId) { | ||
| await deleteTestProject(sessionToken, testProjectId) | ||
| } | ||
| }) | ||
|
|
||
| describe('list_folders', () => { | ||
| it('should return folder list with pagination', async () => { | ||
| const response = await axios.get( | ||
| `${getTenantUrl()}/api/public/v0/project/${testProjectCode}/tcase/folders`, | ||
| { | ||
| headers: getApiHeaders(), | ||
| } | ||
| ) | ||
|
|
||
| expect(response.status).toBe(200) | ||
| expect(response.data).toHaveProperty('data') | ||
| expect(response.data).toHaveProperty('total') | ||
| expect(response.data).toHaveProperty('page') | ||
| expect(response.data).toHaveProperty('limit') | ||
| expect(Array.isArray(response.data.data)).toBe(true) | ||
| }) | ||
|
|
||
| it('should respect pagination parameters', async () => { | ||
| // First create some folders | ||
| await axios.post( | ||
| `${getTenantUrl()}/api/public/v0/project/${testProjectCode}/tcase/folder/bulk`, | ||
| { | ||
| folders: [ | ||
| { path: ['[MCP-TEST] Folder 1'] }, | ||
| { path: ['[MCP-TEST] Folder 2'] }, | ||
| { path: ['[MCP-TEST] Folder 3'] }, | ||
| { path: ['[MCP-TEST] Folder 4'] }, | ||
| { path: ['[MCP-TEST] Folder 5'] }, | ||
| { path: ['[MCP-TEST] Folder 6'] }, | ||
| ], | ||
| }, | ||
| { | ||
| headers: getApiHeaders(), | ||
| } | ||
| ) | ||
|
|
||
| const response = await axios.get( | ||
| `${getTenantUrl()}/api/public/v0/project/${testProjectCode}/tcase/folders`, | ||
| { | ||
| params: { page: 1, limit: 5 }, | ||
| headers: getApiHeaders(), | ||
| } | ||
| ) | ||
|
|
||
| expect(response.status).toBe(200) | ||
| expect(response.data.page).toBe(1) | ||
| expect(response.data.limit).toBe(5) | ||
| expect(response.data.data.length).toBeLessThanOrEqual(5) | ||
| }) | ||
| }) | ||
|
|
||
| describe('upsert_folders', () => { | ||
| it('should create single folder', async () => { | ||
| const response = await axios.post( | ||
| `${getTenantUrl()}/api/public/v0/project/${testProjectCode}/tcase/folder/bulk`, | ||
| { | ||
| folders: [{ path: ['[MCP-TEST] Single Folder'] }], | ||
| }, | ||
| { | ||
| headers: getApiHeaders(), | ||
| } | ||
| ) | ||
|
|
||
| expect(response.status).toBe(200) | ||
| expect(response.data).toHaveProperty('ids') | ||
| expect(Array.isArray(response.data.ids)).toBe(true) | ||
| expect(response.data.ids.length).toBe(1) | ||
| expect(response.data.ids[0].length).toBe(1) | ||
| expect(typeof response.data.ids[0][0]).toBe('number') | ||
| }) | ||
|
|
||
| it('should create nested folders', async () => { | ||
| const response = await axios.post( | ||
| `${getTenantUrl()}/api/public/v0/project/${testProjectCode}/tcase/folder/bulk`, | ||
| { | ||
| folders: [{ path: ['[MCP-TEST] A', '[MCP-TEST] B', '[MCP-TEST] C'] }], | ||
| }, | ||
| { | ||
| headers: getApiHeaders(), | ||
| } | ||
| ) | ||
|
|
||
| expect(response.status).toBe(200) | ||
| expect(response.data).toHaveProperty('ids') | ||
| expect(response.data.ids.length).toBe(1) | ||
| expect(response.data.ids[0].length).toBe(3) | ||
|
|
||
| // Verify each level has a valid ID | ||
| for (const id of response.data.ids[0]) { | ||
| expect(typeof id).toBe('number') | ||
| expect(id).toBeGreaterThan(0) | ||
| } | ||
| }) | ||
|
|
||
| it('should update folder comment without creating duplicate', async () => { | ||
| const folderPath = ['[MCP-TEST] Update Test'] | ||
|
|
||
| // Create folder | ||
| const createResponse = await axios.post( | ||
| `${getTenantUrl()}/api/public/v0/project/${testProjectCode}/tcase/folder/bulk`, | ||
| { | ||
| folders: [{ path: folderPath, comment: 'Initial comment' }], | ||
| }, | ||
| { | ||
| headers: getApiHeaders(), | ||
| } | ||
| ) | ||
|
|
||
| const folderId = createResponse.data.ids[0][0] | ||
|
|
||
| // Update folder comment | ||
| const updateResponse = await axios.post( | ||
| `${getTenantUrl()}/api/public/v0/project/${testProjectCode}/tcase/folder/bulk`, | ||
| { | ||
| folders: [{ path: folderPath, comment: 'Updated comment' }], | ||
| }, | ||
| { | ||
| headers: getApiHeaders(), | ||
| } | ||
| ) | ||
|
|
||
| expect(updateResponse.status).toBe(200) | ||
| // Should return the same folder ID (not create a new one) | ||
| expect(updateResponse.data.ids[0][0]).toBe(folderId) | ||
| }) | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do we need email and password? Using an API key seems enough. We never use username and password for public APIs.