user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); config(['upstream_mirrors.connection' => 'sqlite']); Schema::dropIfExists('piaoju_seller_quota_snapshots'); Schema::create('piaoju_seller_quota_snapshots', function (Blueprint $table): void { $table->bigIncrements('id'); $table->string('seller_key', 64)->unique(); $table->string('seller_name', 191); $table->string('tax_number', 64)->nullable(); $table->boolean('seller_status')->nullable(); $table->string('auth_status', 32)->nullable(); $table->string('auth_status_desc', 64)->nullable(); $table->decimal('invoice_limit', 18, 2)->nullable(); $table->dateTime('invoice_limit_updated_at')->nullable(); $table->dateTime('source_fetched_at'); $table->dateTime('synced_at'); $table->timestamps(); }); $this->createInvoiceBasic('甲公司', '甲店铺组', 10000, 8500, '2026-11'); $this->createInvoiceBasic('乙公司', '乙店铺', 2000, 2500, '2026-11'); $this->createInvoiceBasic('丙公司', '丙店铺', 5000, 1000, '2026-11'); $this->createInvoiceBasic('零额度公司', '零额度店铺', 0, 0, '2026-11'); $this->createInvoiceBasic('预警公司', '预警店铺', 0, 3000, '2026-11'); $this->createInvoiceBasic('历史公司', '历史店铺', 100, 3100, '2026-10'); $this->createPiaojuSnapshot('pi-1', '甲公司', 15000, '2026-11-18 13:30:07'); $this->createPiaojuSnapshot('pi-2', '乙公司', -100, '2026-11-18 13:51:43'); $this->createPiaojuSnapshot('pi-3', '丙公司', 4000, '2026-11-18 13:29:10'); $this->createPiaojuSnapshot('pi-4', '预警公司', 595, '2026-11-18 11:29:10'); } protected function tearDown(): void { Carbon::setTestNow(); parent::tearDown(); } public function test_invoice_quota_is_listed_after_invoice_basic_information(): void { $pages = collect(config('business_navigation')) ->firstWhere('slug', 'invoice-management')['pages']; $this->assertSame( ['automatic-invoicing', 'basic-information', 'invoice-quota', 'invoice-reports', 'store-backend-invoicing'], array_column($pages, 'slug') ); } public function test_invoice_quota_defaults_to_latest_period_and_shows_ticket_union_summary(): void { $this->loginAs() ->get($this->pageUrl()) ->assertOk() ->assertSeeText('发票额度') ->assertSeeText('已开票金额') ->assertSeeText('预估整月开票') ->assertSeeText('5天额度预警') ->assertSeeText('15,000.00') ->assertSeeText('18,000.00') ->assertSeeText('19,495.00') ->assertSeeText('甲公司') ->assertSeeText('8,500.00') ->assertSeeText('10,200.00') ->assertSeeText('日均 340.00') ->assertSeeText('44.12 天') ->assertDontSeeText('1,500.00') ->assertSeeText('乙公司') ->assertSeeText('-100.00') ->assertSeeText('额度不足') ->assertSeeText('未匹配') ->assertSeeText('不可查看 0 · 额度不足 1') ->assertSeeText('预警公司') ->assertSeeText('3,600.00') ->assertSeeText('4.96 天') ->assertSeeText('5天内预警') ->assertSeeText('2026-11-18 13:30') ->assertDontSeeText('历史公司') ->assertDontSee('店铺范围', false) ->assertDontSee('开票额度', false) ->assertSee('