2019-10-17 09:07:07 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-01 21:41:16 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 09:08:32 +00:00
|
|
|
RSpec.describe Types::Ci::DetailedStatusType do
|
2020-10-26 12:08:44 +00:00
|
|
|
include GraphqlHelpers
|
|
|
|
|
2020-05-07 06:09:38 +00:00
|
|
|
specify { expect(described_class.graphql_name).to eq('DetailedStatus') }
|
2019-03-01 21:41:16 +00:00
|
|
|
|
2020-10-26 12:08:44 +00:00
|
|
|
it 'has all fields' do
|
2021-07-14 21:09:44 +00:00
|
|
|
expect(described_class).to have_graphql_fields(:id, :group, :icon, :favicon,
|
2019-03-01 21:41:16 +00:00
|
|
|
:details_path, :has_details,
|
2020-10-07 06:09:03 +00:00
|
|
|
:label, :text, :tooltip, :action)
|
2019-03-01 21:41:16 +00:00
|
|
|
end
|
2020-10-26 12:08:44 +00:00
|
|
|
|
2021-07-14 21:09:44 +00:00
|
|
|
let_it_be(:stage) { create(:ci_stage_entity, status: :skipped) }
|
|
|
|
|
|
|
|
describe 'id field' do
|
|
|
|
it 'correctly renders the field' do
|
|
|
|
parent_object = double(:parent_object, object: stage)
|
|
|
|
parent = double(:parent, object: parent_object)
|
|
|
|
status = stage.detailed_status(stage.pipeline.user)
|
|
|
|
expected_id = "#{status.id}-#{stage.id}"
|
|
|
|
|
|
|
|
expect(resolve_field('id', status, extras: { parent: parent })).to eq(expected_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-26 12:08:44 +00:00
|
|
|
describe 'action field' do
|
|
|
|
it 'correctly renders the field' do
|
|
|
|
status = stage.detailed_status(stage.pipeline.user)
|
|
|
|
|
|
|
|
expected_status = {
|
|
|
|
button_title: status.action_button_title,
|
|
|
|
icon: status.action_icon,
|
|
|
|
method: status.action_method,
|
|
|
|
path: status.action_path,
|
|
|
|
title: status.action_title
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(resolve_field('action', status)).to eq(expected_status)
|
|
|
|
end
|
|
|
|
end
|
2019-03-01 21:41:16 +00:00
|
|
|
end
|