gradio/js/app/test/datetimes.spec.ts
aliabid94 e3c7079e38
gr.DateTime component (#8713)
* changes

* changes

* add changeset

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* Update gradio/components/datetime.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* changes

* changes

---------

Co-authored-by: Ali Abid <aliabid94@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
2024-07-10 20:55:45 -07:00

54 lines
2.1 KiB
TypeScript

import { test, expect } from "@gradio/tootils";
test("gr.DateTime shows correct values", async ({ page }) => {
await page.locator("#date1").getByRole("textbox").first().click();
await page
.locator("#date1")
.getByRole("textbox")
.first()
.fill("2020-10-01 10:50:00");
await page.locator("body").first().click();
await expect(page.getByLabel("Last Change")).toHaveValue(
"2020-10-01 10:50:00"
);
await expect(page.getByLabel("Last Submit")).toHaveValue("");
await page.locator("#date1").getByRole("textbox").first().press("Enter");
await expect(page.getByLabel("Last Submit")).toHaveValue(
"2020-10-01 10:50:00"
);
await expect(page.getByLabel("Last Load")).toHaveValue("");
await page.locator("#date2").getByRole("textbox").first().click();
await page.locator("#date2").getByRole("textbox").first().fill("2000-02-22");
await page.locator("body").first().click();
await expect(page.getByLabel("Last Change")).toHaveValue("2000-02-22");
await page.getByRole("button", { name: "Load Date 1" }).click();
await expect(page.getByLabel("Last Load")).toHaveValue("2020-10-01 10:50:00");
await page.getByRole("button", { name: "Load Date 2" }).click();
await expect(page.getByLabel("Last Load")).toHaveValue("2000-02-22");
await page.locator("#date2").getByRole("textbox").first().click();
await page
.locator("#date2")
.getByRole("textbox")
.first()
.fill("2020-05-01xxx");
await page.locator("body").first().click();
await expect(page.getByLabel("Last Change")).toHaveValue("2000-02-22");
await page.locator("#date2").getByRole("textbox").first().click();
await page.locator("#date2").getByRole("textbox").first().fill("2020-05-02");
await page.locator("body").first().click();
await expect(page.getByLabel("Last Change")).toHaveValue("2020-05-02");
await page.locator("#date3").getByRole("textbox").first().click();
await page
.locator("#date3")
.getByRole("textbox")
.first()
.fill("2020-10-10 05:01:01");
await page.getByRole("button", { name: "Load Date 3" }).click();
await expect(page.getByLabel("Last Load")).toHaveValue("1602298861.0");
});