feat: Establish Playwright testing infrastructure with initial tests for authentication, admin, and instructor modules, and fix instructor video and quiz lesson management pages.
All checks were successful
Build and Deploy Frontend Management to Dev Server / Build Frontend Management Docker Image (push) Successful in 1m17s
Build and Deploy Frontend Management to Dev Server / Deploy E-learning Frontend Management to Dev Server (push) Successful in 8s
Build and Deploy Frontend Management to Dev Server / Notify Deployment Status (push) Successful in 2s
All checks were successful
Build and Deploy Frontend Management to Dev Server / Build Frontend Management Docker Image (push) Successful in 1m17s
Build and Deploy Frontend Management to Dev Server / Deploy E-learning Frontend Management to Dev Server (push) Successful in 8s
Build and Deploy Frontend Management to Dev Server / Notify Deployment Status (push) Successful in 2s
This commit is contained in:
parent
734d922393
commit
9bc24fbe8a
18 changed files with 1344 additions and 7 deletions
93
frontend_management/playwright.config.ts
Normal file
93
frontend_management/playwright.config.ts
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
import { defineConfig, devices } from '@playwright/test';
|
||||
import { fileURLToPath } from 'url';
|
||||
import path from 'path';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
// import dotenv from 'dotenv';
|
||||
// import path from 'path';
|
||||
// dotenv.config({ path: path.resolve(__dirname, '.env') });
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: './tests',
|
||||
/* Run tests in files in parallel */
|
||||
timeout: 60000, // timeout ต่อ test (ms)
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: !!process.env.CI,
|
||||
/* Retry on CI only */
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
// workers: process.env.CI ? 1 : undefined,
|
||||
workers: 1,
|
||||
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: 'html',
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
baseURL: 'http://localhost:3000/',// ปรับเป็น URL ที่ทดสอบ
|
||||
headless: false, // false = เห็น browser ขณะรัน
|
||||
screenshot: 'only-on-failure', // เก็บ screenshot เมื่อ fail
|
||||
trace: 'retain-on-failure', // เก็บ trace เพื่อดีบักเมื่อ fail
|
||||
// launchOptions: {
|
||||
// slowMo: 1000,
|
||||
// }, // ช้าลง 10 วินาที
|
||||
},
|
||||
|
||||
/* ──── Setup Projects: login ครั้งเดียว แล้ว save cookies ──── */
|
||||
projects: [
|
||||
{
|
||||
name: 'admin-setup',
|
||||
testMatch: /admin\.setup\.ts/,
|
||||
testDir: './tests',
|
||||
},
|
||||
{
|
||||
name: 'instructor-setup',
|
||||
testMatch: /instructor\.setup\.ts/,
|
||||
testDir: './tests',
|
||||
},
|
||||
|
||||
/* ──── Auth tests: ไม่ต้อง login ก่อน ──── */
|
||||
{
|
||||
name: 'auth-tests',
|
||||
testDir: './tests/auth',
|
||||
use: { ...devices['Desktop Chrome'] },
|
||||
},
|
||||
|
||||
/* ──── Admin tests: ใช้ cookies จาก admin-setup ──── */
|
||||
{
|
||||
name: 'admin-tests',
|
||||
testDir: './tests/admin',
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
storageState: path.resolve(__dirname, 'tests/.auth/admin.json'),
|
||||
},
|
||||
dependencies: ['admin-setup'],
|
||||
},
|
||||
|
||||
/* ──── Instructor tests: ใช้ cookies จาก instructor-setup ──── */
|
||||
{
|
||||
name: 'instructor-tests',
|
||||
testDir: './tests/instructor',
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
storageState: path.resolve(__dirname, 'tests/.auth/instructor.json'),
|
||||
},
|
||||
dependencies: ['instructor-setup'],
|
||||
},
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
// webServer: {
|
||||
// command: 'npm run start',
|
||||
// url: 'http://localhost:3000',
|
||||
// reuseExistingServer: !process.env.CI,
|
||||
// },
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue