Skip to content

Commit

Permalink
Update how the start date and stop date of the TestRun is set Fixes #…
Browse files Browse the repository at this point in the history
…2323 :

- the start_date in the TestRun is not set automatically when the Test Run is created

- a toggle button is added for setting the start date and stop date, when the date is set for start or
  finish, the toggle disappears and only the timestamp is visible on the page
  • Loading branch information
AirinB authored and atodorov committed Apr 14, 2021
1 parent e220558 commit 584542f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 31 deletions.
23 changes: 23 additions & 0 deletions tcms/testruns/migrations/0014_remove_auto_setting_start_date.py
@@ -0,0 +1,23 @@
# Generated by Django 3.1.6 on 2021-04-03 10:29

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("testruns", "0013_remove_product_version"),
]

operations = [
migrations.AlterField(
model_name="historicaltestrun",
name="start_date",
field=models.DateTimeField(blank=True, db_index=True, null=True),
),
migrations.AlterField(
model_name="testrun",
name="start_date",
field=models.DateTimeField(blank=True, db_index=True, null=True),
),
]
2 changes: 1 addition & 1 deletion tcms/testruns/models.py
Expand Up @@ -26,7 +26,7 @@
class TestRun(models.Model, UrlMixin):
history = KiwiHistoricalRecords()

start_date = models.DateTimeField(auto_now_add=True, db_index=True)
start_date = models.DateTimeField(db_index=True, null=True, blank=True)
stop_date = models.DateTimeField(null=True, blank=True, db_index=True)
planned_start = models.DateTimeField(db_index=True, null=True, blank=True)
planned_stop = models.DateTimeField(db_index=True, null=True, blank=True)
Expand Down
44 changes: 27 additions & 17 deletions tcms/testruns/static/testruns/js/get.js
Expand Up @@ -10,6 +10,10 @@ const allExecutionStatuses = {},

$(document).ready(() => {

$('[data-toggle="tooltip"]').tooltip({
trigger: 'hover'
});

permissions.removeTag = $('#test_run_pk').data('perm-remove-tag') === 'True'
permissions.addComment = $('#test_run_pk').data('perm-add-comment') === 'True'
permissions.removeComment = $('#test_run_pk').data('perm-remove-comment') === 'True'
Expand All @@ -19,23 +23,29 @@ $(document).ready(() => {

const testRunId = $('#test_run_pk').data('pk')

$('#status_button').on('switchChange.bootstrapSwitch', (_event, state) => {
if (state) {
jsonRPC('TestRun.update', [testRunId, { 'stop_date': null }], () => {
$('.stop-date').html('-')
$('#test_run_pk').parent('h1').css({ 'text-decoration': 'none' })
})
} else {
const timeZone = $('#clock').data('time-zone')
const now = currentTimeWithTimezone(timeZone)

jsonRPC('TestRun.update', [testRunId, { 'stop_date': now }], testRun => {
const stopDate = moment(testRun.stop_date).format("DD MMM YYYY, HH:mm a")
$('.stop-date').html(stopDate)
$('#test_run_pk').parent('h1').css({ 'text-decoration': 'line-through' })
})
}
})
$('#start-button').on('click', function () {
const timeZone = $('#clock').data('time-zone')
const now = currentTimeWithTimezone(timeZone)

jsonRPC('TestRun.update', [testRunId, { 'start_date': now }], testRun => {
const startDate = moment(testRun.start_date).format("DD MMM YYYY, HH:mm a")
$('.start-date').html(startDate);
$(this).hide();
})
});

$('#stop-button').on('click', function () {
const timeZone = $('#clock').data('time-zone')
const now = currentTimeWithTimezone(timeZone)

jsonRPC('TestRun.update', [testRunId, { 'stop_date': now }], testRun => {
const stopDate = moment(testRun.stop_date).format("DD MMM YYYY, HH:mm a")
$('.stop-date').html(stopDate);
$(this).hide();
$('#test_run_pk').parent('h1').css({ 'text-decoration': 'line-through' })
})
});


$('.add-comment-bulk').click(function () {
$(this).parents('.dropdown').toggleClass('open')
Expand Down
31 changes: 18 additions & 13 deletions tcms/testruns/templates/testruns/get.html
Expand Up @@ -63,13 +63,6 @@ <h2 class="card-pf-title" style="text-align: left">
</h2>
{% endif %}

<h2 class="card-pf-title" style="text-align: left">
<span class="fa fa-spinner"></span>{% trans 'Status' %}:
<input class="bootstrap-switch" id="status_button" type="checkbox"
{% if not object.stop_date %}checked{% endif %}
{% if not perms.testruns.change_testrun %}disabled{% endif %}
data-on-text="{% trans 'Running' %}" data-off-text="{% trans 'Finished' %}">
</h2>

<h2 class="card-pf-title" style="text-align: left">
<span class="fa fa fa-calendar-o"></span>{% trans 'Planned start' %}:
Expand All @@ -79,22 +72,34 @@ <h2 class="card-pf-title" style="text-align: left">
<h2 class="card-pf-title" style="text-align: left">
<span class="fa fa-calendar"></span>{% trans 'Started at' %}:
{{ object.start_date }}
<span class="start-date">
{{ object.start_date|default:'-' }}
</span>
{% if not object.start_date %}
<button class="btn btn-success btn-xs" type="button" id="start-button"
data-toggle="tooltip" data-placement="top" title="{% trans 'Start' %}"
style="float:right;">
<i class="fa fa-check" style="color: white; margin: auto; "></i>
</button>
{% endif %}
</h2>

<h2 class="card-pf-title" style="text-align: left">
<span class="fa fa fa-calendar-o"></span>{% trans 'Planned stop' %}:
{{ object.planned_stop|default:'-' }}
</h2>

<h2 class="card-pf-title" style="text-align: left">
<h2 class="card-pf-title" style="text-align: left; overflow: hidden;">
<span class="fa fa-calendar-check-o"></span>{% trans 'Finished at' %}:
<span class="stop-date">
{% if object.stop_date %}
{{ object.stop_date }}
{% else %}
-
{% endif %}
{{ object.stop_date|default:'-' }}
</span>
{% if not object.stop_date %}
<button class="btn btn-warning btn-xs pull-right" type="button" id="stop-button"
data-toggle="tooltip" data-placement="top" title="{% trans 'Stop' %}" style="margin-bottom: 1rem;">
<i class="fa fa-check" style="color: white; margin: auto; "></i>
</button>
{% endif %}
</h2>

<div class="card-pf-body"></div>
Expand Down

0 comments on commit 584542f

Please sign in to comment.