feat(graphql): expose pendingDeletedDossiers on groupe instructeur
This commit is contained in:
parent
7c4ae3b786
commit
bf6cc25063
3 changed files with 85 additions and 1 deletions
|
@ -2478,6 +2478,41 @@ type GroupeInstructeurWithDossiers {
|
|||
Le numero du groupe instructeur.
|
||||
"""
|
||||
number: Int!
|
||||
|
||||
"""
|
||||
Liste de tous les dossiers en attente de suppression définitive d’un groupe instructeur.
|
||||
"""
|
||||
pendingDeletedDossiers(
|
||||
"""
|
||||
Returns the elements in the list that come after the specified cursor.
|
||||
"""
|
||||
after: String
|
||||
|
||||
"""
|
||||
Returns the elements in the list that come before the specified cursor.
|
||||
"""
|
||||
before: String
|
||||
|
||||
"""
|
||||
Dossiers en attente de suppression depuis la date.
|
||||
"""
|
||||
deletedSince: ISO8601DateTime
|
||||
|
||||
"""
|
||||
Returns the first _n_ elements from the list.
|
||||
"""
|
||||
first: Int
|
||||
|
||||
"""
|
||||
Returns the last _n_ elements from the list.
|
||||
"""
|
||||
last: Int
|
||||
|
||||
"""
|
||||
L’ordre des dossiers en attente de suppression.
|
||||
"""
|
||||
order: Order = ASC
|
||||
): DeletedDossierConnection!
|
||||
}
|
||||
|
||||
type HeaderSectionChampDescriptor implements ChampDescriptor {
|
||||
|
|
|
@ -18,6 +18,11 @@ module Types
|
|||
argument :deleted_since, GraphQL::Types::ISO8601DateTime, required: false, description: "Dossiers supprimés depuis la date."
|
||||
end
|
||||
|
||||
field :pending_deleted_dossiers, Types::DeletedDossierType.connection_type, "Liste de tous les dossiers en attente de suppression définitive d’un groupe instructeur.", null: false do
|
||||
argument :order, Types::Order, default_value: :asc, required: false, description: "L’ordre des dossiers en attente de suppression."
|
||||
argument :deleted_since, GraphQL::Types::ISO8601DateTime, required: false, description: "Dossiers en attente de suppression depuis la date."
|
||||
end
|
||||
|
||||
def dossiers(updated_since: nil, created_since: nil, state: nil, archived: nil, revision: nil, max_revision: nil, min_revision: nil, order:, lookahead:)
|
||||
dossiers = object
|
||||
.dossiers
|
||||
|
@ -70,5 +75,15 @@ module Types
|
|||
|
||||
dossiers.order(deleted_at: order)
|
||||
end
|
||||
|
||||
def pending_deleted_dossiers(deleted_since: nil, order:)
|
||||
dossiers = object.dossiers.hidden_for_administration
|
||||
|
||||
if deleted_since.present?
|
||||
dossiers = dossiers.hidden_since(deleted_since)
|
||||
end
|
||||
|
||||
dossiers.order(hidden_by_user_at: order, hidden_by_administration_at: order)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -136,7 +136,7 @@ describe API::V2::GraphqlController do
|
|||
|
||||
context 'include deleted Dossiers' do
|
||||
let(:variables) { { demarcheNumber: procedure.id, includeDeletedDossiers: true, deletedSince: 2.weeks.ago.iso8601 } }
|
||||
let(:deleted_dossier) { create(:deleted_dossier, dossier: dossier_accepte) }
|
||||
let(:deleted_dossier) { DeletedDossier.create_from_dossier(dossier_accepte, DeletedDossier.reasons.fetch(:user_request)) }
|
||||
|
||||
before { deleted_dossier }
|
||||
|
||||
|
@ -191,6 +191,40 @@ describe API::V2::GraphqlController do
|
|||
expect(gql_data[:groupeInstructeur][:dossiers][:nodes].size).to eq(1)
|
||||
}
|
||||
end
|
||||
|
||||
context 'include deleted Dossiers' do
|
||||
let(:variables) { { groupeInstructeurNumber: groupe_instructeur.id, includeDeletedDossiers: true, deletedSince: 2.weeks.ago.iso8601 } }
|
||||
let(:deleted_dossier) { DeletedDossier.create_from_dossier(dossier_accepte, DeletedDossier.reasons.fetch(:user_request)) }
|
||||
|
||||
before { deleted_dossier }
|
||||
|
||||
it {
|
||||
expect(gql_errors).to be_nil
|
||||
expect(gql_data[:groupeInstructeur][:id]).to eq(groupe_instructeur.to_typed_id)
|
||||
expect(gql_data[:groupeInstructeur][:deletedDossiers][:nodes].size).to eq(1)
|
||||
expect(gql_data[:groupeInstructeur][:deletedDossiers][:nodes].first[:id]).to eq(deleted_dossier.to_typed_id)
|
||||
expect(gql_data[:groupeInstructeur][:deletedDossiers][:nodes].first[:dateSupression]).to eq(deleted_dossier.deleted_at.iso8601)
|
||||
}
|
||||
end
|
||||
|
||||
context 'include pending deleted Dossiers' do
|
||||
let(:variables) { { groupeInstructeurNumber: groupe_instructeur.id, includePendingDeletedDossiers: true, pendingDeletedSince: 2.weeks.ago.iso8601 } }
|
||||
|
||||
before {
|
||||
dossier.hide_and_keep_track!(dossier.user, DeletedDossier.reasons.fetch(:user_request))
|
||||
dossier_accepte.hide_and_keep_track!(instructeur, DeletedDossier.reasons.fetch(:instructeur_request))
|
||||
}
|
||||
|
||||
it {
|
||||
expect(gql_errors).to be_nil
|
||||
expect(gql_data[:groupeInstructeur][:id]).to eq(groupe_instructeur.to_typed_id)
|
||||
expect(gql_data[:groupeInstructeur][:pendingDeletedDossiers][:nodes].size).to eq(2)
|
||||
expect(gql_data[:groupeInstructeur][:pendingDeletedDossiers][:nodes].first[:id]).to eq(GraphQL::Schema::UniqueWithinType.encode('DeletedDossier', dossier.id))
|
||||
expect(gql_data[:groupeInstructeur][:pendingDeletedDossiers][:nodes].second[:id]).to eq(GraphQL::Schema::UniqueWithinType.encode('DeletedDossier', dossier_accepte.id))
|
||||
expect(gql_data[:groupeInstructeur][:pendingDeletedDossiers][:nodes].first[:dateSupression]).to eq(dossier.hidden_by_user_at.iso8601)
|
||||
expect(gql_data[:groupeInstructeur][:pendingDeletedDossiers][:nodes].second[:dateSupression]).to eq(dossier_accepte.hidden_by_administration_at.iso8601)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context 'getDemarcheDescriptor' do
|
||||
|
|
Loading…
Reference in a new issue