Skip to content

Commit

Permalink
別のお届け先を設定するテスト追加
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Jan 20, 2025
1 parent d387af9 commit 1f3147a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
24 changes: 24 additions & 0 deletions e2e-tests/pages/mypage/delivery_addr.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Locator, Page } from '@playwright/test';
import { PersonalInputPage } from '../personal_input.page';

export class MypageDeliveryAddrPage {
readonly personalInputPage: PersonalInputPage;
readonly registerButton: Locator;

constructor(page: Page) {
this.personalInputPage = new PersonalInputPage(page);
this.registerButton = page.locator('[alt=登録する]');
}

async fill() {
await this.personalInputPage.fillName();
await this.personalInputPage.fillCompany();
await this.personalInputPage.fillAddress();
await this.personalInputPage.fillTel();
await this.personalInputPage.fillFax();
}

async register() {
await this.registerButton.click();
}
}
13 changes: 11 additions & 2 deletions e2e-tests/test/front_login/shopping.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test, expect } from '../../fixtures/mypage_login.fixture';
import { Page, request, APIRequestContext } from '@playwright/test';
import PlaywrightConfig from '../../../playwright.config';
import { MypageDeliveryAddrPage } from '../../pages/mypage/delivery_addr.page';

const url = '/products/detail.php?product_id=1';

Expand Down Expand Up @@ -32,12 +33,20 @@ test.describe.serial('購入フロー(ログイン)のテストをします', ()

// お届け先の指定をします
await expect(page.locator('h2.title')).toContainText('お届け先の指定');
const popupPromise = page.waitForEvent('popup');
await page.getByRole('link', { name: '新しいお届け先を追加する' }).click();
const popup = await popupPromise;
const mypageDeliveryAddrPage = new MypageDeliveryAddrPage(popup);
await mypageDeliveryAddrPage.fill();
await mypageDeliveryAddrPage.register();

await page.getByRole('row', { name: '追加登録住所' }).getByRole('radio').check();
await page.click('[alt=選択したお届け先に送る]');

// お支払い方法・お届け時間の指定をします
await page.click('text=代金引換');
await page.selectOption('select[name=deliv_date0]', { index: 2 });
await page.selectOption('select[name=deliv_time_id0]', { label: '午後' });
await page.selectOption('select[name^=deliv_date]', { index: 2 });
await page.selectOption('select[name^=deliv_time_id]', { label: '午後' });
await page.check('#point_on');
await page.fill('input[name=use_point]', '1');
await page.fill('textarea[name=message]', 'お問い合わせ');
Expand Down

0 comments on commit 1f3147a

Please sign in to comment.