1#! /usr/bin/env python3
2#
3# BitBake Toaster Implementation
4#
5# Copyright (C) 2013-2016 Intel Corporation
6#
7# SPDX-License-Identifier: GPL-2.0-only
8#
9
10from django.urls import reverse
11from django.utils import timezone
12from tests.browser.selenium_helpers import SeleniumTestCase
13from orm.models import Project, Build, Recipe, Task, Layer, Layer_Version
14from orm.models import Target
15
16class TestBuilddashboardPageTasks(SeleniumTestCase):
17    """ Test build dashboard tasks sub-page """
18
19    def setUp(self):
20        project = Project.objects.get_or_create_default_project()
21
22        now = timezone.now()
23
24        self.build = Build.objects.create(project=project,
25                                          started_on=now,
26                                          completed_on=now)
27
28        layer = Layer.objects.create()
29
30        layer_version = Layer_Version.objects.create(layer=layer)
31
32        recipe = Recipe.objects.create(layer_version=layer_version)
33
34        task = Task.objects.create(build=self.build, recipe=recipe, order=1)
35
36        Target.objects.create(build=self.build, task=task, target='do_build')
37
38    def test_build_tasks_columns(self):
39        """
40        Check that non-hideable columns of the table on the tasks sub-page
41        are disabled on the edit columns dropdown.
42        """
43        url = reverse('tasks', args=(self.build.id,))
44        self.get(url)
45
46        self.wait_until_visible('#edit-columns-button')
47
48        # check that options for the non-hideable columns are disabled
49        non_hideable = ['order', 'task_name', 'recipe__name']
50
51        for column in non_hideable:
52            selector = 'input#checkbox-%s[disabled="disabled"]' % column
53            self.wait_until_present(selector)
54