import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__ from "@tachybase/test/client";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo1_mjs__ from "../demos/demo1.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo2_mjs__ from "../demos/demo2.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo3_mjs__ from "../demos/demo3.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo4_mjs__ from "../demos/demo4.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo5_mjs__ from "../demos/demo5.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo6_mjs__ from "../demos/demo6.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo7_mjs__ from "../demos/demo7.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo8_mjs__ from "../demos/demo8.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo9_mjs__ from "../demos/demo9.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo11_mjs__ from "../demos/demo11.mjs";
describe('DatePicker', ()=>{
    it('basic', async ()=>{
        const { container, getByText } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo1_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const picker = container.querySelector('.ant-picker');
        const input = container.querySelector('input');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(picker);
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.type(input, '2023/05/01 00:00:00');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(getByText('OK'));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            expect(input).toHaveValue('2023/05/01 00:00:00');
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023/05/01 00:00:00', {
                selector: '.ant-description-date-picker'
            })).toBeInTheDocument();
            if (!process.env.GITHUB_ACTIONS) expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023-04-30T16:00:00.000Z')).toBeInTheDocument();
        });
    });
    it('GMT', async ()=>{
        const { container, getByText } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo2_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const picker = container.querySelector('.ant-picker');
        const input = container.querySelector('input');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(picker);
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.clear(input);
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.type(input, '2023/05/01 00:00:00');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(getByText('OK'));
        expect(input).toHaveValue('2023/05/01 00:00:00');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023/05/01 00:00:00', {
            selector: '.ant-description-date-picker'
        })).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023-05-01T00:00:00.000Z')).toBeInTheDocument();
    });
    it('non-UTC', async ()=>{
        const { container } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo3_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const picker = container.querySelector('.ant-picker');
        const input = container.querySelector('input');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(picker);
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.type(input, '2023/05/01');
        let selected;
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            selected = document.querySelector('.ant-picker-cell-selected');
            expect(selected).toBeInTheDocument();
        });
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(selected);
        expect(input).toHaveValue('2023/05/01');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023/05/01 00:00:00', {
            selector: '.ant-description-date-picker'
        })).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023-05-01')).toBeInTheDocument();
    });
});
describe('RangePicker', ()=>{
    it('GMT', async ()=>{
        const { container, getByPlaceholderText } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo4_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const picker = container.querySelector('.ant-picker');
        const startInput = getByPlaceholderText('Start date');
        const endInput = getByPlaceholderText('End date');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(picker);
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(document.querySelector('[title="2023-05-01"]'));
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(document.querySelector('[title="2023-05-02"]'));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>expect(startInput).toHaveValue('2023-05-01'));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>expect(endInput).toHaveValue('2023-05-02'));
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023-05-01~2023-05-02', {
            selector: '.ant-description-text'
        })).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023-05-01T00:00:00.000Z ~ 2023-05-02T23:59:59.999Z')).toBeInTheDocument();
    });
    it('non-GMT', async ()=>{
        const { container, getByPlaceholderText } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo5_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const picker = container.querySelector('.ant-picker');
        const startInput = getByPlaceholderText('Start date');
        const endInput = getByPlaceholderText('End date');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(picker);
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(document.querySelector('[title="2023-05-01"]'));
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(document.querySelector('[title="2023-05-02"]'));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            expect(startInput).toHaveValue('2023-05-01');
            expect(endInput).toHaveValue('2023-05-02');
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023-05-01~2023-05-02', {
                selector: '.ant-description-text'
            })).toBeInTheDocument();
            if (!process.env.GITHUB_ACTIONS) expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/2023-04-30t16:00:00\.000z ~ 2023-05-02t15:59:59\.999z/i)).toBeInTheDocument();
        });
    });
    it('non-UTC', async ()=>{
        const { container, getByPlaceholderText } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo6_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const picker = container.querySelector('.ant-picker');
        const startInput = getByPlaceholderText('Start date');
        const endInput = getByPlaceholderText('End date');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(picker);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(document.querySelector('[title="2023-05-01"]'));
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(document.querySelector('[title="2023-05-02"]'));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>expect(startInput).toHaveValue('2023-05-01'));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>expect(endInput).toHaveValue('2023-05-02'));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023-05-01~2023-05-02', {
                selector: '.ant-description-text'
            })).toBeInTheDocument());
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023-05-01 ~ 2023-05-02')).toBeInTheDocument());
    });
    it('showTime=false,gmt=true,utc=true', async ()=>{
        const { container } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo7_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const picker = container.querySelector('.ant-picker');
        const input = container.querySelector('input');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(picker);
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.type(input, '2023/05/01');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(document.querySelector('[title="2023-05-01"]'));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            expect(input).toHaveValue('2023/05/01');
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023/05/01', {
                selector: '.ant-description-date-picker'
            })).toBeInTheDocument();
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023-05-01T00:00:00.000Z')).toBeInTheDocument();
        });
    });
    it('showTime=false,gmt=false,utc=true', async ()=>{
        const { container } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo8_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const picker = container.querySelector('.ant-picker');
        const input = container.querySelector('input');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(picker);
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.type(input, '2023/05/01');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(document.querySelector('[title="2023-05-01"]'));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            expect(input).toHaveValue('2023/05/01');
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023/05/01', {
                selector: '.ant-description-date-picker'
            })).toBeInTheDocument();
            if (!process.env.GITHUB_ACTIONS) expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('2023-04-30T16:00:00.000Z')).toBeInTheDocument();
        });
    });
    it('showTime=false,gmt=true,utc=true & not input', async ()=>{
        const currentDateString = new Date().toISOString().split('T')[0];
        const { container } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo9_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const picker = container.querySelector('.ant-picker');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(picker);
        const btn = document.querySelector('[title="'.concat(currentDateString, '"]'));
        expect(btn).toBeInTheDocument();
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(btn);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(currentDateString.replace(/-/g, '/'), {
                selector: '.ant-description-date-picker'
            })).toBeInTheDocument();
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText("".concat(currentDateString, "T00:00:00.000Z"))).toBeInTheDocument();
        });
    });
    it('shortcut', async ()=>{
        const { container } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo11_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const picker = container.querySelector('.ant-picker');
        const startInput = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByPlaceholderText('Start date');
        const endInput = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByPlaceholderText('End date');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(picker);
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/today/i));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>expect(startInput.getAttribute('value')).toBeTruthy());
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>expect(endInput.getAttribute('value')).toBeTruthy());
    });
});
