basic-routes-e2e
This commit is contained in:
parent
55081224b5
commit
4f91f9830b
|
@ -47,7 +47,7 @@ jobs:
|
||||||
- name: Install playwright browsers
|
- name: Install playwright browsers
|
||||||
run: npx playwright install --with-deps
|
run: npx playwright install --with-deps
|
||||||
- name: Run Playwright Test
|
- name: Run Playwright Test
|
||||||
run: npx playwright test test/discoursio-webapp.check.js
|
run: npx playwright test
|
||||||
|
|
||||||
push:
|
push:
|
||||||
needs: test_with_playwright
|
needs: test_with_playwright
|
||||||
|
|
33
test/basic-routes.test.js
Normal file
33
test/basic-routes.test.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
// test/discoursio-webapp.check.js
|
||||||
|
|
||||||
|
const { chromium } = require('playwright')
|
||||||
|
|
||||||
|
;(async () => {
|
||||||
|
const browser = await chromium.launch()
|
||||||
|
const context = await browser.newContext()
|
||||||
|
|
||||||
|
// Define the URLs to visit
|
||||||
|
const pagesToVisit = [
|
||||||
|
'http://localhost:3000/',
|
||||||
|
'http://localhost:3000/feed',
|
||||||
|
'http://localhost:3000/create',
|
||||||
|
'http://localhost:3000/about/donate',
|
||||||
|
'http://localhost:3000/authors',
|
||||||
|
'http://localhost:3000/topics',
|
||||||
|
'http://localhost:3000/inbox',
|
||||||
|
]
|
||||||
|
|
||||||
|
// Loop through the pages and visit each one
|
||||||
|
for (const pageUrl of pagesToVisit) {
|
||||||
|
const page = await context.newPage()
|
||||||
|
await page.goto(pageUrl)
|
||||||
|
|
||||||
|
// Add your test assertions here if needed
|
||||||
|
|
||||||
|
// Close the page before moving to the next one
|
||||||
|
await page.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the browser
|
||||||
|
await browser.close()
|
||||||
|
})()
|
|
@ -1,21 +0,0 @@
|
||||||
const { chromium } = require('playwright')
|
|
||||||
|
|
||||||
const checkUrl = async (page, targetUrl, pageName) => {
|
|
||||||
const response = await page.goto(targetUrl)
|
|
||||||
if (response.status() > 399) {
|
|
||||||
throw new Error(`Failed with response code ${response.status()}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
await page.screenshot({ path: `${pageName}.jpg` })
|
|
||||||
}
|
|
||||||
|
|
||||||
const browser = await chromium.launch()
|
|
||||||
const page = await browser.newPage()
|
|
||||||
|
|
||||||
const targetUrl = process.env.ENVIRONMENT_URL || 'https://testing.discours.io'
|
|
||||||
|
|
||||||
await checkUrl(page, targetUrl, 'main')
|
|
||||||
await checkUrl(page, `${targetUrl}/authors`, 'authors')
|
|
||||||
await checkUrl(page, `${targetUrl}/topics`, 'topics')
|
|
||||||
await page.close()
|
|
||||||
await browser.close()
|
|
Loading…
Reference in New Issue
Block a user