Skip to content

Commit

Permalink
Restore data-testid attributes & update unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-golovanov committed Feb 4, 2025
1 parent c92bef9 commit 4c80891
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const DismissibleTabBar = ({
<Spinner size="md" />
) : (
<Styled.PlusButton
data-testid="t--ide-tabs-add-button"
isDisabled={disableAdd}
isIconButton
kind="tertiary"
Expand Down
1 change: 1 addition & 0 deletions app/client/src/pages/Editor/IDE/EditorTabs/AddTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const AddTab = ({

return (
<DismissibleTab
dataTestId="t--ide-tab-new_query"
isActive={segmentMode === EditorEntityTabState.Add && !isListActive}
onClick={newTabClickCallback}
onClose={onCloseClick}
Expand Down
2 changes: 2 additions & 0 deletions app/client/src/pages/Editor/IDE/EditorTabs/EditableTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { getIsSavingEntityName } from "ee/selectors/entitiesSelector";

import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { sanitizeString } from "utils/URLUtils";

import {
getEditableTabPermissions,
Expand Down Expand Up @@ -63,6 +64,7 @@ export function EditableTab(props: EditableTabProps) {
return (
<EditableDismissibleTab
canEdit={isChangePermitted}
dataTestId={`t--ide-tab-${sanitizeString(title)}`}
icon={icon}
isActive={isActive}
isEditable={isChangePermitted}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ describe("EditorTabs render checks", () => {
// check tabs is empty
const tabsContainer = getByTestId("t--tabs-container");

expect(tabsContainer.firstChild).toBeNull();
// tabs container contains 2 sentinel divs to check for intersections, so in empty state it should have 2 children
expect(tabsContainer.childElementCount).toBe(2);

//check add button is not present
expect(queryByTestId("t--ide-tabs-add-button")).toBeNull();
Expand All @@ -69,7 +70,8 @@ describe("EditorTabs render checks", () => {
// check tabs is empty
const tabsContainer = getByTestId("t--tabs-container");

expect(tabsContainer.firstChild).toBeNull();
// tabs container contains 2 sentinel divs to check for intersections, so in empty state it should have 2 children
expect(tabsContainer.childElementCount).toBe(2);

//check add button is not present
expect(queryByTestId("t--ide-tabs-add-button")).toBeNull();
Expand Down
1 change: 1 addition & 0 deletions app/client/src/pages/Editor/IDE/EditorTabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const EditorTabs = () => {
<EntityTabsHeader>
{showEntityListButton && (
<EntityListButton
data-testid="t--list-toggle"
isSelected={isListViewActive}
onClick={handleHamburgerClick}
/>
Expand Down

0 comments on commit 4c80891

Please sign in to comment.