Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Product/Version references for TestRun / TestExecution in multiple pages #3439

Merged
merged 5 commits into from
Dec 3, 2023
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
11 changes: 7 additions & 4 deletions tcms/issuetracker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,17 @@ def _report_comment(self, execution, user=None): # pylint: disable=no-self-use
{reporter}

**Product:**
{execution.run.plan.product.name}
{execution.build.version.product.name}

**Component(s):**
{self.get_case_components(execution.case)}
**Version:**
{execution.build.version.value}

**Version-Release number** (if applicable):
**Build:**
{execution.build.name}

**Component(s):**
{self.get_case_components(execution.case)}

**Steps to reproduce**:
{txt}

Expand Down
4 changes: 2 additions & 2 deletions tcms/issuetracker/bugzilla_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def _report_issue(self, execution, user):
to a URL with some of the values pre-defined as query parameters!
"""
args = {
"product": execution.run.plan.product.name,
"product": execution.build.version.product.name,
"component": self.get_case_components(execution.case),
"version": execution.run.plan.product_version.value,
"version": execution.build.version.value,
"short_desc": f"Test case failure: {execution.case.summary}",
"comment": self._report_comment(execution, user),
}
Expand Down
4 changes: 2 additions & 2 deletions tcms/issuetracker/kiwitcms.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def _report_issue(self, execution, user):
data = {
"reporter": user,
"summary": f"Failed test: {execution.case.summary}",
"product": execution.run.plan.product,
"version": execution.run.plan.product_version,
"product": execution.build.version.product,
"version": execution.build.version,
"build": execution.build,
"text": self._report_comment(execution, user),
"_execution": execution,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_azureboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_bitbucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
6 changes: 6 additions & 0 deletions tcms/issuetracker/tests/test_bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def test_report_issue_from_test_execution_falls_back_to_query_params(self):
test_case.save() # will generate history object

test_run = TestRunFactory(plan=test_plan)
test_run.build.version = version
test_run.build.save()

execution2 = TestExecutionFactory(
run=test_run, case=test_case, build=test_run.build
)
Expand Down Expand Up @@ -144,6 +147,9 @@ def test_report_issue_from_test_execution_1click_works(self):
test_case.save() # will generate history object

test_run = TestRunFactory(plan=test_plan)
test_run.build.version = version
test_run.build.save()

execution2 = TestExecutionFactory(
run=test_run, case=test_case, build=test_run.build
)
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_gitlab_com.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_gitlab_ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
6 changes: 3 additions & 3 deletions tcms/issuetracker/tests/test_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def _fixture_setup(self):
self.execution_1.run.save()

# this is the name of the Project in JIRA. Key is "KT"
self.execution_1.run.plan.product.name = "Kiwi TCMS"
self.execution_1.run.plan.product.save()
self.execution_1.build.version.product.name = "Kiwi TCMS"
self.execution_1.build.version.product.save()

self.component = ComponentFactory(
name="JIRA integration", product=self.execution_1.run.plan.product
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_kiwitcms.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
6 changes: 3 additions & 3 deletions tcms/issuetracker/tests/test_redmine.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def _fixture_setup(self):
self.execution_1.case.save() # will generate history object

# this is the name of the Redmine Project
self.execution_1.run.plan.product.name = "Integration with Kiwi TCMS"
self.execution_1.run.plan.product.save()
self.execution_1.build.version.product.name = "Integration with Kiwi TCMS"
self.execution_1.build.version.product.save()

self.component = ComponentFactory(
name="Redmine integration", product=self.execution_1.run.plan.product
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_project_from_jira(self, execution):

.. versionadded:: 11.4
"""
search_for = execution.run.plan.product.name.lower()
search_for = execution.build.version.product.name.lower()
projects_in_jira = self.rpc.projects()
for project in self.rpc.projects():
if (project.name.lower() == search_for) or (
Expand Down
6 changes: 3 additions & 3 deletions tcms/rpc/api/testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,19 @@ def filter(query=None): # pylint: disable=redefined-builtin
TestRun.objects.filter(**query)
.values(
"id",
"plan__product_version",
"plan__product_version__value",
"start_date",
"stop_date",
"planned_start",
"planned_stop",
"summary",
"notes",
"plan",
"plan__product",
"plan__name",
"build",
"build__name",
"build__version",
"build__version__value",
"build__version__product",
"manager",
"manager__username",
"default_tester",
Expand Down
7 changes: 4 additions & 3 deletions tcms/rpc/tests/test_testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,13 @@ def test_filter(self):
result = result[0]

self.assertEqual(result["id"], self.test_run.pk)
self.assertEqual(result["build__version"], self.test_run.build.version.pk)
self.assertEqual(
result["plan__product_version"], self.test_run.plan.product_version.pk
result["build__version__value"],
self.test_run.build.version.value,
)
self.assertEqual(
result["plan__product_version__value"],
self.test_run.plan.product_version.value,
result["build__version__product"], self.test_run.build.version.product.pk
)
self.assertEqual(result["start_date"], self.test_run.start_date)
self.assertEqual(result["stop_date"], self.test_run.stop_date)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export function drawTable () {

const productIds = $('#id_product').val()
if (productIds.length) {
query.run__plan__product__in = productIds
query.build__version__product__in = productIds
}

const versionIds = $('#id_version').val()
if (versionIds.length) {
query.run__plan__product_version__in = versionIds
query.build__version__in = versionIds
}

const buildIds = $('#id_build').val()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export function drawChart () {

const productIds = $('#id_product').val()
if (productIds.length) {
query.run__plan__product__in = productIds
query.build__version__product__in = productIds
}

const versionIds = $('#id_version').val()
if (versionIds.length) {
query.run__plan__product_version__in = versionIds
query.build__version__in = versionIds
}

const buildIds = $('#id_build').val()
Expand Down
4 changes: 2 additions & 2 deletions tcms/telemetry/static/telemetry/js/testing/status-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ export function drawTable () {

const productIds = $('#id_product').val()
if (productIds.length) {
query.run__plan__product__in = productIds
query.build__version__product__in = productIds
}

const versionIds = $('#id_version').val()
if (versionIds.length) {
query.run__plan__product_version__in = versionIds
query.build__version__in = versionIds
}

const buildIds = $('#id_build').val()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export function initializePage () {

const productIds = $('#id_product').val()
if (productIds.length) {
query.run__plan__product__in = productIds
query.build__version__product__in = productIds
}

const versionIds = $('#id_version').val()
if (versionIds.length) {
query.run__plan__product_version__in = versionIds
query.build__version__in = versionIds
}

const buildIds = $('#id_build').val()
Expand Down
2 changes: 1 addition & 1 deletion tcms/templates/email/post_run_save/email.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% blocktrans with pk=test_run.pk run_url=test_run.get_full_url plan_url=test_run.plan.get_full_url summary=test_run.summary manager=test_run.manager default_tester=test_run.default_tester product=test_run.plan.product version=test_run.plan.product_version build=test_run.build notes=test_run.notes %}Test run {{ pk }} has been created or updated for you.
{% blocktrans with pk=test_run.pk run_url=test_run.get_full_url plan_url=test_run.plan.get_full_url summary=test_run.summary manager=test_run.manager default_tester=test_run.default_tester product=test_run.build.version.product version=test_run.build.version build=test_run.build notes=test_run.notes %}Test run {{ pk }} has been created or updated for you.

### Links ###
Test run: {{ run_url }}
Expand Down
15 changes: 7 additions & 8 deletions tcms/testruns/static/testruns/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {

function preProcessData (data, callbackF) {
const runIds = []
const planIds = []
const productIds = []
data.forEach(function (element) {
runIds.push(element.id)
planIds.push(element.plan)
productIds.push(element.build__version__product)
})

// get tags for all objects
Expand All @@ -29,7 +29,7 @@ function preProcessData (data, callbackF) {
}
})

jsonRPC('Product.filter', { plan__in: planIds }, function (products) {
jsonRPC('Product.filter', { pk__in: productIds }, function (products) {
products = arrayToDict(products)

// augment data set with additional info
Expand All @@ -39,8 +39,7 @@ function preProcessData (data, callbackF) {
} else {
element.tag = []
}

element.product_name = products[element.plan__product].name
element.product_name = products[element.build__version__product].name
})

callbackF({ data }) // renders everything
Expand Down Expand Up @@ -104,11 +103,11 @@ export function pageTestrunsSearchReadyHandler () {
}

if ($('#id_product').val()) {
params.plan__product = $('#id_product').val()
params.build__version__product = $('#id_product').val()
};

if ($('#id_version').val()) {
params.plan__product_version = $('#id_version').val()
params.build__version = $('#id_version').val()
};

if ($('#id_build').val()) {
Expand Down Expand Up @@ -148,7 +147,7 @@ export function pageTestrunsSearchReadyHandler () {
}
},
{ data: 'product_name' },
{ data: 'plan__product_version__value' },
{ data: 'build__version__value' },
{ data: 'build__name' },
{ data: 'start_date' },
{ data: 'stop_date' },
Expand Down
8 changes: 4 additions & 4 deletions tcms/testruns/templates/testruns/get.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ <h2 class="card-pf-title" style="text-align: left">

<h2 class="card-pf-title" style="text-align: left">
<span class="fa fa-shopping-cart"></span>{% trans 'Product' %}:
<a href="{% url 'testruns-search' %}?product={{ object.plan.product_id }}" title="Search test runs of {{ object.plan.product }}">{{ object.plan.product }}</a>
<a href="{% url 'testruns-search' %}?product={{ object.build.version.product_id }}" title="Search test runs of {{ object.build.version.product }}">{{ object.build.version.product }}</a>
</h2>

<h2 class="card-pf-title" style="text-align: left">
<span class="fa fa-random"></span>{% trans 'Version' %}:
<a href="{% url 'testruns-search' %}?product={{ object.plan.product_id }}&version={{ object.plan.product_version_id }}" title="Search test runs of {{ object.plan.product_version.value }}">{{ object.plan.product_version.value }}</a>
<a href="{% url 'testruns-search' %}?product={{ object.build.version.product_id }}&version={{ object.build.version_id }}" title="Search test runs of {{ object.build.version.value }}">{{ object.build.version.value }}</a>
</h2>

<h2 class="card-pf-title" style="text-align: left">
<span class="fa fa-wrench"></span>{% trans 'Build' %}:
<a href="{% url 'testruns-search' %}?product={{ object.plan.product_id }}&version={{ object.plan.product_version_id }}&build={{ object.build_id }}" title="Search test runs of {{ object.build }}">{{ object.build }}</a>
<a href="{% url 'testruns-search' %}?product={{ object.build.version.product_id }}&version={{ object.build.version_id }}&build={{ object.build_id }}" title="Search test runs of {{ object.build }}">{{ object.build }}</a>
</h2>

<h2 class="card-pf-title" style="text-align: left">
Expand Down Expand Up @@ -295,7 +295,7 @@ <h2 class="card-pf-title">
</button>

<button class="btn btn-default"
href="{% url 'testcases-search' %}?product={{ object.plan.product_id }}{% for status in confirmed_statuses %}&case_status={{ status.pk }}{% endfor %}"
href="{% url 'testcases-search' %}?product={{ object.build.version.product_id }}{% for status in confirmed_statuses %}&case_status={{ status.pk }}{% endfor %}"
id="btn-search-cases" title="{% trans 'Advanced search' %}">
<span class="fa fa-search"></span>
</button>
Expand Down
1 change: 0 additions & 1 deletion tcms/testruns/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def setUpTestData(cls):
"manager": cls.test_run.manager.email,
"default_tester": intern.email,
"notes": "New run notes",
"product_version": cls.test_run.plan.product_version.pk,
"plan": cls.test_run.plan.pk,
}
super().setUpTestData()
Expand Down
4 changes: 2 additions & 2 deletions tcms/testruns/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def test_post_creates_new_run(self):
post_data = {
"summary": new_run_summary,
"plan": self.plan.pk,
"product_id": self.plan.product_id,
"product": self.plan.product_id,
"product_id": self.build.version.product_id,
"product": self.build.version.product_id,
"build": self.build.pk,
"manager": self.tester.email,
"default_tester": self.tester.email,
Expand Down
Loading