forked from chainable-dev/the-front
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Playwright workflow to trigger on deployment status
- Loading branch information
Showing
6 changed files
with
101 additions
and
86 deletions.
There are no files selected for viewing
This file contains 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 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,35 +1,11 @@ | ||
# name: Unit Tests | ||
|
||
# on: | ||
# push: | ||
# branches: [ main ] | ||
# pull_request: | ||
# branches: [ main ] | ||
|
||
# jobs: | ||
# test: | ||
# runs-on: ubuntu-latest | ||
|
||
# steps: | ||
# - uses: actions/checkout@v3 | ||
|
||
# - name: Use Node.js | ||
# uses: actions/setup-node@v3 | ||
# with: | ||
# node-version: '18' | ||
|
||
# - name: Install pnpm | ||
# uses: pnpm/action-setup@v2 | ||
# with: | ||
# version: 8 | ||
|
||
# - name: Install dependencies | ||
# run: pnpm install | ||
|
||
# - name: Run tests | ||
# run: pnpm test | ||
|
||
# - name: Upload coverage reports to Codecov | ||
# uses: codecov/codecov-action@v3 | ||
# env: | ||
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
name: Unit Tests | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: echo "No unit tests configured yet" |
This file contains 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,23 +1,16 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('should navigate to the homepage and see content', async ({ page }) => { | ||
// Use the BASE_URL from the environment variable | ||
await page.goto(process.env.BASE_URL); // Use the dynamic BASE_URL | ||
|
||
// Example of using the Bypass Token in a request | ||
const response = await page.request.get('/api/some-endpoint', { | ||
headers: { | ||
'Authorization': `Bearer ${process.env.BYPASS_TOKEN}` // Use the Bypass Token | ||
} | ||
}); | ||
test('should load homepage with content', async ({ page }) => { | ||
console.log('Starting test: should load homepage with content'); | ||
await page.goto('/'); | ||
console.log('Navigated to homepage'); | ||
|
||
// Check if the response is successful | ||
expect(response.ok()).toBeTruthy(); | ||
await page.waitForSelector('body', { state: 'visible' }); | ||
console.log('Body is visible'); | ||
|
||
const content = await page.textContent('body'); | ||
console.log('Page content:', content); | ||
|
||
// Wait for the page to load completely | ||
await page.waitForLoadState('networkidle'); | ||
|
||
// Check for the presence of the expected text | ||
const content = await page.content(); | ||
expect(content).toContain('Welcome'); | ||
console.log('Content contains "Welcome"'); | ||
}); |
This file contains 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,35 +1,67 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('Unprotected Page Tests', () => { | ||
test('should navigate to the homepage and see content', async ({ page }) => { | ||
await page.goto('/'); // This will use the baseURL set in the config | ||
test.describe('Streaming Website Tests', () => { | ||
test('should handle chunked streaming content', async ({ page }) => { | ||
console.log('Starting test: should handle chunked streaming content'); | ||
await page.goto('/'); | ||
console.log('Navigated to homepage'); | ||
|
||
// Check if the page contains any content | ||
const content = await page.content(); | ||
expect(content).toContain('Welcome'); // Ensure this matches the actual homepage content | ||
}); | ||
// Wait for the streaming content container to be visible | ||
await page.waitForSelector('body', { state: 'visible', timeout: 30000 }); | ||
console.log('Body is visible'); | ||
|
||
test('should navigate to the landing page and see content', async ({ page }) => { | ||
await page.goto('/landing'); // Navigate to the landing page | ||
// Function to collect chunks | ||
const chunks: string[] = []; | ||
await page.exposeFunction('addChunk', (chunk: string) => { | ||
chunks.push(chunk); | ||
console.log('Received chunk:', chunk); | ||
}); | ||
|
||
// Check if the page contains any content | ||
const content = await page.content(); | ||
expect(content).toContain('AI-Powered Task Management'); // Ensure this matches the actual landing page content | ||
}); | ||
// Listen for chunks | ||
await page.evaluate(() => { | ||
const observer = new MutationObserver((mutations) => { | ||
for (let mutation of mutations) { | ||
if (mutation.type === 'childList') { | ||
mutation.addedNodes.forEach((node) => { | ||
if (node.nodeType === Node.TEXT_NODE) { | ||
// @ts-ignore | ||
window.addChunk(node.textContent); | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
observer.observe(document.body, { childList: true, subtree: true }); | ||
}); | ||
console.log('Set up MutationObserver'); | ||
|
||
// Wait for some time to collect chunks (adjust timeout as needed) | ||
await page.waitForTimeout(10000); | ||
console.log('Waited for 10 seconds'); | ||
|
||
test('should navigate to the about page and see content', async ({ page }) => { | ||
await page.goto('/about'); // This will use the baseURL set in the config | ||
// Verify that we received chunks | ||
expect(chunks.length).toBeGreaterThan(0); | ||
console.log('Total chunks received:', chunks.length); | ||
console.log('Chunks:', chunks); | ||
|
||
// Check if the page contains any content | ||
const content = await page.content(); | ||
expect(content).toContain('About Us'); // Ensure this matches the actual about page content | ||
// You can add more specific assertions here based on the expected content of your chunks | ||
}); | ||
|
||
test('should navigate to the signup page and see content', async ({ page }) => { | ||
await page.goto('/signup'); // This will use the baseURL set in the config | ||
test('should handle user interactions with streaming content', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
// Check if the page contains any content | ||
const content = await page.content(); | ||
expect(content).toContain('Create your account'); // Ensure this matches the actual signup page content | ||
// Wait for an interactive element to be available | ||
await page.waitForSelector('#interaction-button', { state: 'visible' }); | ||
|
||
// Interact with the streaming content | ||
await page.click('#interaction-button'); | ||
|
||
// Wait for and verify the response to the interaction | ||
const responseElement = await page.waitForSelector('#interaction-response', { state: 'visible', timeout: 5000 }); | ||
const responseText = await responseElement.textContent(); | ||
expect(responseText).toContain('Interaction successful'); | ||
}); | ||
|
||
// Add more tests as needed for your specific streaming features | ||
}); |
This file contains 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 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