Sha256: d09275dcad09d7cab786cb2468838559311c832f014a3ce7f528ec0ed5285480

Contents?: true

Size: 1.97 KB

Versions: 482

Compression:

Stored size: 1.97 KB

Contents

import React from "react";
import {
  render,
  screen,
  fireEvent,
} from "../utilities/test-utils";
import { Button, Filter, Flex, Select, TextInput } from "playbook-ui";

function FilterTest(props) {
  const SortingChangeCallback = (sortOptions) => {
    alert(JSON.stringify(sortOptions[0]));
  };

  const options = [
    { value: "USA" },
    { value: "Canada" },
    { value: "Brazil" },
    { value: "Philippines" },
    { value: "A Galaxy Far Far Away Like Really Far Away" },
  ];
  return (
    <Filter
        onSortChange={SortingChangeCallback}
        results={1}
        sortOptions={{
        popularity: "Popularity",
        // eslint-disable-next-line
        manager_title: "Manager's Title",
        // eslint-disable-next-line
        manager_name: "Manager's Name",
      }}
        sortValue={[{ name: "popularity", dir: "desc" }]}
        {...props}
    >
      <TextInput
          label="Example Text Field"
          placeholder="Enter Text"
          {...props}
      />

      <Select
          blankSelection="Select One..."
          label="Example Collection Select"
          name="Collection Select"
          options={options}
          {...props}
      />
      <Flex spacing="between"
          {...props}>
        <Button text="Apply"
            {...props} />
        <Button text="Clear"
            variant="secondary"
            {...props} />
      </Flex>
    </Filter>
  );
}

test("triggers popover on filter button click", () => {
  render(<FilterTest data={{ testid: "render-test" }}/>);

  const btn = screen.getAllByRole("button")[0];

  // checks if the sort menu rendered
  expect(screen.getByLabelText("sort-amount-down icon")).toBeInTheDocument()
  expect(screen.getByText('Popularity')).toBeInTheDocument() // check if filter/sort is rendered 

  // hits the filter button and triggers popover
  fireEvent.click(btn);

  // check if popover displays correctly by checking its tet
  expect(screen.getByText("Example Text Field")).toBeInTheDocument() 


});

Version data entries

482 entries across 482 versions & 1 rubygems

Version Path
playbook_ui-14.11.1.pre.alpha.PLAY17445539 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR798datepickerturbo5537 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.pbntr703collapsiblerowsrails5536 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.PLAY1751pbcontenttagpt25529 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR7495495 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.12.0.pre.rc.11 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.12.0.pre.rc.10 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.12.0.pre.rc.9 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.12.0.pre.rc.8 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.12.0.pre.rc.7 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5437 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR719listdraggablesimple5432 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR768stickyrightcolumn5431 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.12.0.pre.rc.6 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5415 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5413 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.12.0.pre.rc.5 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5409 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5400 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5392 app/pb_kits/playbook/pb_filter/filter.test.js