Skip to content

Commit

Permalink
Merge branch 'main' into issue-activity-log-query
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Anderson authored Jan 23, 2024
2 parents 4a4ac0e + 945a55a commit aa64f20
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 64 deletions.
60 changes: 9 additions & 51 deletions coral/src/app/features/topics/browse/BrowseTopics.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import { TopicApiResponse } from "src/domain/topic/topic-types";
import { mockIntersectionObserver } from "src/services/test-utils/mock-intersection-observer";
import { customRender } from "src/services/test-utils/render-with-wrappers";
import { tabNavigateTo } from "src/services/test-utils/tabbing";
import { setupFeatureFlagMock } from "src/services/feature-flags/test-helper";
import { FeatureFlag } from "src/services/feature-flags/types";

jest.mock("src/domain/team/team-api.ts");
jest.mock("src/domain/topic/topic-api.ts");
Expand Down Expand Up @@ -85,53 +83,6 @@ describe("BrowseTopics.tsx", () => {
teamId: undefined,
};

describe("renders a select element for Topic types based on a feature flag", () => {
beforeEach(() => {
mockGetTeams.mockResolvedValue(mockGetTeamsResponse);
mockGetEnvironments.mockResolvedValue(mockGetEnvironmentResponse);
mockGetTopics.mockResolvedValue(mockedGetTopicsResponseSinglePage);
});

afterEach(cleanup);

it("does not show the select for Topic type when feature flag is not enabled", async () => {
customRender(<BrowseTopics />, {
memoryRouter: true,
queryClient: true,
aquariumContext: true,
});
await waitForElementToBeRemoved(
screen.getAllByTestId(/async-select-loading/)
);

const select = screen.queryByRole("combobox", {
name: filterByTopicTypeLabel,
});

expect(select).not.toBeInTheDocument();
});

it("shows a select for Topic type when feature flag is enabled", async () => {
setupFeatureFlagMock(FeatureFlag.FEATURE_FLAG_TOPIC_TYPE_FILTER, true);

customRender(<BrowseTopics />, {
memoryRouter: true,
queryClient: true,
aquariumContext: true,
});

await waitForElementToBeRemoved(
screen.getAllByTestId(/async-select-loading/)
);

const select = screen.getByRole("combobox", {
name: filterByTopicTypeLabel,
});

expect(select).toBeEnabled();
});
});

describe("handles successful response with one page", () => {
beforeAll(async () => {
mockGetTeams.mockResolvedValue(mockGetTeamsResponse);
Expand Down Expand Up @@ -169,6 +120,14 @@ describe("BrowseTopics.tsx", () => {
expect(select).toBeEnabled();
});

it("shows a select for Topic type", () => {
const select = screen.getByRole("combobox", {
name: filterByTopicTypeLabel,
});

expect(select).toBeEnabled();
});

it("renders the topic table with information about the pages", async () => {
const table = screen.getByRole("table", {
name: "Topics overview, page 1 of 1",
Expand Down Expand Up @@ -391,9 +350,8 @@ describe("BrowseTopics.tsx", () => {
});
});

describe("handles user filtering topics by type when feature flag is active", () => {
describe("handles user filtering topics by type", () => {
beforeEach(async () => {
setupFeatureFlagMock(FeatureFlag.FEATURE_FLAG_TOPIC_TYPE_FILTER, true);
mockGetTeams.mockResolvedValue(mockGetTeamsResponse);
mockGetEnvironments.mockResolvedValue([]);
mockGetTopics.mockResolvedValue(mockedResponseTransformed);
Expand Down
10 changes: 1 addition & 9 deletions coral/src/app/features/topics/browse/BrowseTopics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,8 @@ import { TableLayout } from "src/app/features/components/layouts/TableLayout";
import TopicTable from "src/app/features/topics/browse/components/TopicTable";
import { getTopics } from "src/domain/topic";
import { TopicTypeFilter } from "src/app/features/components/filters/TopicTypeFilter";
import useFeatureFlag from "src/services/feature-flags/hook/useFeatureFlag";
import { FeatureFlag } from "src/services/feature-flags/types";

function BrowseTopics() {
const topicTypeFilterEnabled = useFeatureFlag(
FeatureFlag.FEATURE_FLAG_TOPIC_TYPE_FILTER
);

const [searchParams, setSearchParams] = useSearchParams();

const currentPage = searchParams.get("page")
Expand Down Expand Up @@ -75,9 +69,7 @@ function BrowseTopics() {
key="environment"
environmentsFor={"TOPIC_AND_ACL"}
/>,
...(topicTypeFilterEnabled
? [<TopicTypeFilter key={"topicType"} />]
: []),
<TopicTypeFilter key={"topicType"} />,
<SearchTopicFilter key={"search"} />,
]}
table={
Expand Down
1 change: 0 additions & 1 deletion coral/src/services/feature-flags/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
enum FeatureFlag {
FEATURE_FLAG_DASHBOARD = "FEATURE_FLAG_DASHBOARD",
FEATURE_FLAG_TOPIC_TYPE_FILTER = "FEATURE_FLAG_TOPIC_TYPE_FILTER",
}

export { FeatureFlag };
3 changes: 0 additions & 3 deletions coral/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ export default defineConfig(({ mode }) => {
FEATURE_FLAG_DASHBOARD: ["development", "remote-api"]
.includes(mode)
.toString(),
FEATURE_FLAG_TOPIC_TYPE_FILTER: ["development", "remote-api"]
.includes(mode)
.toString(),
},
},
css: {
Expand Down

0 comments on commit aa64f20

Please sign in to comment.