Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions e2e/help-screenshots.capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,35 @@ test("ヘルプのスクリーンショットを撮る", async ({ page, browser
await allowHousehold(page);
await capture(page, "api-token-new");

// カレンダー連携。発行した URL のダイアログを撮る
await page.goto("/settings/calendar");
const issueCalendarButton = page.getByRole("button", {
name: "URL を発行する",
});
const issuedDialog = page.getByRole("dialog", { name: "URL を発行しました" });
// ハイドレーションの前に押すと発行されないため、ダイアログが開くまで押し直す
await expect(async () => {
if (await issueCalendarButton.isVisible()) {
await issueCalendarButton.click();
}
await expect(issuedDialog).toBeVisible({ timeout: 2_000 });
}).toPass();
// URL は発行のたびに変わり、撮影した環境のオリジンも写るため、見本の URL に置き換えて撮る。
// 撮影の前にフォーカスを外すと入力欄が描き直されて元の URL に戻るため、先に外しておく
await page.evaluate(() => {
if (document.activeElement instanceof HTMLElement) {
document.activeElement.blur();
}
});
await issuedDialog
.getByRole("textbox", { name: "カレンダーの URL" })
.evaluate((element: HTMLInputElement) => {
element.value =
"https://canshi.app/calendar/Q2FsZW5kYXJGZWVkVG9rZW5FeGFtcGxl.ics";
});
await capture(page, "calendar-feed-issued");
await issuedDialog.getByRole("button", { name: "閉じる" }).click();

await captureInquiry(page);

// 通知。next dev では Service Worker を登録しないため、通知の設定の確認が終わるよう自分で登録する
Expand Down
128 changes: 128 additions & 0 deletions e2e/vrt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,134 @@ test.describe("APIトークン", () => {
});
});

// 未発行・発行したダイアログ・発行済みを順に撮るため直列にし、最後に停止して未発行に戻す
test.describe("カレンダー連携", () => {
test.describe.configure({ mode: "serial" });

const issueButton = (page: Page) =>
page.getByRole("button", { name: "URL を発行する" });

/**
* 発行日時・最後に読んだ日時は撮るたびに変わるため、固定の値に置き換える。ダイアログの後ろにも
* 写るため、マスク(ダイアログの上にも塗られる)ではなく文字を置き換える
*/
async function fixFeedDates(page: Page) {
// ハイドレーションの前に置き換えると React が描き直して元に戻すため、読み込みが落ち着いてから置き換える
await page.waitForLoadState("networkidle");
const dates = page.locator('[class*="details"] dd');
await dates.evaluateAll((elements) =>
elements.forEach((element) => {
element.textContent = "2026-12-04 12:00";
}),
);
await expect(dates).toHaveText(["2026-12-04 12:00", "2026-12-04 12:00"]);
}

/** 発行済みなら停止して、未発行に戻す(前の実行が途中で止まったときのため) */
async function stopIfIssued(page: Page) {
const stopButton = page.getByRole("button", { name: "停止する" });
const stopDialog = page.getByRole("dialog", {
name: "カレンダーとの連携を停止しますか?",
});
await expect(issueButton(page).or(stopButton)).toBeVisible();
if (await issueButton(page).isVisible()) {
return;
}
await expect(async () => {
if (!(await stopDialog.isVisible())) {
await stopButton.click();
}
await expect(stopDialog).toBeVisible({ timeout: 1_000 });
}).toPass();
await stopDialog.getByRole("button", { name: "停止する" }).click();
await expect(issueButton(page)).toBeVisible();
}

test("カレンダー連携ページ(未発行)の見た目", async ({ page }, testInfo) => {
await page.goto("/settings/calendar");
await expect(
page.getByRole("heading", { level: 1, name: "カレンダー連携" }),
).toBeVisible();
await stopIfIssued(page);
await takeSnapshot(page, testInfo);
});

test("発行したカレンダーの URL のダイアログの見た目", async ({
page,
}, testInfo) => {
await page.goto("/settings/calendar");
await stopIfIssued(page);
const dialog = page.getByRole("dialog", { name: "URL を発行しました" });
// ハイドレーションの前に押すと発行されないため、ダイアログが開くまで押し直す
await expect(async () => {
if (await issueButton(page).isVisible()) {
await issueButton(page).click();
}
await expect(dialog).toBeVisible({ timeout: 2_000 });
}).toPass();
const urlField = dialog.getByRole("textbox", { name: "カレンダーの URL" });
await expect(urlField).toHaveValue(/\/calendar\/[A-Za-z0-9_-]{43}\.ics$/);

// URL は発行のたびに変わるため、固定の値に置き換えて撮る
await urlField.evaluate((element: HTMLInputElement) => {
element.value = "https://canshi.app/calendar/vrt-calendar-feed-token.ics";
});
// 発行すると、ダイアログの後ろのページが発行済みの表示に変わる
await expect(
page.getByRole("button", { name: "URL を作り直す" }),
).toBeVisible();
Comment thread
cateiru marked this conversation as resolved.
Resolved
await fixFeedDates(page);
await takeSnapshot(page, testInfo, { fullPage: false });
await dialog.getByRole("button", { name: "閉じる" }).click();
});

test("カレンダー連携ページ(発行済み)の見た目", async ({
page,
}, testInfo) => {
await page.goto("/settings/calendar");
await expect(
page.getByRole("button", { name: "URL を作り直す" }),
).toBeVisible();
await fixFeedDates(page);
await takeSnapshot(page, testInfo);
});

test("カレンダーの URL の作り直しのダイアログの見た目", async ({
page,
}, testInfo) => {
await page.goto("/settings/calendar");
const dialog = page.getByRole("dialog", { name: "URL を作り直しますか?" });
await expect(async () => {
if (!(await dialog.isVisible())) {
await page.getByRole("button", { name: "URL を作り直す" }).click();
}
await expect(dialog).toBeVisible({ timeout: 1_000 });
}).toPass();
await fixFeedDates(page);
await takeSnapshot(page, testInfo, { fullPage: false });
});

test("カレンダー連携の停止のダイアログの見た目", async ({
page,
}, testInfo) => {
await page.goto("/settings/calendar");
const dialog = page.getByRole("dialog", {
name: "カレンダーとの連携を停止しますか?",
});
await expect(async () => {
if (!(await dialog.isVisible())) {
await page.getByRole("button", { name: "停止する" }).click();
}
await expect(dialog).toBeVisible({ timeout: 1_000 });
}).toPass();
await fixFeedDates(page);
await takeSnapshot(page, testInfo, { fullPage: false });
// 未発行に戻す
await dialog.getByRole("button", { name: "停止する" }).click();
await expect(issueButton(page)).toBeVisible();
});
});

test("AIとの接続ページの見た目", async ({ page }, testInfo) => {
await page.goto("/settings/ai-connections");
await expect(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "canshi",
"version": "0.89.4",
"version": "0.90.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
27 changes: 27 additions & 0 deletions packages/shared/src/ui/RecordIcons/RecordIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,33 @@ export function ApiTokenIcon(props: RecordIconProps) {
);
}

export function CalendarFeedIcon(props: RecordIconProps) {
const page =
"M5 5h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2Z";
const header = "M5 5h14a2 2 0 0 1 2 2v3H3V7a2 2 0 0 1 2-2Z";

return (
<RecordIcon
{...props}
fills={
<>
<path fill="#fff4df" d={page} />
<path fill="#f4b0a3" d={header} />
</>
}
>
<path d={page} />
<path d="M3 10h18" />
{/* 綴じ具は上の端から背景にはみ出す */}
<path className={styles.line} d="M8 3v4m8-4v4" />
<path
d="M7.5 14h.01m4.5 0h.01m4.5 0h.01m-9 3.5h.01m4.5 0h.01"
strokeWidth="2"
/>
</RecordIcon>
);
}

export function InquiryIcon(props: RecordIconProps) {
const envelope =
"M4.5 5h15A1.5 1.5 0 0 1 21 6.5v11a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 17.5v-11A1.5 1.5 0 0 1 4.5 5Z";
Expand Down
Binary file added public/images/help/calendar-feed-issued.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
135 changes: 135 additions & 0 deletions src/app/help/calendar/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import type { Metadata } from "next";
import { HelpArticle } from "@/features/help/HelpArticle";
import styles from "@/features/help/HelpContent.module.css";
import { HelpSteps } from "@/features/help/HelpSteps";
import { getHelpTopic } from "@/features/help/topics";
import { Surface } from "@/features/shared/Surface";

const SLUG = "calendar";

export const metadata: Metadata = {
title: getHelpTopic(SLUG).title,
};

export default function CalendarHelpPage() {
return (
<HelpArticle
slug={SLUG}
lead={
<p>
Google カレンダーや iPhone
のカレンダーなど、ふだん使っているカレンダーアプリに、ねこの掃除・通院・服薬の予定と誕生日を表示できます。CANSHI
で発行した URL を、カレンダーアプリに「URL
で追加するカレンダー」として登録します。
</p>
}
related={["notifications", "records"]}
>
<Surface title="連携のしかた" gap="md">
<HelpSteps
steps={[
{
title: "カレンダーの URL を発行します",
body: (
<>
<p>
設定の「外部接続」の「カレンダー連携」を開き、「URL
を発行する」を押します。表示された URL
を「コピーする」でコピーします。
</p>
<p>
URL
は、発行したときだけ表示します。画面を閉じる前に、カレンダーアプリに登録してください。
</p>
</>
),
screenshot: {
name: "calendar-feed-issued",
alt: "カレンダー連携の画面で URL を発行したところ。カレンダーの URL とコピーするボタンが表示されている",
},
},
{
title: "カレンダーアプリに URL を登録します",
body: (
<>
<p>
カレンダーアプリの、URL
でカレンダーを追加する(照会・購読する)画面に、コピーした
URL を貼り付けます。たとえば次の場所から追加できます。
</p>
<ul className={styles.points}>
<li>
Google カレンダー:パソコンのブラウザで Google
カレンダーを開き、「他のカレンダー」の「+」から「URL
で追加」を選びます(スマートフォンのアプリからは追加できません)。
</li>
<li>
iPhone・iPad
のカレンダー:カレンダーアプリの「カレンダー」から「カレンダーを追加」の「照会カレンダーを追加」を選びます。
</li>
<li>
Mac
のカレンダー:「ファイル」メニューの「新規照会カレンダー」を選びます。
</li>
</ul>
<p>
画面の場所や名前は、カレンダーアプリやそのバージョンによって異なります。くわしくは、お使いのカレンダーアプリのヘルプを見てください。
</p>
</>
),
},
{
title: "カレンダーアプリに、ねこの予定が表示されます",
body: (
<p>
予定を開くと、CANSHI
の記録のページへのリンクがあります。記録を変えてから予定に反映されるまでの時間は、カレンダーアプリが
URL を読み直す間隔によります(数時間かかることもあります)。
</p>
),
},
]}
/>
</Surface>

<Surface title="表示する予定" gap="md">
<p>
あなたが所属しているすべての家のねこの、次の予定を表示します。メモリーに移したねこの予定は表示しません。
</p>
<ul className={styles.points}>
<li>
掃除:次回の予定日。一度も記録していない掃除や、無効にした掃除は表示しません。掃除を記録すると、次の予定日に移ります。
</li>
<li>通院:通院記録に入れた、今日以降の次回の受診予定。</li>
<li>服薬:服用中の薬の、開始日から終了予定日まで。</li>
<li>誕生日:生年月日を日まで登録したねこの誕生日(毎年)。</li>
</ul>
<p>
カレンダーアプリに表示するのは、ねこの名前と予定の名前だけです。通院の理由などのくわしい記録は表示しません。
</p>
</Surface>

<Surface title="URL を管理する" gap="md">
<ul className={styles.points}>
<li>
URL
を知っている人は、だれでもねこの予定を見られます。ほかの人に見せないでください。
</li>
<li>
URL
がわからなくなったときや、漏れたおそれのあるときは、「カレンダー連携」の「URL
を作り直す」を押してください。今の URL は使えなくなるので、新しい
URL を登録し直してください。
</li>
<li>
連携をやめるときは「停止する」を押し、カレンダーアプリからも購読を削除してください。カレンダーアプリにすでに表示されている予定は、アプリで削除するまで残ることがあります。
</li>
<li>
「カレンダー連携」では、カレンダーアプリが最後に URL
を読んだ日時を確認できます。
</li>
</ul>
</Surface>
</HelpArticle>
);
}
Loading
Loading