Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#44828] fixed spec selectors

Eric Schubert11ddbb53fab9
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/wp-relation-row/wp-relation-row.template.html b/frontend/src/app/features/work-packages/components/wp-relations/wp-relation-row/wp-relation-row.template.html
index abf5ff983bf..7cd263a8f7f 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/wp-relation-row/wp-relation-row.template.html
+++ b/frontend/src/app/features/work-packages/components/wp-relations/wp-relation-row/wp-relation-row.template.html
@@ -10,6 +10,7 @@
<button
type="button"
class="relation-row--type"
+ data-qa-selector="op-relation--row-type"
(click)="activateRelationTypeEdit()"
*ngIf="!userInputs.showRelationTypesForm"
>
@@ -47,12 +48,14 @@
<a
class="relation-row--grid-id"
+ data-qa-selector="op-relation--row-id"
uiSref="work-packages.show.tabs"
[uiParams]="{ workPackageId: relatedWorkPackage.id, tabIdentifier: 'relations' }"
>#{{relatedWorkPackage.id}}</a>
<a
class="relation-row--grid-subject"
+ data-qa-selector="op-relation--row-subject"
uiSref="work-packages.show.tabs"
[uiParams]="{ workPackageId: relatedWorkPackage.id, tabIdentifier: 'relations' }"
[textContent]="relatedWorkPackage.subject"
diff --git a/spec/features/work_packages/copy_spec.rb b/spec/features/work_packages/copy_spec.rb
index f63b00f6d66..30df41460ee 100644
--- a/spec/features/work_packages/copy_spec.rb
+++ b/spec/features/work_packages/copy_spec.rb
@@ -128,7 +128,7 @@ RSpec.describe 'Work package copy', js: true, selenium: true do
work_package_page.visit_tab! :relations
expect_angular_frontend_initialized
expect(page).to have_selector('.relation-group--header', text: 'RELATED TO', wait: 20)
- expect(page).to have_selector('.wp-relations--subject-field', text: original_work_package.subject)
+ expect(page).to have_selector("[data-qa-selector='op-relation--row-subject']", text: original_work_package.subject)
end
describe 'when source work package has an attachment' do
@@ -181,6 +181,6 @@ RSpec.describe 'Work package copy', js: true, selenium: true do
work_package_page.visit_tab!('relations')
expect_angular_frontend_initialized
expect(page).to have_selector('.relation-group--header', text: 'RELATED TO', wait: 20)
- expect(page).to have_selector('.wp-relations--subject-field', text: original_work_package.subject)
+ expect(page).to have_selector("[data-qa-selector='op-relation--row-subject']", text: original_work_package.subject)
end
end
diff --git a/spec/features/work_packages/details/relations/hierarchy_spec.rb b/spec/features/work_packages/details/relations/hierarchy_spec.rb
index f071d4dbdaf..a8301ef0532 100644
--- a/spec/features/work_packages/details/relations/hierarchy_spec.rb
+++ b/spec/features/work_packages/details/relations/hierarchy_spec.rb
@@ -69,14 +69,14 @@ shared_examples 'work package relations tab', js: true, selenium: true do
##
# Add child #1
- relations.openChildrenAutocompleter
+ relations.open_children_autocompleter
relations.add_existing_child(child)
relations.expect_child(child)
##
# Add child #2
- relations.openChildrenAutocompleter
+ relations.open_children_autocompleter
relations.add_existing_child(child2)
relations.expect_child(child2)
@@ -240,7 +240,7 @@ shared_examples 'work package relations tab', js: true, selenium: true do
##
# Add child
- relations.openChildrenAutocompleter
+ relations.open_children_autocompleter
relations.add_existing_child(child)
wp_page.expect_and_dismiss_toaster(message: 'Successful update.')
diff --git a/spec/features/work_packages/details/relations/relations_spec.rb b/spec/features/work_packages/details/relations/relations_spec.rb
index 588a98da1d0..3ab48316224 100644
--- a/spec/features/work_packages/details/relations/relations_spec.rb
+++ b/spec/features/work_packages/details/relations/relations_spec.rb
@@ -249,7 +249,7 @@ describe 'Work package relations tab', js: true, selenium: true do
# Wait for the relations table to be present
sleep 2
- expect(page).to have_selector('.wp-relations--subject-field')
+ expect(page).to have_selector("[data-qa-selector='op-relation--row-subject']")
scroll_to_element find('.detail-panel--relations')
diff --git a/spec/support/components/work_packages/relations.rb b/spec/support/components/work_packages/relations.rb
index 23359c83cf2..f9881b4df9b 100644
--- a/spec/support/components/work_packages/relations.rb
+++ b/spec/support/components/work_packages/relations.rb
@@ -48,7 +48,7 @@ module Components
def click_relation(relatable)
SeleniumHubWaiter.wait
- page.find(".relation-row-#{relatable.id} .wp-relations--subject-field").click
+ page.find(".relation-row-#{relatable.id} [data-qa-selector='op-relation--row-id']").click
end
def edit_relation_type(relatable, to_type:)
@@ -63,7 +63,7 @@ module Components
def hover_action(relatable, action)
retry_block do
# Focus type edit to expose buttons
- span = page.find(".relation-row-#{relatable.id} .relation-row--type", wait: 20)
+ span = page.find(".relation-row-#{relatable.id} [data-qa-selector='op-relation--row-type']", wait: 20)
scroll_to_element(span)
page.driver.browser.action.move_to(span.native).perform
@@ -96,7 +96,7 @@ module Components
container = find('.wp-relations-create--form', wait: 10)
# Labels to expect
- relation_label = I18n.t('js.relation_labels.' + type)
+ relation_label = I18n.t("js.relation_labels.#{type}")
select relation_label, from: 'relation-type--select'
@@ -111,9 +111,9 @@ module Components
text: relation_label.upcase,
wait: 10)
- expect(page).to have_selector('.relation-row--type', text: to.type.name.upcase)
+ expect(page).to have_selector("[data-qa-selector='op-relation--row-type']", text: to.type.name.upcase)
- expect(page).to have_selector('.wp-relations--subject-field', text: to.subject)
+ expect(page).to have_selector("[data-qa-selector='op-relation--row-subject']", text: to.subject)
## Test if relation exist
work_package.reload
@@ -123,15 +123,15 @@ module Components
end
def expect_relation(relatable)
- expect(relations_group).to have_selector('.wp-relations--subject-field', text: relatable.subject)
+ expect(relations_group).to have_selector("[data-qa-selector='op-relation--row-subject']", text: relatable.subject)
end
def expect_relation_by_text(text)
- expect(relations_group).to have_selector('.wp-relations--subject-field', text:)
+ expect(relations_group).to have_selector("[data-qa-selector='op-relation--row-subject']", text:)
end
def expect_no_relation(relatable)
- expect(page).not_to have_selector('.wp-relations--subject-field', text: relatable.subject)
+ expect(page).not_to have_selector("[data-qa-selector='op-relation--row-subject']", text: relatable.subject)
end
def add_parent(query, work_package)
@@ -172,7 +172,7 @@ module Components
subject.update subject_text
end
- def openChildrenAutocompleter
+ def open_children_autocompleter
retry_block do
next if page.has_selector?('.wp-relations--children .ng-input input')