Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions web/pgadmin/static/js/components/PgTree/FileTreeItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,28 @@ export class FileTreeItem extends React.Component<IItemRendererXProps & IItemRen
const tags = item._metadata.data?.tags ?? [];

return (
<div
className={cn('file-entry', {
renaming: isRenamePrompt,
prompt: isRenamePrompt || isNewPrompt,
new: isNewPrompt,
}, fileOrDir, decorations ? decorations.classlist : null, `depth-${item.depth}`, extraClasses)}
data-depth={item.depth}
onContextMenu={this.handleContextMenu}
onClick={this.handleClick}
onDragStart={this.handleDragStartItem}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
onKeyDown={()=>{/* taken care by parent */}}
// required for rendering context menus when opened through context menu button on keyboard
ref={this.handleDivRef}
draggable={true}>

{!isNewPrompt && fileOrDir === 'directory' ?
<i className={cn('directory-toggle', isDirExpanded ? 'open' : '')} />
: null
}

<DoubleClickHandler onDoubleClick={this.handleDoubleClick} onSingleClick={this.handleClick} >
<DoubleClickHandler onDoubleClick={this.handleDoubleClick} onSingleClick={this.handleClick}>
<div
className={cn('file-entry', {
renaming: isRenamePrompt,
prompt: isRenamePrompt || isNewPrompt,
new: isNewPrompt,
}, fileOrDir, decorations ? decorations.classlist : null, `depth-${item.depth}`, extraClasses)}
data-depth={item.depth}
onContextMenu={this.handleContextMenu}
onDragStart={this.handleDragStartItem}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
onKeyDown={()=>{/* taken care by parent */}}
// required for rendering context menus when opened through context menu button on keyboard
ref={this.handleDivRef}
draggable={true}>

{!isNewPrompt && fileOrDir === 'directory' ?
<i className={cn('directory-toggle', isDirExpanded ? 'open' : '')} />
: null
}

<span className='file-label'>{
item._metadata?.data?.icon ?
<i className={cn('file-icon', item._metadata?.data?.icon ? item._metadata.data.icon : fileOrDir)} /> : null
Expand All @@ -120,8 +119,9 @@ export class FileTreeItem extends React.Component<IItemRendererXProps & IItemRen
</div>
))}
</span>
</DoubleClickHandler>
</div>);
</div>
</DoubleClickHandler>
);
}

public componentDidMount() {
Expand Down
19 changes: 18 additions & 1 deletion web/regression/feature_tests/browser_tool_bar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
import secrets
import time

from selenium.webdriver.support.wait import WebDriverWait

from regression.python_test_utils import test_utils
from regression.feature_utils.locators import BrowserToolBarLocators
from regression.feature_utils.base_feature_test import BaseFeatureTest
from regression.feature_utils.tree_area_locators import TreeAreaLocators
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC


class BrowserToolBarFeatureTest(BaseFeatureTest):
Expand Down Expand Up @@ -68,6 +71,14 @@ def test_query_tool_button(self):
'db_password'],
self.test_db),
'Tree is not expanded to database node')

WebDriverWait(self.driver, 3).until(
EC.visibility_of_element_located(
(By.CSS_SELECTOR,
BrowserToolBarLocators.open_query_tool_button_css)
), "Timed out waiting for execute query button to appear"
)

