Sha256: cac20ffcc400ae751115d241a8774f62820918d1d45a7f0a7a70e4ead186f716

Contents?: true

Size: 1.96 KB

Versions: 520

Compression:

Stored size: 1.96 KB

Contents

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

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

520 entries across 520 versions & 1 rubygems

Version Path
playbook_ui-13.18.0.pre.alpha.dependabotnpmandyarnpowerhomeplaybookicons001alpha52174 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2173 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2159 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.17.0.pre.alpha.nodealphaupgrade2157 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.18.0 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2130 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.PLAY12002127 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.powercentrainplaybookpt22125 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2107 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.PBNTR181stripedtable2103 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2100 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.PBNTR184betaflaginmenuyml2085 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.PBNTR178AdvancedTableDocs2072 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.17.0 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2060 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2038 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2037 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.nodejsupgrade2036 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2035 app/pb_kits/playbook/pb_filter/filter.test.js
playbook_ui-13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2034 app/pb_kits/playbook/pb_filter/filter.test.js