starling-devex 0.1.2

Starling: a local dev orchestrator with a central daemon, shared named-URL proxy, and a k9s-style TUI (a Rust port of Tilt + portless)
import { render, screen } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import React from "react"
import { MemoryRouter } from "react-router"
import Features, { FeaturesTestProvider, Flag } from "./feature"
import { OverviewTableDisplayOptions } from "./OverviewTableDisplayOptions"
import { ResourceGroupsContextProvider } from "./ResourceGroupsContext"
import {
  ResourceListOptions,
  ResourceListOptionsProvider,
} from "./ResourceListOptionsContext"
import { nResourceWithLabelsView, TestDataView } from "./testdata"

// Helpers
const DisplayOptions = ({
  view,
  resourceListOptions,
}: {
  view: TestDataView
  resourceListOptions?: ResourceListOptions
}) => {
  const features = new Features({
    [Flag.Labels]: true,
  })
  return (
    <MemoryRouter
      initialEntries={["/"]}
      future={{ v7_startTransition: true, v7_relativeSplatPath: true }}
    >
      <FeaturesTestProvider value={features}>
        <ResourceGroupsContextProvider>
          <ResourceListOptionsProvider
            initialValuesForTesting={resourceListOptions}
          >
            <OverviewTableDisplayOptions resources={view.uiResources} />
          </ResourceListOptionsProvider>
        </ResourceGroupsContextProvider>
      </FeaturesTestProvider>
    </MemoryRouter>
  )
}

describe("expand-all button", () => {
  it("sends analytics onclick", () => {
    let view = nResourceWithLabelsView(3)
    const { container } = render(DisplayOptions({ view }))
    userEvent.click(screen.getByTitle("Expand All"))
  })
})

describe("collapse-all button", () => {
  it("sends analytics onclick", () => {
    let view = nResourceWithLabelsView(3)
    const { container } = render(DisplayOptions({ view }))
    userEvent.click(screen.getByTitle("Collapse All"))
  })
})