diff --git a/e2e/tests/smoke.spec.js b/e2e/tests/smoke.spec.js new file mode 100644 index 0000000000..a7514c4c74 --- /dev/null +++ b/e2e/tests/smoke.spec.js @@ -0,0 +1,24 @@ +const { test, expect } = require('@playwright/test'); + +test.describe('Editor Smoke Test', () => { + + test.beforeEach(async ({ page }) => { + await page.goto('/'); + await expect(page.locator('.CodeMirror')).toBeVisible({ timeout: 15000 }); + }); + + test('play button runs sketch', async ({ page }) => { + const playButton = page.locator('#play-sketch'); + + await expect(playButton).toBeVisible(); + await playButton.click({ force: true }); + + // wait for preview trigger + await page.waitForTimeout(2000); + + // ✅ ONLY reliable signal + const iframe = page.locator('iframe'); + await expect(iframe).toBeVisible(); + }); + +}); \ No newline at end of file diff --git a/package.json b/package.json index 2599c66f89..ebb7dc5a26 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,9 @@ "version": "2.20.6", "description": "The web editor for p5.js.", "scripts": { + "test:e2e": "playwright test", + "test:e2e:headed": "playwright test --headed", + "test:e2e:debug": "playwright test --debug", "clean": "rimraf dist", "start": "cross-env BABEL_DISABLE_CACHE=1 NODE_ENV=development nodemon index.js", "start:prod": "cross-env NODE_ENV=production node index.js", @@ -97,6 +100,7 @@ "url": "git+https://github.com/catarak/p5.js-web-editor.git" }, "devDependencies": { + "@playwright/test": "^1.45.0", "@babel/eslint-parser": "^7.17.0", "@babel/plugin-proposal-class-properties": "^7.14.5", "@babel/plugin-proposal-decorators": "^7.14.5", diff --git a/playwright.config.js b/playwright.config.js new file mode 100644 index 0000000000..41bd3aa53f --- /dev/null +++ b/playwright.config.js @@ -0,0 +1,25 @@ +const { defineConfig, devices } = require('@playwright/test'); + +module.exports = defineConfig({ + testDir: './e2e/tests', + + use: { + baseURL: process.env.BASE_URL || 'http://localhost:8000', + headless: true, + actionTimeout: 10000, + }, + + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + ], + + webServer: { + command: 'npm run start', + url: 'http://localhost:8000', + timeout: 120000, + reuseExistingServer: !process.env.CI, + }, +}); \ No newline at end of file diff --git a/test-results/.last-run.json b/test-results/.last-run.json new file mode 100644 index 0000000000..cbcc1fbac1 --- /dev/null +++ b/test-results/.last-run.json @@ -0,0 +1,4 @@ +{ + "status": "passed", + "failedTests": [] +} \ No newline at end of file