Admin analytics: heatmap per device, anteprima staff e analisi costi.
Separa heatmap mobile/desktop, opt-out analytics per operatori, dashboard costi con KPI e trend mensili. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Admin costs", type: :request do
|
||||
let!(:admin) { AdminAccount.create!(username: "ops-costs", password: "Password123") }
|
||||
let(:month) { Time.zone.today.beginning_of_month }
|
||||
|
||||
before do
|
||||
post admin_login_path, params: { username: admin.username, password: "Password123" }
|
||||
PlatformCostEntry.create!(month: month, label: "Piattaforma", amount_cents: 8_500)
|
||||
end
|
||||
|
||||
it "mostra la dashboard costi" do
|
||||
get admin_costs_path, params: { month: month.strftime("%Y-%m") }
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to include(I18n.t("admin.costs.index.title"))
|
||||
expect(response.body).to include("85.00")
|
||||
end
|
||||
|
||||
it "crea, aggiorna ed elimina una voce di costo" do
|
||||
post admin_cost_entries_path,
|
||||
params: {
|
||||
platform_cost_entry: {
|
||||
month: month.strftime("%Y-%m"),
|
||||
label: "Stream CPX",
|
||||
amount_euros: "42.50",
|
||||
notes: "overflow nodes"
|
||||
}
|
||||
}
|
||||
expect(response).to redirect_to(admin_costs_path(month: month.strftime("%Y-%m")))
|
||||
entry = PlatformCostEntry.find_by(label: "Stream CPX")
|
||||
expect(entry.amount_cents).to eq(4_250)
|
||||
|
||||
patch admin_cost_entry_path(entry),
|
||||
params: { platform_cost_entry: { month: month.strftime("%Y-%m"), label: "Stream CPX", amount_euros: "50" } }
|
||||
expect(response).to redirect_to(admin_costs_path(month: month.strftime("%Y-%m")))
|
||||
expect(entry.reload.amount_cents).to eq(5_000)
|
||||
|
||||
delete admin_cost_entry_path(entry)
|
||||
expect(response).to redirect_to(admin_costs_path(month: month.strftime("%Y-%m")))
|
||||
expect(PlatformCostEntry.find_by(id: entry.id)).to be_nil
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user