qltyfolio/test-detail.sql

              SELECT 'dynamic' AS component, sqlpage.run_sql('shell/shell.sql') AS properties;
              -- not including breadcrumbs from sqlpage_aide_navigation
              -- not including page title from sqlpage_aide_navigation

              
      SELECT 'title' AS component, (SELECT COALESCE(title, caption)
    FROM sqlpage_aide_navigation
   WHERE namespace = 'prime' AND path = 'qltyfolio/test-detail.sql/index.sql') as contents;
    ;

    select
    'breadcrumb' as component;
    select
    'Home' as title,
      sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/' as link;
    select
    'Test Management System' as title,
      sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/qltyfolio/index.sql' as link; 
    select s.name as title,
      sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/qltyfolio/suite-data.sql?id=' || s.id as link
         FROM test_cases r
         INNER JOIN groups g on g.id = r.group_id 
         INNER JOIN test_suites s on s.id = g.suite_id
         where test_case_id = $id
         group by title;  
    select g.name as title,
      sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/qltyfolio/test-cases.sql?id=' || g.id as link
         FROM test_cases r
         INNER JOIN groups g on g.id = r.group_id 
         where test_case_id = $id
         group by title;
         
    SELECT title FROM test_cases where test_case_id = $id;      
         

         

    SELECT 'title'AS component,
      title as contents FROM test_cases where test_case_id = $id; 

    SELECT 'list'AS component;
    SELECT
    '
 **Status**  :  ' || rn."status" AS description_md,
      '
 **Start Time**  :  ' || rn."start_time" AS description_md,
        '
 **End Time**  :  ' || rn."end_time" AS description_md,
          '
 **Duration**  :  ' || rn."total_duration" AS description_md,
            '
 **Title**  :  ' || bd.title AS description_md,
              '
 **Created By**  :  ' || bd.created_by AS description_md,
                '
 **Created At**  :  ' || bd.created_at AS description_md,
                  '
 **Priority**  :  ' || bd.priority AS description_md,
                    '
' || bd.body AS description_md
FROM  test_cases bd 
LEFT JOIN test_case_run_results rn ON  bd.test_case_id = rn.test_case_id
WHERE bd.test_case_id = $id;


  SELECT 'html' as component,
    '<style>
        tr.actualClass-passed td.Status {
            color: green !important; /* Default to red */
        }
         tr.actualClass-failed td.Status {
            color: red !important; /* Default to red */
        }
        .btn-list {
        display: flex;
        justify-content: flex-end;
    }
    </style>
    
    ' as html FROM test_case_run_results where test_case_id = $id group by group_id;


    --Define tabs
    SELECT
    'tab' AS component,
      TRUE AS center
     FROM test_case_run_results where test_case_id = $id group by group_id;

    --Tab 1: Test Suite list
    SELECT
    'Actual Result' AS title,
      sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/qltyfolio/test-detail.sql?tab=actual-result&id='|| $id || '#actual-result-content'  AS link,
      $tab = 'actual-result' AS active
        FROM test_case_run_results where test_case_id = $id group by group_id;


    --Tab 2: Test case list
    SELECT
    'Test Run' AS title,
      sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/qltyfolio/test-detail.sql?tab=test-run&id='|| $id || '#test-run-content'  AS link,
      $tab = 'test-run' AS active
         FROM test_case_run_results where test_case_id = $id group by group_id;



    SELECT
    CASE
        WHEN $tab = 'actual-result' THEN 'title'
    END AS component,
      'Actual Result' as contents   
    FROM test_case_run_results WHERE test_case_id = $id group by group_id;

    SELECT
    CASE
        WHEN $tab = 'actual-result' THEN 'table'
        WHEN $tab = 'test-run' THEN 'list'
      END AS component,
      'Column Count' as align_right,
      TRUE as sort,
      TRUE as search
        FROM test_case_run_results  where test_case_id = $id group by group_id;


    --Tab - specific content for "actual-result"  

      
    SELECT
    step_name as 'Activity',
      step_status as 'Activity Status',
      'actualClass-'||step_status as _sqlpage_css_class,
      step_start_time as 'Start Time',
      step_end_time as 'End Time'
          FROM test_execution_log
          WHERE $tab = 'actual-result' and  test_case_id = $id order by step_start_time desc;
    SELECT
    CASE
        WHEN $tab = 'actual-result' THEN 'html'
    END AS component,
      '<div id="actual-result-content"></div>' as html;



    --Tab - specific content for "test-run"
    SELECT
    '
 **Run Date**  :  ' || run_date AS description_md,
      '
 **Environment**  :  ' || environment AS description_md,
        '
' || body AS description_md
    FROM  test_run WHERE $tab = 'test-run' and test_case_id = $id;

    SELECT
    CASE
        WHEN $tab = 'test-run' THEN 'html'
    END AS component,
      '<div id="test-run-content"></div>' as html;
    --select 'code' AS component;
    --select content as contents FROM test_case_run_profile where $tab = 'test-run' and  test_case_id = $id;