-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/npm_and_yarn/tar-6.2.1
- Loading branch information
Showing
40 changed files
with
679 additions
and
533 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
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
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
export const ADMIN_DIR = process.env.ADMIN_DIR ? process.env.ADMIN_DIR : 'admin/'; | ||
export const ECCUBE_ADMIN_USER = process.env.ECCUBE_ADMIN_USER ? process.env.ECCUBE_ADMIN_USER : 'admin'; | ||
export const ECCUBE_ADMIN_PASS = process.env.ECCUBE_ADMIN_PASS ? process.env.ECCUBE_ADMIN_PASS : 'password'; | ||
export const ECCUBE_DEFAULT_USER = process.env.ECCUBE_DEFAULT_USER ? process.env.ECCUBE_DEFAULT_USER : 'zap_user@example.com'; | ||
export const ECCUBE_DEFAULT_PASS = process.env.ECCUBE_DEFAULT_PASS ? process.env.ECCUBE_DEFAULT_PASS : 'password'; |
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 { test as base, expect } from "@playwright/test"; | ||
import { AdminLoginPage } from "../pages/admin/login.page"; | ||
import { Mode, ContextType } from '../utils/ZapClient'; | ||
import { ECCUBE_ADMIN_USER, ECCUBE_ADMIN_PASS, ADMIN_DIR } from "../config/default.config"; | ||
import PlaywrightConfig from '../../playwright.config'; | ||
|
||
type LoginFixtures = { | ||
loginPage: AdminLoginPage; | ||
}; | ||
|
||
export const test = base.extend<LoginFixtures>({ | ||
loginPage: async ({ page }, use) => { | ||
const loginPage = new AdminLoginPage(page); | ||
if (PlaywrightConfig.use?.proxy === undefined) { | ||
await page.goto(`/${ ADMIN_DIR }`); | ||
await loginPage.login(ECCUBE_ADMIN_USER, ECCUBE_ADMIN_PASS); | ||
} else { | ||
const zapClient = loginPage.getZapClient(); | ||
await zapClient.setMode(Mode.Protect); | ||
await zapClient.newSession('/zap/wrk/sessions/admin', true); | ||
await zapClient.importContext(ContextType.Admin); | ||
|
||
if (!await zapClient.isForcedUserModeEnabled()) { | ||
await zapClient.setForcedUserModeEnabled(); | ||
expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy(); | ||
} | ||
await page.goto(`/${ ADMIN_DIR }home.php`); | ||
} | ||
await use(loginPage); | ||
} | ||
}); | ||
|
||
export { expect } from "@playwright/test"; |
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,29 @@ | ||
import { test as base, expect } from "@playwright/test"; | ||
import { MypageLoginPage } from "../pages/mypage/login.page"; | ||
import { Mode, ContextType } from '../utils/ZapClient'; | ||
import { ECCUBE_DEFAULT_USER, ECCUBE_DEFAULT_PASS } from "../config/default.config"; | ||
import PlaywrightConfig from '../../playwright.config'; | ||
|
||
export const test = base.extend({ | ||
page: async ({ page }, use) => { | ||
const loginPage = new MypageLoginPage(page); | ||
if (PlaywrightConfig.use?.proxy === undefined) { | ||
await loginPage.goto(); | ||
await loginPage.login(ECCUBE_DEFAULT_USER, ECCUBE_DEFAULT_PASS); | ||
} else { | ||
const zapClient = loginPage.getZapClient(); | ||
await zapClient.setMode(Mode.Protect); | ||
await zapClient.newSession('/zap/wrk/sessions/front_login', true); | ||
await zapClient.importContext(ContextType.FrontLogin); | ||
|
||
if (!await zapClient.isForcedUserModeEnabled()) { | ||
await zapClient.setForcedUserModeEnabled(); | ||
expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy(); | ||
} | ||
await page.goto(`/mypage/index.php`); | ||
} | ||
use(page); | ||
} | ||
}); | ||
|
||
export { expect } from "@playwright/test"; |
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,41 @@ | ||
import { Locator, Page } from "@playwright/test"; | ||
import { ADMIN_DIR } from "../../config/default.config"; | ||
import { ZapClient } from '../../utils/ZapClient'; | ||
|
||
export class AdminLoginPage { | ||
readonly page: Page; | ||
readonly url: string; | ||
|
||
readonly loginId: Locator; | ||
readonly password: Locator; | ||
readonly loginButton: Locator; | ||
zapClient: ZapClient; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.url = `/${ ADMIN_DIR }index.php`; | ||
|
||
this.loginId = page.locator('input[name=login_id]'); | ||
this.password = page.locator('input[name=password]'); | ||
this.loginButton = page.getByRole('link', { name: 'LOGIN' }); | ||
this.zapClient = new ZapClient(); | ||
} | ||
|
||
async goto() { | ||
await this.page.goto(this.url); | ||
} | ||
|
||
async login(loginId: string, password: string) { | ||
await this.loginId.fill(loginId); | ||
await this.password.fill(password); | ||
await this.loginButton.click(); | ||
} | ||
|
||
async logout() { | ||
await this.page.goto(`/${ ADMIN_DIR }/logout.php`); | ||
} | ||
|
||
getZapClient() { | ||
return this.zapClient; | ||
} | ||
} |
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,90 @@ | ||
import { test, expect } from '../fixtures/mypage_login.fixture'; | ||
import { Locator, Page } from '@playwright/test'; | ||
import PlaywrightConfig from '../../playwright.config'; | ||
import { ZapClient } from '../utils/ZapClient'; | ||
|
||
export class ContactPage { | ||
readonly page: Page; | ||
readonly url: string; | ||
|
||
readonly confirmButton: Locator; | ||
readonly submitButton: Locator; | ||
readonly name01: Locator; | ||
readonly name02: Locator; | ||
readonly kana01: Locator; | ||
readonly kana02: Locator; | ||
readonly zip01: Locator; | ||
readonly zip02: Locator; | ||
readonly addr01: Locator; | ||
readonly addr02: Locator; | ||
readonly tel01: Locator; | ||
readonly tel02: Locator; | ||
readonly tel03: Locator; | ||
readonly email: Locator; | ||
readonly emailConfirm: Locator; | ||
readonly contents: Locator; | ||
zapClient: ZapClient; | ||
|
||
// 'name01', 'name02', 'kana01', 'kana02', 'zip01', 'zip02', 'addr01', 'addr02', 'tel01', 'tel02', 'tel03' | ||
constructor(page: Page) { | ||
this.page = page; | ||
this.url = `${ PlaywrightConfig.use?.baseURL ?? "" }/contact/index.php`; | ||
this.confirmButton = page.locator('input[name=confirm][alt=確認ページへ]'); | ||
this.submitButton = page.locator('input[name=send][alt=送信]'); | ||
this.name01 = page.locator('input[name=name01]'); | ||
this.name02 = page.locator('input[name=name02]'); | ||
this.kana01 = page.locator('input[name=kana01]'); | ||
this.kana02 = page.locator('input[name=kana02]'); | ||
this.zip01 = page.locator('input[name=zip01]'); | ||
this.zip02 = page.locator('input[name=zip02]'); | ||
this.addr01 = page.locator('input[name=addr01]'); | ||
this.addr02 = page.locator('input[name=addr02]'); | ||
this.tel01 = page.locator('input[name=tel01]'); | ||
this.tel02 = page.locator('input[name=tel02]'); | ||
this.tel03 = page.locator('input[name=tel03]'); | ||
this.email = page.locator('input[name=email]'); | ||
this.emailConfirm = page.locator('input[name=email_confirm]'); | ||
this.contents = page.locator('textarea[name=contents]'); | ||
this.zapClient = new ZapClient(); | ||
} | ||
|
||
async goto() { | ||
await this.page.goto(this.url); | ||
} | ||
|
||
async confirm() { | ||
await this.confirmButton.click(); | ||
} | ||
|
||
async submit() { | ||
await this.submitButton.click(); | ||
} | ||
|
||
async expectConfirmPage() { | ||
this.getInputFields().forEach(async (fieled) => { | ||
await expect(fieled).toBeHidden(); | ||
await expect(fieled).not.toBeEmpty(); | ||
}); | ||
} | ||
|
||
private getInputFields(): Locator[] { | ||
return [ | ||
this.name01, | ||
this.name02, | ||
this.kana01, | ||
this.kana02, | ||
this.zip01, | ||
this.zip02, | ||
this.addr01, | ||
this.addr02, | ||
this.tel01, | ||
this.tel02, | ||
this.tel03, | ||
this.email, | ||
this.emailConfirm | ||
]; | ||
} | ||
getZapClient() { | ||
return this.zapClient; | ||
} | ||
} |
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,43 @@ | ||
import { Locator, Page } from "@playwright/test"; | ||
import { ZapClient } from '../../utils/ZapClient'; | ||
|
||
export class MypageLoginPage { | ||
readonly page: Page; | ||
readonly url: string; | ||
|
||
readonly loginEmail: Locator; | ||
readonly loginPass: Locator; | ||
readonly loginButton: Locator; | ||
readonly logoutButton: Locator; | ||
zapClient: ZapClient; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.url = '/mypage/login.php'; | ||
|
||
this.loginEmail = page.getByRole('textbox', { name: 'メールアドレスを入力して下さい' }); | ||
this.loginPass = page.getByRole('textbox', { name: 'パスワードを入力して下さい' }); | ||
this.loginButton = page.locator('id=header_login_form').getByRole('button'); | ||
this.logoutButton = page.getByRole('button', { name: 'ログアウト' }).first(); | ||
this.zapClient = new ZapClient(); | ||
} | ||
|
||
async goto() { | ||
await this.page.goto(this.url); | ||
} | ||
|
||
async login(email: string, password: string) { | ||
await this.loginEmail.fill(email); | ||
await this.loginPass.fill(password); | ||
await this.loginButton.click(); | ||
} | ||
|
||
async logout() { | ||
await this.goto(); | ||
await this.logoutButton.click(); | ||
} | ||
|
||
getZapClient() { | ||
return this.zapClient; | ||
} | ||
} |
Oops, something went wrong.