user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); } 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('快递合作合同使用我方账号 18052733960') ->assertSeeText('我方 E 签宝实名认证姓名') ->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('