basic-routes-e2e
Some checks failed
deploy / test (push) Successful in 53s
deploy / quality (push) Failing after 10s
deploy / Run end-to-end tests (push) Failing after 1m25s
deploy / Update templates on Mailgun (push) Has been skipped
deploy / push (push) Failing after 1s

This commit is contained in:
Untone 2024-02-04 13:20:41 +03:00
parent 55081224b5
commit 4f91f9830b
3 changed files with 34 additions and 22 deletions

View File

@ -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
View 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()
})()

View File

@ -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()