self.assertTrue(self.page.retry_click(
(By.CSS_SELECTOR,
BrowserToolBarLocators.open_query_tool_button_css),
Expand All @@ -87,7 +98,13 @@ def test_view_data_tool_button(self):
table_node = self.page.check_if_element_exists_with_scroll(
TreeAreaLocators.table_node(self.test_table_name))
table_node.click()
time.sleep(2)

WebDriverWait(self.driver, 3).until(
EC.visibility_of_element_located(
(By.CSS_SELECTOR,
BrowserToolBarLocators.view_table_data_button_css)
), "Timed out waiting for execute query button to appear"
)

self.assertTrue(self.page.retry_click(
(By.CSS_SELECTOR,
Expand Down
139 changes: 14 additions & 125 deletions web/regression/feature_utils/tree_area_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def server_group_node(server_group_name):
@staticmethod
def server_group_node_exp_status(server_group_name):
return "//i[@class='directory-toggle open']/following-sibling::" \
"div//span[starts-with(text(),'%s')]" % server_group_name
"span//span[starts-with(text(),'%s')]" % server_group_name

# Server Node
@staticmethod
Expand All @@ -31,7 +31,7 @@ def server_node(server_name):
@staticmethod
def server_node_exp_status(server_name):
return "//i[@class='directory-toggle open']/following-sibling::" \
"div//span[starts-with(text(),'%s')]" % server_name
"span//span[starts-with(text(),'%s')]" % server_name

# Server Connection
@staticmethod
Expand All @@ -49,20 +49,19 @@ def databases_node(server_name):
@staticmethod
def databases_node_exp_status(server_name):
return "//div[div[div[span[span[starts-with(text(),'%s')]]]]]/" \
"following-sibling::div//div[span[span[text()='Databases']]]/" \
"following-sibling::div//span[span[text()='Databases']]/" \
"preceding-sibling::i[@class='directory-toggle open']" \
% server_name

# Database Node
@staticmethod
def database_node(database_name):
return "//div[@data-depth='4']/div/span/span[text()='%s']" \
% database_name
return "//div[@data-depth='4']/span/span[text()='%s']" % database_name

@staticmethod
def database_node_exp_status(database_name):
return "//i[@class='directory-toggle open']/following-sibling::" \
"div//span[text()='%s']" % database_name
"span//span[text()='%s']" % database_name

# Schemas Node
@staticmethod
Expand All @@ -73,7 +72,7 @@ def schemas_node(database_name):
@staticmethod
def schemas_node_exp_status(database_name):
return "//div[div[div[span[span[starts-with(text(),'%s')]]]]]/" \
"following-sibling::div//div[span[span[text()='Schemas']]]/" \
"following-sibling::span//div[span[span[text()='Schemas']]]/" \
"preceding-sibling::i[@class='directory-toggle open']" \
% database_name

Expand All @@ -86,25 +85,25 @@ def schema_node(schema_name):
@staticmethod
def schema_node_exp_status(schema_name):
return "//i[@class='directory-toggle open']/" \
"following-sibling::div//span[text()='%s']" % schema_name
"following-sibling::span//span[text()='%s']" % schema_name

# Tables Node
@staticmethod
def tables_node(schema_name):
return "//div[divdiv[[span[span[starts-with(text(),'%s')]]]]]/" \
"following-sibling::div//span[text()='Tables']" % schema_name
return ("//div[div[div[span/span[text()='%s']]]]/"
"following-sibling::div//span[text()='Tables']" % schema_name)

@staticmethod
def tables_node_exp_status(schema_name):
return "//div[div[span[span[starts-with(text(),'%s')]]]]/" \
"following-sibling::div//div[span[span[text()='Tables']]]/" \
"following-sibling::span//div[span[span[text()='Tables']]]/" \
"preceding-sibling::i[@class='directory-toggle open']"\
% schema_name

# Schema child
child_node_exp_status = \
"//div[div[div[span[span[starts-with(text(),'%s')]]]]]/" \
"following-sibling::div//div[span[span[text()='%s']]]/" \
"following-sibling::div//span[span[text()='%s']]/" \
"preceding-sibling::i[@class='directory-toggle open']"

child_node = "//div[div[div[span[span[starts-with(text(),'%s')]]]]]/" \
Expand Down Expand Up @@ -148,129 +147,19 @@ def server_child_node(server_name, child_node_name):
# Table Node
@staticmethod
def table_node(table_name):
return "//div[@data-depth='8']/div/span/span[text()='%s']" % table_name
return "//div[@data-depth='8']/span/span[text()='%s']" % table_name

# Function Node
@staticmethod
def function_node(table_name):
return "//div[@data-depth='8']/div/span/span[text()='%s']" % table_name
return "//div[@data-depth='8']/span/span[text()='%s']" % table_name

# Role Node
@staticmethod
def role_node(role_name):
return "//div[@data-depth='4']/div/span/span[text()='%s']" % role_name
return "//div[@data-depth='4']/span/span[text()='%s']" % role_name

# Context element option
@staticmethod
def context_menu_element(schema_name):
return "[role='menuitem'][data-label='%s']" % schema_name

# Old xpaths
# server_group_sub_nodes_exp_status = \
# "//div[div[span[span[contains(text(),'Servers')]]]]" \
# "/following-sibling::ul/li/div"
#
# server_group_sub_nodes_connected_status = \
# "//div[div[span[span[contains(text(), 'Servers')]]]]/" \
# "following-sibling::ul/li/div/div/div/span[2]"
#
# specified_tree_node = \
# "//div[@id='id-object-explorer']//span[@class='aciTreeItem']/" \
# "span[(@class='aciTreeText') and text()='{}']"
#
# specified_tree_node_exp_status = \
# "//div[@id='id-object-explorer']//span[@class='aciTreeItem']/" \
# "span[(@class='aciTreeText') and text()='{}']" \
# "//ancestor::*[@class='aciTreeLine']"
#
# sub_nodes_of_tables_node = \
# "//div[div[div[div[div[div[div[div[span[span[" \
# "contains(text(),'Tables')]]]]]]]]]]/" \
# "following-sibling::ul/li/div//div/span[2]/span[2]"
#
# sub_nodes_of_functions_node = \
# "//div[div[div[div[div[div[div[div[span[span[" \
# "contains(text(),'Functions')]]]]]]]]]]/" \
# "following-sibling::ul/li/div//div/span[2]/span[2]"
#
# sub_nodes_of_login_group_node = \
# "//div[div[div[span[span[contains(text(),'Login/Group Roles')]]]]]" \
# "/following::ul/li/div[@class='aciTreeLine']"
#
# @staticmethod
# def sub_nodes_of_a_server_node(server_name):
# xpath = "//div[div[div[span[span[contains(text(),'%s')]]]]]/" \
# "following-sibling::ul/li/div[@class='aciTreeLine']" % \
# server_name
# return xpath
#
# @staticmethod
# def sub_nodes_of_a_server_node_exp_status(server_name):
# xpath = "//div[div[div[span[span[contains(text(),'%s')]]]]]/" \
# "following-sibling::ul/li/div" % server_name
# return xpath
#
# @staticmethod
# def databases_node_of_a_server_node(server_name):
# xpath = "//div[div[div[span[span[contains(text(),'%s')]]]]]/" \
# "following-sibling::ul/li/div/div/div/div/span[2]/span[2 " \
# "and text()='Databases ']" % server_name
# return xpath
#
# @staticmethod
# def sub_nodes_of_databases_node(server_name):
# xpath = "//div[div[div[span[span[contains(text(),'%s')]]]]]/" \
# "following-sibling::ul/li[1]/div/following-sibling::ul/li/" \
# "div/div/div/div/div/span[2]/span[@class='aciTreeText']" % \
# server_name
# return xpath
#
# @staticmethod
# def sub_nodes_of_databases_node_exp_status(server_name):
# xpath = "//div[div[div[span[span[contains(text(), '%s')]]]]]/" \
# "following-sibling::ul/li[1]/div/following-sibling::ul/li/" \
# "div" % server_name
# return xpath
#
# @staticmethod
# def sub_nodes_of_database_node(database_name):
# xpath = "//div[div[div[div[div[span[span[contains(text()," \
# "'%s')]]]]]]]/following-sibling::" \
# "ul/li/div/div/div/div/div/div/span[2]/span[2]"\
# % database_name
# return xpath
#
# @staticmethod
# def sub_nodes_of_database_node_exp_status(database_name):
# xpath = "//div[div[div[div[div[span[span[contains(text(), " \
# "'%s')]]]]]]]/following-sibling::ul/li/div" % database_name
# return xpath
#
# @staticmethod
# def sub_nodes_of_schemas_node(database_name):
# xpath = "//div[div[div[div[div[span[span[text()='%s']]]]]]]/" \
# "following-sibling::ul/li[" \
# "@role='presentation']/ul/li/div//div/span/span[" \
# "@class='aciTreeText']" % database_name
# return xpath
#
# @staticmethod
# def sub_nodes_of_schemas_node_exp_status(database_name):
# xpath = "//div[div[div[div[div[span[span[text()='%s']]]]]]]/" \
# "following-sibling::ul/li[@role='presentation']/ul/li/div" \
# % database_name
# return xpath
#
# @staticmethod
# def sub_nodes_of_schema_node(database_name):
# xpath = "//div[div[div[div[div[span[span[text()='%s']]]]]]]/" \
# "following-sibling::ul/li[@role='presentation']" \
# "/ul/li/ul/li/div//div/span[2]/span[2]" % database_name
# return xpath
#
# @staticmethod
# def sub_nodes_of_schema_node_exp_status(database_name):
# xpath = "//div[div[div[div[div[span[span[text()='%s']]]]]]]/" \
# "following-sibling::ul/li[@role='presentation']" \
# "/ul/li/ul/li/div" % database_name
# return xpath