-
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.
- Loading branch information
1 parent
7b612d0
commit f8f1b45
Showing
4 changed files
with
61 additions
and
72 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
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,28 +1,51 @@ | ||
import { test, expect, request } from '@playwright/test'; | ||
import { expect, request, test } from '@playwright/test'; | ||
|
||
test('Verify each link in links.json is reachable', async ({ page, baseURL }) => { | ||
console.log(`Attempting to load links.json from ${baseURL}/links.json`); | ||
let links: string[] = []; | ||
|
||
// A setup function to load links.json before all tests | ||
test.beforeAll(async ({ baseURL }) => { | ||
if (!baseURL) { | ||
throw new Error( | ||
'baseURL is not defined. Ensure the baseURL is properly set in Playwright config.', | ||
); | ||
} | ||
|
||
const apiContext = await request.newContext(); | ||
const response = await apiContext.get(`${baseURL}/links.json`); | ||
|
||
if (!response.ok()) { | ||
console.error(`Failed to load links.json with status: ${response.status()}`); | ||
console.error( | ||
`Failed to load links.json with status: ${response.status()}`, | ||
); | ||
throw new Error('Could not load links.json'); | ||
} | ||
|
||
let links: string[] = []; | ||
try { | ||
const data = await response.json(); | ||
links = data.links; | ||
console.log(`Loaded ${links.length} links from links.json`); | ||
//console.log(`Loaded ${links.length} links from links.json`); | ||
} catch (error) { | ||
console.error('Failed to parse links.json:', error); | ||
throw error; | ||
} | ||
}); | ||
|
||
// A test to verify each link in links.json is reachable | ||
test('Verify each link in links.json is reachable', async ({ page }) => { | ||
if (links.length === 0) { | ||
throw new Error( | ||
'No links were loaded. Ensure links.json is available and correctly parsed.', | ||
); | ||
} | ||
|
||
for (const link of links) { | ||
await page.goto(link); | ||
expect(page.url()).toBe(link); | ||
//console.log(`Successfully navigated to ${link}`); | ||
} | ||
}); | ||
|
||
test('has title', async ({ page }) => { | ||
await page.goto('/'); | ||
await expect(page).toHaveTitle(/.*KOLLITSCH\.dev\*.*/); | ||
}); |
This file was deleted.
Oops, something went wrong.