2022-12-01 11:22:20 +01:00
|
|
|
|
RSpec.describe Dossiers::BatchAlertComponent, type: :component do
|
|
|
|
|
let(:instructeur) { create(:instructeur) }
|
|
|
|
|
let(:procedure) { create(:procedure) }
|
|
|
|
|
|
|
|
|
|
subject { render_inline(component).to_html }
|
|
|
|
|
|
2022-12-12 10:02:33 +01:00
|
|
|
|
describe 'archiver' do
|
|
|
|
|
let(:component) do
|
|
|
|
|
described_class.new(
|
|
|
|
|
batch: batch_operation,
|
|
|
|
|
procedure: procedure
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
let!(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
|
|
|
|
let!(:dossier_2) { create(:dossier, :accepte, procedure: procedure) }
|
|
|
|
|
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [dossier, dossier_2], instructeur: instructeur) }
|
|
|
|
|
context 'in_progress' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--info') }
|
|
|
|
|
it { is_expected.to have_text("Une action de masse est en cours") }
|
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ont été archivés") }
|
2023-05-11 17:13:02 +02:00
|
|
|
|
it { is_expected.to have_text("Cette opération a été lancée par #{instructeur.email}, il y a moins d'une minute") }
|
2022-12-12 10:02:33 +01:00
|
|
|
|
end
|
2022-12-05 15:36:41 +01:00
|
|
|
|
|
2022-12-12 10:02:33 +01:00
|
|
|
|
context 'finished and success' do
|
|
|
|
|
before {
|
2023-02-01 14:59:37 +01:00
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
2022-12-12 10:02:33 +01:00
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
2022-12-01 11:22:20 +01:00
|
|
|
|
|
2022-12-12 10:02:33 +01:00
|
|
|
|
it { is_expected.to have_selector('.fr-alert--success') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2022-12-12 10:02:33 +01:00
|
|
|
|
it { is_expected.to have_text("2 dossiers ont été archivés") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'finished and fail' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(false, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--warning') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2022-12-12 10:02:33 +01:00
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ont été archivés") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
|
2022-12-15 17:35:50 +01:00
|
|
|
|
it 'on next render "seen_at" is set to avoid rendering alert' do
|
2022-12-12 10:02:33 +01:00
|
|
|
|
render_inline(component).to_html
|
|
|
|
|
expect(batch_operation.seen_at).not_to eq(nil)
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-12-01 11:22:20 +01:00
|
|
|
|
end
|
|
|
|
|
|
2022-12-12 10:02:33 +01:00
|
|
|
|
describe 'passer_en_instruction' do
|
|
|
|
|
let(:component) do
|
|
|
|
|
described_class.new(
|
|
|
|
|
batch: batch_operation,
|
|
|
|
|
procedure: procedure
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
let!(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
|
|
|
|
let!(:dossier_2) { create(:dossier, :en_construction, procedure: procedure) }
|
|
|
|
|
let!(:batch_operation) { create(:batch_operation, operation: :passer_en_instruction, dossiers: [dossier, dossier_2], instructeur: instructeur) }
|
|
|
|
|
|
|
|
|
|
context 'in_progress' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--info') }
|
|
|
|
|
it { is_expected.to have_text("Une action de masse est en cours") }
|
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ont été passés en instruction") }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'finished and success' do
|
|
|
|
|
before {
|
2023-02-01 14:59:37 +01:00
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
2022-12-12 10:02:33 +01:00
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--success') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2022-12-12 10:02:33 +01:00
|
|
|
|
it { is_expected.to have_text("2 dossiers ont été passés en instruction") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'finished and fail' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(false, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--warning') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2022-12-12 10:02:33 +01:00
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ont été passés en instruction") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
|
2022-12-15 17:35:50 +01:00
|
|
|
|
it 'on next render "seen_at" is set to avoid rendering alert' do
|
|
|
|
|
render_inline(component).to_html
|
|
|
|
|
expect(batch_operation.seen_at).not_to eq(nil)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-01-04 11:51:22 +01:00
|
|
|
|
|
2022-12-15 17:35:50 +01:00
|
|
|
|
describe 'accepter' do
|
|
|
|
|
let(:component) do
|
|
|
|
|
described_class.new(
|
|
|
|
|
batch: batch_operation,
|
|
|
|
|
procedure: procedure
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
let!(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
|
|
|
|
let!(:dossier_2) { create(:dossier, :en_instruction, procedure: procedure) }
|
|
|
|
|
let!(:batch_operation) { create(:batch_operation, operation: :accepter, dossiers: [dossier, dossier_2], instructeur: instructeur) }
|
|
|
|
|
|
|
|
|
|
context 'in_progress' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--info') }
|
|
|
|
|
it { is_expected.to have_text("Une action de masse est en cours") }
|
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ont été acceptés") }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'finished and success' do
|
|
|
|
|
before {
|
2023-02-01 14:59:37 +01:00
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
2022-12-15 17:35:50 +01:00
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--success') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2022-12-15 17:35:50 +01:00
|
|
|
|
it { is_expected.to have_text("2 dossiers ont été acceptés") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'finished and fail' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(false, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--warning') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2022-12-15 17:35:50 +01:00
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ont été acceptés") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
|
|
|
|
|
it 'on next render "seen_at" is set to avoid rendering alert' do
|
2022-12-12 10:02:33 +01:00
|
|
|
|
render_inline(component).to_html
|
|
|
|
|
expect(batch_operation.seen_at).not_to eq(nil)
|
|
|
|
|
end
|
2022-12-02 12:42:26 +01:00
|
|
|
|
end
|
2022-12-01 11:22:20 +01:00
|
|
|
|
end
|
2023-01-04 11:51:22 +01:00
|
|
|
|
|
|
|
|
|
describe 'follow' do
|
|
|
|
|
let(:component) do
|
|
|
|
|
described_class.new(
|
|
|
|
|
batch: batch_operation,
|
|
|
|
|
procedure: procedure
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
let!(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
|
|
|
|
let!(:dossier_2) { create(:dossier, :en_instruction, procedure: procedure) }
|
|
|
|
|
let!(:batch_operation) { create(:batch_operation, operation: :follow, dossiers: [dossier, dossier_2], instructeur: instructeur) }
|
|
|
|
|
|
|
|
|
|
context 'in_progress' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--info') }
|
|
|
|
|
it { is_expected.to have_text("Une action de masse est en cours") }
|
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ont été suivis") }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'finished and success' do
|
|
|
|
|
before {
|
2023-02-01 14:59:37 +01:00
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
2023-01-04 11:51:22 +01:00
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--success') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2023-01-04 11:51:22 +01:00
|
|
|
|
it { is_expected.to have_text("2 dossiers ont été suivis") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'finished and fail' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(false, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--warning') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2023-01-04 11:51:22 +01:00
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ont été suivis") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
|
|
|
|
|
it 'on next render "seen_at" is set to avoid rendering alert' do
|
|
|
|
|
render_inline(component).to_html
|
|
|
|
|
expect(batch_operation.seen_at).not_to eq(nil)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-01-11 11:05:19 +01:00
|
|
|
|
|
2023-01-13 15:09:24 +01:00
|
|
|
|
describe 'unfollow' do
|
|
|
|
|
let(:component) do
|
|
|
|
|
described_class.new(
|
|
|
|
|
batch: batch_operation,
|
|
|
|
|
procedure: procedure
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
let!(:dossier) { create(:dossier, :en_construction, :followed, procedure: procedure) }
|
|
|
|
|
let!(:dossier_2) { create(:dossier, :en_instruction, :followed, procedure: procedure) }
|
|
|
|
|
let!(:batch_operation) { create(:batch_operation, operation: :unfollow, dossiers: [dossier, dossier_2], instructeur: instructeur) }
|
|
|
|
|
|
|
|
|
|
context 'in_progress' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--info') }
|
|
|
|
|
it { is_expected.to have_text("Une action de masse est en cours") }
|
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ne sont plus suivis") }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'finished and success' do
|
|
|
|
|
before {
|
2023-02-01 14:59:37 +01:00
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
2023-01-13 15:09:24 +01:00
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--success') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2023-01-13 15:09:24 +01:00
|
|
|
|
it { is_expected.to have_text("2 dossiers ne sont plus suivis") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'finished and fail' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(false, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--warning') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2023-01-13 15:09:24 +01:00
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ne sont plus suivis") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
|
|
|
|
|
it 'on next render "seen_at" is set to avoid rendering alert' do
|
|
|
|
|
render_inline(component).to_html
|
|
|
|
|
expect(batch_operation.seen_at).not_to eq(nil)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2023-01-11 11:05:19 +01:00
|
|
|
|
describe 'repasser en construction' do
|
|
|
|
|
let(:component) do
|
|
|
|
|
described_class.new(
|
|
|
|
|
batch: batch_operation,
|
|
|
|
|
procedure: procedure
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
let!(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
|
|
|
|
let!(:dossier_2) { create(:dossier, :en_instruction, procedure: procedure) }
|
|
|
|
|
let!(:batch_operation) { create(:batch_operation, operation: :repasser_en_construction, dossiers: [dossier, dossier_2], instructeur: instructeur) }
|
|
|
|
|
|
|
|
|
|
context 'in_progress' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--info') }
|
|
|
|
|
it { is_expected.to have_text("Une action de masse est en cours") }
|
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ont été repassés en construction") }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'finished and success' do
|
|
|
|
|
before {
|
2023-02-01 14:59:37 +01:00
|
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
2023-01-11 11:05:19 +01:00
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--success') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2023-01-11 11:05:19 +01:00
|
|
|
|
it { is_expected.to have_text("2 dossiers ont été repassés en construction") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'finished and fail' do
|
|
|
|
|
before {
|
|
|
|
|
batch_operation.track_processed_dossier(false, dossier)
|
|
|
|
|
batch_operation.track_processed_dossier(true, dossier_2)
|
|
|
|
|
batch_operation.reload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_selector('.fr-alert--warning') }
|
2023-06-08 10:03:34 +02:00
|
|
|
|
it { is_expected.to have_text("L’action de masse est terminée") }
|
2023-01-11 11:05:19 +01:00
|
|
|
|
it { is_expected.to have_text("1/2 dossiers ont été repassés en construction") }
|
|
|
|
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
|
|
|
|
|
|
|
|
|
it 'on next render "seen_at" is set to avoid rendering alert' do
|
|
|
|
|
render_inline(component).to_html
|
|
|
|
|
expect(batch_operation.seen_at).not_to eq(nil)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-12-01 11:22:20 +01:00
|
|
|
|
end
|