add happy path test for booking an event (#1177)

This commit is contained in:
Alex Johansson 2021-11-15 16:03:04 +01:00 committed by GitHub
parent 6b171a6f87
commit 11269229ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 5 deletions

View file

@ -153,10 +153,11 @@ function DatePicker({
selectedMonth <= dayjs().month() && selectedMonth <= dayjs().month() &&
"text-gray-400 dark:text-gray-600" "text-gray-400 dark:text-gray-600"
)} )}
disabled={typeof selectedMonth === "number" && selectedMonth <= dayjs().month()}> disabled={typeof selectedMonth === "number" && selectedMonth <= dayjs().month()}
data-testid="decrementMonth">
<ChevronLeftIcon className="group-hover:text-black dark:group-hover:text-white w-5 h-5" /> <ChevronLeftIcon className="group-hover:text-black dark:group-hover:text-white w-5 h-5" />
</button> </button>
<button className="group p-1" onClick={incrementMonth}> <button className="group p-1" onClick={incrementMonth} data-testid="incrementMonth">
<ChevronRightIcon className="group-hover:text-black dark:group-hover:text-white w-5 h-5" /> <ChevronRightIcon className="group-hover:text-black dark:group-hover:text-white w-5 h-5" />
</button> </button>
</div> </div>

View file

@ -50,7 +50,7 @@ export default function User(props: inferSSRProps<typeof getServerSideProps>) {
className="group relative dark:bg-neutral-900 dark:border-0 dark:hover:border-neutral-600 bg-white hover:bg-gray-50 border border-neutral-200 hover:border-brand rounded-sm"> className="group relative dark:bg-neutral-900 dark:border-0 dark:hover:border-neutral-600 bg-white hover:bg-gray-50 border border-neutral-200 hover:border-brand rounded-sm">
<ArrowRightIcon className="absolute transition-opacity h-4 w-4 right-3 top-3 text-black dark:text-white opacity-0 group-hover:opacity-100" /> <ArrowRightIcon className="absolute transition-opacity h-4 w-4 right-3 top-3 text-black dark:text-white opacity-0 group-hover:opacity-100" />
<Link href={`/${user.username}/${type.slug}`}> <Link href={`/${user.username}/${type.slug}`}>
<a className="block px-6 py-4"> <a className="block px-6 py-4" data-testid="event-type-link">
<h2 className="font-semibold text-neutral-900 dark:text-white">{type.title}</h2> <h2 className="font-semibold text-neutral-900 dark:text-white">{type.title}</h2>
<EventTypeDescription eventType={type} /> <EventTypeDescription eventType={type} />
</a> </a>

View file

@ -3,7 +3,9 @@ import { kont } from "kont";
import { pageProvider } from "./lib/pageProvider"; import { pageProvider } from "./lib/pageProvider";
jest.setTimeout(60e3); jest.setTimeout(60e3);
if (process.env.CI) {
jest.retryTimes(3); jest.retryTimes(3);
}
describe("free user", () => { describe("free user", () => {
const ctx = kont() const ctx = kont()
@ -31,5 +33,26 @@ describe("pro user", () => {
expect($eventTypes.length).toBeGreaterThanOrEqual(2); expect($eventTypes.length).toBeGreaterThanOrEqual(2);
}); });
// TODO: make sure `/free/30min` is bookable and that `/free/60min` is not test("book an event first day in next month", async () => {
const { page } = ctx;
// Click first event type
await page.click('[data-testid="event-type-link"]');
// Click [data-testid="incrementMonth"]
await page.click('[data-testid="incrementMonth"]');
// Click [data-testid="day"]
await page.click('[data-testid="day"]');
// Click [data-testid="time"]
await page.click('[data-testid="time"]');
// --- fill form
await page.fill('[name="name"]', "Test Testson");
await page.fill('[name="email"]', "test@example.com");
await page.press('[name="email"]', "Enter");
// Make sure we're navigated to the success page
await page.waitForNavigation({
url(url) {
return url.pathname.endsWith("/success");
},
});
});
}); });