Skip to content
Open
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ node_modules
/coverage/
playwright/.auth
/actions-runner/
nohup.out
nohup.out
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
39 changes: 24 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
"seed": "tsx prisma/seed.ts"
},
"devDependencies": {
"@playwright/test": "^1.38.0",
"@playwright/test": "^1.40.0",
"@sveltejs/adapter-node": "^1.3.1",
"@sveltejs/kit": "^1.25.0",
"@types/express": "^4.17.17",
"@types/glob": "^8.1.0",
"@types/imap-simple": "^4.2.6",
"@types/morgan": "^1.9.5",
"@types/node": "^20.9.3",
"@types/nodemailer": "^6.4.10",
"@types/nprogress": "^0.2.0",
"@types/prettier": "^2.7.3",
Expand Down
129 changes: 14 additions & 115 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,25 @@
import type { PlaywrightTestConfig } from '@playwright/test'
import { devices } from '@playwright/test'
import dotenv from 'dotenv'
import { PlaywrightTestConfig, devices } from '@playwright/test'

dotenv.config()

const base = ''
// const base = '/talk'

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
testDir: './e2e',
/* Maximum time one test can run for. */
timeout: process.env.CI ? 20 * 1000 : 10 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 3000,
webServer: {
command: 'npm run dev',
port: 5173,
reuseExistingServer: !process.env.CI,
},
/* Run tests in files in parallel */
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: 0,
retries: process.env.CI ? 1 : 0,
/* Opt out of parallel tests on CI. */
// workers: undefined,
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [['html', { open: 'never' }]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
// webServer: {
// command: 'npm run build && npm run preview',
// port: 4173,
// },
testDir: 'tests',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この行を次のようにする必要があると思います:

	testDir: 'e2e',

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Acha0203 修正いたしました。

testMatch: /(.+\.)?(test|spec)\.[jt]s/,

reporter: 'html',
use: {
baseURL: `http://127.0.0.1:5173${base}/`,

/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://localhost:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',

// headless: false,
video: 'retain-on-failure',

contextOptions: {
permissions: ['clipboard-read', 'clipboard-write', 'accessibility-events'],
},
},

/* Configure projects for major browsers */
projects: [
{ name: 'setup', testMatch: /[^.]{1,100}\.setup\.ts/ },
{ name: 'setup', testMatch: /.*\.setup\.ts/ },

{
name: 'chromium',
Expand All @@ -70,65 +28,6 @@ const config: PlaywrightTestConfig = {
},
dependencies: ['setup'],
},

// {
// name: 'firefox',
// use: {
// ...devices['Desktop Firefox'],
// },
// },

// {
// name: 'webkit',
// use: {
// ...devices['Desktop Safari'],
// },
// },

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: {
// ...devices['Pixel 5'],
// },
// },
// {
// name: 'Mobile Safari',
// use: {
// ...devices['iPhone 12'],
// },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: {
// channel: 'msedge',
// },
// },
// {
// name: 'Google Chrome',
// use: {
// channel: 'chrome',
// },
// },
],

/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',

/* Run your local dev server before starting the tests */
webServer: [
{
command: 'npm run dev',
url: `http://127.0.0.1:5173${base}/`,
reuseExistingServer: !process.env.CI,
},
// {
// command: 'npm run build && npm run preview',
// port: 4173,
// reuseExistingServer: !process.env.CI,
// },
],
}

Expand Down
File renamed without changes.
26 changes: 2 additions & 24 deletions e2e/auth.setup.ts → tests/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
import { expect, test as setup } from '@playwright/test'
import { PrismaClient } from '@prisma/client'
// import { promises as fs } from 'fs'
// import { sleep } from '../src/lib/general/system.js'
// import { get_pin_code_from_mail } from './lib/get_pin_code_from_mail.js'
import { auth_file_path } from './lib/setup.js'

// async function find_auth_file(): Promise<boolean> {
// try {
// await fs.access(auth_file_path, fs.constants.F_OK)
// return true
// } catch {
// return false
// }
// }

// async function get_pin_code_from_mail(): Promise<string> {
// await sleep(process.env.CI ? 5000 : 1000)
// const pin_code = await get_pin_code_from_mail()
// expect(pin_code).toMatch(/^\d{6}$/)

// return pin_code
// }

async function get_pin_code_from_database(gmail_user: string): Promise<string> {
const prisma_client = new PrismaClient()

Expand All @@ -36,13 +16,11 @@ async function get_pin_code_from_database(gmail_user: string): Promise<string> {
}

setup('sign in', async ({ page }) => {
// if (await find_auth_file()) return
if (process.env['CI']) return

await page.goto('./sign-in', { waitUntil: 'networkidle' })

const gmail_user = process.env.GMAIL_USER ?? ''

// expect(gmail_user).toEqual('iam.o.sin@gmail.com')
const gmail_user = process.env['GMAIL_USER'] ?? ''

await page.getByPlaceholder('Enter email').fill(gmail_user)
await page.getByRole('button', { name: 'Continue' }).click()
Expand Down
Loading