Skip to content

Commit bfd8017

Browse files
yn1323claude
andcommitted
fix: E2E 互換性のため ShiftForm に tablist ロールを付与し POM を更新
- DateRail に role="tablist"/role="tab"/aria-selected を追加 - ViewTabs に role="tablist"/role="tab"/aria-selected を追加 - ConfirmButton のラベルを「確定して通知する」に合わせる - POM: switchDateTab/switchToOverview を新ロールで再実装、expectConfirmedStatus は first() で絞り込み - 一覧テーブル判定は hasText ベースに変更 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c6a6be1 commit bfd8017

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

e2e/pages/ShiftBoardPage.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ export class ShiftBoardPage {
1717
}
1818

1919
async switchDateTab(index: number) {
20-
const tabs = this.page.getByRole("tab");
21-
await tabs.nth(index).click();
20+
await this.page.getByRole("tablist", { name: "日付選択" }).getByRole("tab").nth(index).click();
2221
}
2322

2423
async switchToOverview() {
25-
// PC/SPで2つのSegmentGroupが存在するためlabelテキストをクリック
26-
await this.page.locator("[data-scope='segment-group'] [data-part='item-text']").getByText("一覧").first().click();
24+
await this.page.getByRole("tablist", { name: "ビュー切替" }).getByRole("tab", { name: "一覧" }).first().click();
2725
}
2826

2927
async confirm(staffCount: number) {
@@ -39,7 +37,7 @@ export class ShiftBoardPage {
3937
}
4038

4139
async expectConfirmedStatus() {
42-
await expect(this.page.getByText(//)).toBeVisible();
40+
await expect(this.page.getByText(//).first()).toBeVisible();
4341
}
4442

4543
async expectResendButton() {

e2e/scenarios/first-shift-delivery.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,9 @@ test.describe("田中さんの初めてのシフト確定", () => {
128128

129129
await test.step("Step 7: 一覧ビューで最終確認する", async () => {
130130
await shiftBoard.switchToOverview();
131-
// daily/overviewのテーブルが両方DOMにあるため、visible なテーブルを対象
132-
const table = page.locator("table").filter({ has: page.getByRole("button", { name: // }) });
131+
const table = page.locator("table").filter({ hasText: "田中太郎" }).first();
133132
await expect(table).toBeVisible();
134-
await expect(table.getByText(/\d{1,2}:\d{2}-\d{1,2}:\d{2}/).first()).toBeVisible();
133+
await expect(table.getByText(/\d{1,2}:\d{2}.\d{1,2}:\d{2}/).first()).toBeVisible();
135134
});
136135

137136
await test.step("Step 8: シフトを確定して通知する", async () => {

src/components/features/Shift/ShiftForm/components.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ export const ViewTabs = ({ value, onChange }: { value: ViewMode; onChange: (v: V
2929
{ k: "overview", label: "一覧" },
3030
];
3131
return (
32-
<Flex gap={0}>
32+
<Flex gap={0} role="tablist" aria-label="ビュー切替">
3333
{tabs.map((t) => {
3434
const active = value === t.k;
3535
return (
3636
<Box
3737
key={t.k}
38+
role="tab"
39+
aria-selected={active}
3840
onClick={() => onChange(t.k)}
3941
cursor="pointer"
4042
py="10px"
@@ -168,7 +170,7 @@ type ConfirmButtonProps = {
168170
};
169171

170172
export const ConfirmButton = ({ compact = false, isConfirmed = false, onClick }: ConfirmButtonProps) => {
171-
const label = compact ? (isConfirmed ? "再通知" : "確定") : isConfirmed ? "再通知する" : "確定して通知";
173+
const label = compact ? (isConfirmed ? "再通知" : "確定") : isConfirmed ? "再通知する" : "確定して通知する";
172174
return (
173175
<button
174176
type="button"

src/components/features/Shift/ShiftForm/pc/DailyView/DateRail.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,27 @@ const dayColor = (dateStr: string, holidays: string[]): string => {
1717
};
1818

1919
export const DateRail = ({ dates, selectedDate, onSelect, holidays = [] }: Props) => (
20-
<Box w="80px" h="100%" borderRightWidth="1px" borderColor="gray.200" bg="white" py={2} flexShrink={0} overflow="auto">
20+
<Box
21+
w="80px"
22+
h="100%"
23+
borderRightWidth="1px"
24+
borderColor="gray.200"
25+
bg="white"
26+
py={2}
27+
flexShrink={0}
28+
overflow="auto"
29+
role="tablist"
30+
aria-label="日付選択"
31+
>
2132
<Stack gap={1} px={2}>
2233
{dates.map((iso) => {
2334
const d = dayjs(iso);
2435
const active = iso === selectedDate;
2536
return (
2637
<Box
2738
key={iso}
39+
role="tab"
40+
aria-selected={active}
2841
onClick={() => onSelect(iso)}
2942
cursor="pointer"
3043
py="6px"

0 commit comments

Comments
 (0)