-
-
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
c545e2e
commit 05e91fc
Showing
11 changed files
with
364 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Nightly E2E Tests | ||
|
||
on: | ||
schedule: | ||
- cron: '0 2 * * *' # Runs at 2 AM UTC every day | ||
workflow_dispatch: # Allows manual triggering | ||
|
||
jobs: | ||
e2e-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Install Playwright browsers | ||
run: npx playwright install --with-deps | ||
|
||
- name: Run E2E tests | ||
run: npm run e2e | ||
|
||
- name: Upload test results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 5 |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: PR Tests | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run unit tests | ||
run: npm run test | ||
|
||
- name: Install Playwright browsers | ||
run: npx playwright install --with-deps | ||
|
||
- name: Run E2E tests | ||
run: npm run e2e | ||
|
||
- name: Upload test results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-reports | ||
path: | | ||
playwright-report/ | ||
coverage/ | ||
retention-days: 5 |
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ dist.crx | |
# Build files | ||
dist/ | ||
build/ | ||
test-results/ | ||
|
||
# Thumbnails | ||
._* | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { defineConfig } from '@playwright/test' | ||
|
||
export default defineConfig({ | ||
testMatch: /.*\.e2e\.js/, | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { test as base, expect } from '@playwright/test' | ||
import siteConfigs from './config.js' | ||
|
||
// Define a common user agent | ||
const COMMON_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' | ||
|
||
// Create a custom test fixture that sets the user agent | ||
const test = base.extend({ | ||
page: async ({ page }, use) => { | ||
await page.setExtraHTTPHeaders({ | ||
'User-Agent': COMMON_USER_AGENT, | ||
}) | ||
await use(page) | ||
}, | ||
}) | ||
|
||
// Helper function to test a specific page configuration | ||
async function testPageConfig(page, url, config) { | ||
await page.goto(url) | ||
|
||
// Execute the getInfo function in the browser context | ||
const info = await page.evaluate(config.getInfo) | ||
|
||
// Verify that the info object is not null or undefined | ||
expect(info).toBeTruthy() | ||
|
||
// Verify that all expected properties are present and non-empty | ||
for (const key in info) { | ||
expect(info[key]).toBeTruthy() | ||
} | ||
|
||
// Test markdown and plaintext building functions | ||
const markdown = config.buildMarkdown(info, url) | ||
const plaintext = config.buildPlaintext(info, url) | ||
|
||
expect(markdown).toBeTruthy() | ||
expect(plaintext).toBeTruthy() | ||
} | ||
|
||
// Test cases for each site and page type | ||
for (const [siteName, siteConfig] of Object.entries(siteConfigs)) { | ||
// LinkedIn is hard to test because it requires auth | ||
if (siteName === 'linkedin') continue | ||
|
||
for (const [pageName, pageConfig] of Object.entries(siteConfig.pages)) { | ||
test(`${siteName} - ${pageName}`, async ({ page }) => { | ||
const testUrls = { | ||
github: { | ||
pr: 'https://github.com/microsoft/playwright/pull/20635', | ||
issue: 'https://github.com/microsoft/playwright/issues/20636', | ||
discussion: 'https://github.com/golang/go/discussions/61669', | ||
repo: 'https://github.com/microsoft/playwright', | ||
user: 'https://github.com/microsoft', | ||
release: 'https://github.com/microsoft/playwright/releases/tag/v1.32.3', | ||
commit: 'https://github.com/golang/go/commit/96d8ff00c2d6a88384863a656fb5e53716b614d3', | ||
}, | ||
instagram: { | ||
profile: 'https://www.instagram.com/jonfriesen/', | ||
}, | ||
} | ||
|
||
const testUrl = testUrls[siteName][pageName] | ||
await testPageConfig(page, testUrl, pageConfig) | ||
}) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import siteConfigs from './config' | ||
|
||
describe('GitHub URL pattern tests', () => { | ||
const testCases = [ | ||
{ page: 'pr', url: 'https://github.com/user/repo/pull/123', shouldMatch: true }, | ||
{ page: 'issue', url: 'https://github.com/user/repo/issues/456', shouldMatch: true }, | ||
{ page: 'discussion', url: 'https://github.com/user/repo/discussions/789', shouldMatch: true }, | ||
{ page: 'repo', url: 'https://github.com/user/repo', shouldMatch: true }, | ||
{ page: 'user', url: 'https://github.com/username', shouldMatch: true }, | ||
{ page: 'release', url: 'https://github.com/user/repo/releases/tag/v1.0.0', shouldMatch: true }, | ||
{ page: 'commit', url: 'https://github.com/user/repo/commit/1234567890123456789012345678901234567890', shouldMatch: true }, | ||
{ page: 'pr', url: 'https://github.com/user/repo', shouldMatch: false }, | ||
] | ||
|
||
test.each(testCases)('$page: $url should ${shouldMatch ? "match" : "not match"}', ({ page, url, shouldMatch }) => { | ||
const pattern = siteConfigs.github.pages[page].urlPattern | ||
if (shouldMatch) { | ||
expect(url).toMatch(pattern) | ||
} else { | ||
expect(url).not.toMatch(pattern) | ||
} | ||
}) | ||
}) | ||
|
||
describe('GitHub markdown generator tests', () => { | ||
const markdownTestCases = [ | ||
{ | ||
page: 'pr', | ||
info: { number: '#123', title: 'Add new feature' }, | ||
url: 'https://github.com/user/repo/pull/123', | ||
expected: '[#123: Add new feature](https://github.com/user/repo/pull/123)', | ||
}, | ||
{ | ||
page: 'issue', | ||
info: { number: '#456', title: 'Fix bug in login' }, | ||
url: 'https://github.com/user/repo/issues/456', | ||
expected: '[#456: Fix bug in login](https://github.com/user/repo/issues/456)', | ||
}, | ||
{ | ||
page: 'discussion', | ||
info: { number: '#789', title: 'Propose new architecture' }, | ||
url: 'https://github.com/user/repo/discussions/789', | ||
expected: '[#789: Propose new architecture](https://github.com/user/repo/discussions/789)', | ||
}, | ||
{ | ||
page: 'repo', | ||
info: { title: 'user/repo', description: 'A cool project' }, | ||
url: 'https://github.com/user/repo', | ||
expected: '[user/repo](https://github.com/user/repo) - A cool project', | ||
}, | ||
{ | ||
page: 'user', | ||
info: { name: 'John Doe', bio: 'Software Developer' }, | ||
url: 'https://github.com/johndoe', | ||
expected: '[John Doe](https://github.com/johndoe) - Software Developer', | ||
}, | ||
{ | ||
page: 'release', | ||
info: { title: 'v1.0.0: First Release', date: '2023-05-01T00:00:00Z' }, | ||
url: 'https://github.com/user/repo/releases/tag/v1.0.0', | ||
expected: '[v1.0.0: First Release](https://github.com/user/repo/releases/tag/v1.0.0) - Released on ' + new Date('2023-05-01T00:00:00Z').toLocaleDateString(), | ||
}, | ||
{ | ||
page: 'commit', | ||
info: { title: 'Update README.md', hash: '1234567890abcdef', author: 'John Doe', date: '2023-05-01T00:00:00Z' }, | ||
url: 'https://github.com/user/repo/commit/1234567890abcdef', | ||
expected: '[(1234567) - Update README.md](https://github.com/user/repo/commit/1234567890abcdef)\nBy John Doe on ' + new Date('2023-05-01T00:00:00Z').toLocaleString(), | ||
}, | ||
] | ||
|
||
test.each(markdownTestCases)('$page: should generate correct markdown', ({ page, info, url, expected }) => { | ||
const buildMarkdown = siteConfigs.github.pages[page].buildMarkdown | ||
expect(buildMarkdown(info, url)).toBe(expected) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import siteConfigs from './config' | ||
|
||
describe('Instagram URL pattern tests', () => { | ||
const testCases = [ | ||
{ page: 'profile', url: 'https://www.instagram.com/username/', shouldMatch: true }, | ||
{ page: 'profile', url: 'https://www.instagram.com/p/123456/', shouldMatch: false }, | ||
] | ||
|
||
test.each(testCases)('$page: $url should ${shouldMatch ? "match" : "not match"}', ({ page, url, shouldMatch }) => { | ||
const pattern = siteConfigs.instagram.pages[page].urlPattern | ||
if (shouldMatch) { | ||
expect(url).toMatch(pattern) | ||
} else { | ||
expect(url).not.toMatch(pattern) | ||
} | ||
}) | ||
}) | ||
|
||
describe('Instagram markdown generator tests', () => { | ||
const markdownTestCases = [ | ||
{ | ||
page: 'profile', | ||
info: { name: 'Travel Enthusiast' }, | ||
url: 'https://www.instagram.com/travelenthusiast/', | ||
expected: '[Travel Enthusiast](https://www.instagram.com/travelenthusiast/)', | ||
}, | ||
] | ||
|
||
test.each(markdownTestCases)('$page: should generate correct markdown', ({ page, info, url, expected }) => { | ||
const buildMarkdown = siteConfigs.instagram.pages[page].buildMarkdown | ||
expect(buildMarkdown(info, url)).toBe(expected) | ||
}) | ||
}) |
Oops, something went wrong.