Skip to content

Commit

Permalink
ci debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Kruggel committed Jul 18, 2024
1 parent f05fb03 commit f22db52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: playwright-screenshot
path: tests/screenshots/screenshot.png
path: tests/screenshots/screenshot.png
17 changes: 16 additions & 1 deletion tests/auth.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@ import { test as setup, expect } from '@playwright/test';
import { authFile } from './playwright.config';
import path from 'path';

const screenshotPath = path.resolve(__dirname, 'screenshots', 'screenshot.png');
// Function to generate a unique screenshot filename
const getUniqueScreenshotPath = () => {
let index = 1;
let screenshotPath = path.resolve(__dirname, 'screenshots', `screenshot${index}.png`);
while (fs.existsSync(screenshotPath)) {
index++;
screenshotPath = path.resolve(__dirname, 'screenshots', `screenshot${index}.png`);
}
return screenshotPath;
};

setup('authenticate', async ({ page, context, baseURL }) => {
console.log('Current working directory:', process.cwd());
console.log('Screenshot will be saved to:', screenshotPath);
await page.goto('https://jenkins.uds.dev/');
await page.getByLabel("Username or email").fill("doug");
await page.getByLabel("Password").fill("unicorn123!@#");
const screenshotPath = getUniqueScreenshotPath();
console.log('Screenshot will be saved to:', screenshotPath);
await page.screenshot({ path: screenshotPath });
await page.getByRole("button", { name: "Log In" }).click();

// ensure auth cookies were set
Expand All @@ -28,6 +40,9 @@ setup('authenticate', async ({ page, context, baseURL }) => {
await expect(page).toHaveURL('https://jenkins.uds.dev/');
} catch (error) {
console.log('URL assertion failed');
const currentURL = page.url();
const screenshotPath = getUniqueScreenshotPath();
console.log('Screenshot will be saved to:', screenshotPath);
await page.screenshot({ path: screenshotPath });
throw error; // Rethrow the error after taking the screenshot
}
Expand Down

0 comments on commit f22db52

Please sign in to comment.