Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,32 @@ jobs:
pattern: blob-report-*
merge-multiple: true

- name: Check if blob reports exist
id: check-blob-reports
run: |
if [ -d "all-blob-reports" ] && [ "$(ls -A all-blob-reports)" ]; then
echo "has-reports=true" >> "$GITHUB_OUTPUT"
else
echo "has-reports=false" >> "$GITHUB_OUTPUT"
mkdir -p all-blob-reports
fi

- name: Merge into HTML Report
if: steps.check-blob-reports.outputs.has-reports == 'true'
run: npx playwright merge-reports --reporter html ./all-blob-reports

- name: Merge into JSON Report
if: steps.check-blob-reports.outputs.has-reports == 'true'
run: npx playwright merge-reports --reporter json ./all-blob-reports > playwright-results.json

- uses: actions/upload-artifact@v6
if: steps.check-blob-reports.outputs.has-reports == 'true'
with:
name: playwright-report
path: playwright-report/

- uses: actions/upload-artifact@v6
if: steps.check-blob-reports.outputs.has-reports == 'true'
with:
name: playwright-results-json
path: playwright-results.json
Expand All @@ -152,6 +166,9 @@ jobs:
pattern: playwright-screenshots-*
merge-multiple: true

- name: Ensure screenshots directory exists
run: mkdir -p test/playwright/__screenshots__

- uses: actions/upload-artifact@v6
with:
name: playwright-screenshots
Expand All @@ -168,7 +185,7 @@ jobs:

- name: '[PR] Calculate if any shard failed to download master screenshots'
run: |
if grep -q "failure" master-screenshots-outcomes/*; then
if [ -d "master-screenshots-outcomes" ] && [ "$(ls -A master-screenshots-outcomes)" ] && grep -q "failure" master-screenshots-outcomes/* 2>/dev/null; then
echo "failure" > master-screenshots-outcome
else
echo "success" > master-screenshots-outcome
Expand All @@ -191,7 +208,12 @@ jobs:
merge-multiple: true

- name: Merge playwright output files
run: cat playwright-outputs/* > playwright-output
run: |
if [ -d "playwright-outputs" ] && [ "$(ls -A playwright-outputs)" ]; then
cat playwright-outputs/* > playwright-output
else
touch playwright-output
fi

- uses: actions/upload-artifact@v6
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ dictionaries/
/playwright-report/
/playwright/.cache/
/test/playwright/__screenshots__/
/.playwright-user-data/

ext/manifest.json

ext/lib/*
actionlint
Binary file added innocent_corpus.zip
Binary file not shown.
Binary file added jmdict_dutch.zip
Binary file not shown.
Binary file added jmdict_english.zip
Binary file not shown.
Binary file added jmdict_french.zip
Binary file not shown.
Binary file added jmdict_german.zip
Binary file not shown.
Binary file added jmdict_hungarian.zip
Binary file not shown.
Binary file added jmdict_russian.zip
Binary file not shown.
Binary file added jmdict_slovenian.zip
Binary file not shown.
Binary file added jmdict_spanish.zip
Binary file not shown.
Binary file added jmdict_swedish.zip
Binary file not shown.
Binary file added jmnedict.zip
Binary file not shown.
Binary file added kanjidic_english.zip
Binary file not shown.
Binary file added kanjidic_french.zip
Binary file not shown.
Binary file added kanjidic_portuguese.zip
Binary file not shown.
Binary file added kanjidic_spanish.zip
Binary file not shown.
Binary file added kanjium_pitch_accents.zip
Binary file not shown.
Binary file added kireicake.zip
Binary file not shown.
7 changes: 4 additions & 3 deletions test/playwright/playwright-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ export const test = base.extend({
// eslint-disable-next-line no-empty-pattern
context: async ({}, /** @type {(r: import('playwright').BrowserContext) => Promise<void>} */ use) => {
const pathToExtension = path.join(root, 'ext');
const context = await chromium.launchPersistentContext('', {
// Disabled: headless: false,
// Use a temp directory for user data
const userDataDir = path.join(root, '.playwright-user-data');
const context = await chromium.launchPersistentContext(userDataDir, {
headless: false, // Extensions don't work properly in headless mode
args: [
'--headless=new',
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,
],
Expand Down
17 changes: 15 additions & 2 deletions test/playwright/visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@

test.beforeEach(async ({context}) => {
// Wait for the on-install welcome.html tab to load, which becomes the foreground tab
const welcome = await context.waitForEvent('page');
await welcome.close(); // Close the welcome tab so our main tab becomes the foreground tab -- otherwise, the screenshot can hang
// Use a promise race to avoid hanging if the welcome page doesn't appear
try {
const welcome = await Promise.race([
context.waitForEvent('page'),
new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), 5000))
]);
await welcome.close(); // Close the welcome tab so our main tab becomes the foreground tab -- otherwise, the screenshot can hang
} catch (e) {
// If welcome page doesn't appear or already appeared, that's okay
console.log('Welcome page handling:', e.message);

Check failure on line 35 in test/playwright/visual.spec.js

View workflow job for this annotation

GitHub Actions / TypeScript (test)

'e' is of type 'unknown'.
}
});

test('welcome', async ({page, extensionId}) => {
Expand All @@ -34,6 +43,7 @@
await expect(page.getByText('Welcome to Yomitan!')).toBeVisible();

// Take a screenshot of the welcome page
await page.bringToFront();
await expect.soft(page).toHaveScreenshot('welcome-page.png');
});
test.describe('settings', () => {
Expand All @@ -48,6 +58,7 @@
const storage_locator = page.locator('.storage-use-finite >> xpath=..');

// Take a simple screenshot of the settings page
await page.bringToFront();
await expect.soft(page).toHaveScreenshot('settings-fresh.png', {mask: [storage_locator]});

// Load in jmdict_english.zip
Expand All @@ -56,6 +67,7 @@
await expect(page.locator('id=dictionaries')).toHaveText('Dictionaries (1 installed, 1 enabled)', {timeout: 5 * 60 * 1000});

// Take a screenshot of the settings page with jmdict loaded
await page.bringToFront();
await expect.soft(page).toHaveScreenshot('settings-jmdict-loaded.png', {mask: [storage_locator]});
});
test('remote load and delete of jmdict_swedish', async ({page, extensionId}) => {
Expand Down Expand Up @@ -99,6 +111,7 @@
const storage_locator = page.locator('.storage-use-finite >> xpath=..');

// Take a full page screenshot of the settings page with advanced settings enabled
await page.bringToFront();
await expect.soft(page).toHaveScreenshot('settings-fresh-full-advanced.png', {
fullPage: true,
mask: [storage_locator],
Expand Down
Loading