user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); } public function test_duplicate_quote_push_displays_the_reason_on_the_returned_page(): void { $this->grantWorkspaceAccess(); Http::preventStrayRequests(); config([ 'services.esign.app_id' => 'test-app-id', 'services.esign.app_secret' => 'test-app-secret', ]); $signature = $this->createQuoteSignature('QB-DUPLICATE', CourierQuoteSignature::STATUS_ARCHIVED, '睢宁中通'); $this->loginAs(); $url = route('business.pages.show', [ 'section' => 'courier-payables', 'page' => 'agreement-signing', 'agreement_view' => 'create', ]); $this->withExceptionHandling()->loginAs()->from($url) ->post(route('business.courier-agreement-signatures.store'), [ 'idempotency_key' => 'duplicate-quote-push', 'courier_name' => '睢宁中通', 'document_type' => 'quote-confirmation', 'quote_version_id' => $signature->quote_version_id, 'signing_subject' => $this->company->name, 'company_full_name' => $this->company->name, 'signature_date' => now()->toDateString(), 'signing_deadline' => now()->addDays(7)->toDateString(), 'esign_account' => '13800138000', 'counterparty_signer_type' => 'organization', 'counterparty_organization_name' => '睢宁中通快递有限公司', 'operator_name' => '张经理', 'archive_mode' => 'auto', ]) ->assertRedirect($url) ->assertSessionHasErrors('signature'); $this->get($url)->assertOk() ->assertSee('data-agreement-submit-error', false) ->assertSeeText('报价版本 QB-DUPLICATE 当前为“已签署并归档”,不能重复推送。'); Http::assertNothingSent(); $this->assertSame(CourierQuoteSignature::STATUS_ARCHIVED, $signature->fresh()->status); $this->assertDatabaseCount('business_courier_quote_signatures', 1); } public function testAgreementSigningPageRendersTheSigningWorkspace(): void { $this->grantWorkspaceAccess(); $this->loginAs() ->get(route('business.pages.show', [ 'section' => 'courier-payables', 'page' => 'agreement-signing', ])) ->assertOk() ->assertSeeText('协议签署') ->assertSeeText('签署任务') ->assertSeeText('发起签章') ->assertSeeText('模板管理') ->assertSeeText(EsignClient::configured() ? 'E签宝已连接' : 'E签宝未连接') ->assertSeeText('暂无待处理任务') ->assertSeeText('收款账户变更证明.doc') ->assertSeeText('收款账户证明文件.doc') ->assertSeeText('公司主体变更证明.docx') ->assertSeeText('共用合同证明.docx') ->assertSeeText('授权委托书(快递).docx'); } public function testAgreementSigningPageIncludesSinglePageRequestFormAndLivePreview(): void { $this->grantWorkspaceAccess(); $this->loginAs() ->get(route('business.pages.show', [ 'section' => 'courier-payables', 'page' => 'agreement-signing', 'agreement_view' => 'create', ])) ->assertOk() ->assertSee('data-signing-request-form', false) ->assertSee('data-agreement-preview', false) ->assertSee('data-sign-request-send', false) ->assertDontSee('data-agreement-step-panel', false) ->assertSeeText('发起签章请求') ->assertSeeText('合作方类型') ->assertSee('name="partner_type" value="courier" checked', false) ->assertSee('name="partner_type" value="supplier"', false) ->assertSee('data-signing-supplier-id', false) ->assertSeeText('按供应商简称、企业全称或编码搜索,选择后自动带入易签宝账号。') ->assertSeeText('快递公司') ->assertSee('data-courier-search', false) ->assertSee('placeholder="输入快递名称搜索"', false) ->assertSee('aria-haspopup="listbox"', false) ->assertSee('data-courier-options', false) ->assertSeeText('文件类型') ->assertSeeText('收款账户证明') ->assertSeeText('TPL-ACCOUNT-CERT-V2') ->assertSeeText('我方签署主体') ->assertSeeText('公司全称') ->assertSee('name="company_full_name"', false) ->assertSee('data-company-name', false) ->assertSee('data-subject-linked-name', false) ->assertSeeText('签署截止日期') ->assertSeeText('对方 E 签宝账号') ->assertSeeText('对方签署主体类型') ->assertSee('对方签署个人姓名', false) ->assertSee('name="counterparty_signer_type"', false) ->assertSee('data-primary-esign-label', false) ->assertSee('data-secondary-esign-label', false) ->assertSee("labels.primary = '快递方 E 签宝账号'", false) ->assertSee("labels.secondary = '我方 E 签宝账号'", false) ->assertSee("labels.primary = '委托方 E 签宝账号'", false) ->assertSee("labels.secondary = '受托方 E 签宝账号'", false) ->assertSeeText('对方签署企业全称') ->assertSeeText('必须与对方 E 签宝企业认证名称一致') ->assertSeeText('对方 E 签宝实名认证姓名') ->assertSeeText('仅用于 E 签宝身份核验,不是收款人姓名') ->assertSee("setPreviewValue('proofSigner', '公司盖章')", false) ->assertSee("setPreviewValue('changeSigner', '公司盖章')", false) ->assertSeeText('先乙方后甲方') ->assertSee('value="18052733960" readonly', false) ->assertSee('name="secondary_operator_name"', false) ->assertSeeText('填写变量') ->assertSeeText('签署完成后自动归档') ->assertSeeText('人工确认后归档') ->assertSeeText('刷新预览') ->assertSeeText('推送至E签宝') ->assertSeeText('收款帐户资料证明'); } public function test_signing_page_exposes_supplier_account_and_search_identity_separately(): void { $this->grantWorkspaceAccess(); $repository = Mockery::mock(SupplierManagementMirrorRepository::class); $repository->shouldReceive('signingOptions')->once()->andReturn([[ 'id' => 7, 'value' => '测试供应商', 'code' => 'T007', 'company' => '测试供应商有限公司', 'account' => '13800138000', 'operator' => '张经理', ]]); $this->app->instance(SupplierManagementMirrorRepository::class, $repository); $response = $this->loginAs()->get(route('business.pages.show', ['section' => 'courier-payables', 'page' => 'agreement-signing', 'agreement_view' => 'create']))->assertOk(); $this->assertSame('13800138000', $response->viewData('agreementSupplierOptions')[0]['account']); $this->assertSame('张经理', $response->viewData('agreementSupplierOptions')[0]['operator']); } public function test_supplier_contract_templates_include_full_preview_and_editable_variables(): void { $this->grantWorkspaceAccess(); $response = $this->loginAs()->get(route('business.pages.show', [ 'section' => 'courier-payables', 'page' => 'agreement-signing', 'agreement_view' => 'create', ]))->assertOk(); foreach (['dropshipping', 'consignment', 'production'] as $template) { $response->assertSee('data-supplier-contract-preview="' . $template . '"', false); $response->assertSeeText(\App\Support\SupplierCooperationTemplates::TEMPLATES[$template]['name']); $response->assertSee(\App\Support\SupplierCooperationTemplates::TEMPLATES[$template]['code'], false); } $response->assertSee('name="supplier_contract_template"', false) ->assertSee('name="supplier_contract_fields[number]"', false) ->assertSee('data-supplier-bind="party_a"', false) ->assertSee('production-3.png', false) ->assertDontSeeText('供应商合作合同模板尚未提供'); } public function testAgreementSigningPageUsesCourierNamesFromCourierInformation(): void { $this->grantWorkspaceAccess(); $courierInformation = Mockery::mock(CourierInformationMirrorRepository::class); $courierInformation->shouldReceive('names') ->once() ->andReturn(['顺丰', '韵达']); $courierInformation->shouldReceive('signingAccountsByName') ->once() ->with(['顺丰', '韵达']) ->andReturn(['顺丰' => '13800000001']); $courierInformation->shouldReceive('contractPartiesByName')->once()->with(['顺丰', '韵达'])->andReturn([ '顺丰' => ['party_b' => '乙方顺丰物流有限公司', 'party_a' => '甲方商贸有限公司', 'ambiguous' => false], ]); $this->app->instance(CourierInformationMirrorRepository::class, $courierInformation); $response = $this->loginAs() ->get(route('business.pages.show', [ 'section' => 'courier-payables', 'page' => 'agreement-signing', 'agreement_view' => 'create', ])) ->assertOk() ->assertSee('data-courier-search', false) ->assertSee('data-courier-select required', false) ->assertSee('', false) ->assertSee('', false) ->assertSee('data-courier-contract-parties', false) ->assertDontSee('