44 lines
1.6 KiB
PowerShell
44 lines
1.6 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
function Read-ProjectFile {
|
|
param([string]$RelativePath)
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
Get-Content -Raw -Encoding UTF8 -LiteralPath (Join-Path $root $RelativePath)
|
|
}
|
|
|
|
function Require-Text {
|
|
param([string]$Content, [string]$Text, [string]$Label)
|
|
if (-not $Content.Contains($Text)) { throw "$Label missing: $Text" }
|
|
}
|
|
|
|
function Forbid-Text {
|
|
param([string]$Content, [string]$Text, [string]$Label)
|
|
if ($Content.Contains($Text)) { throw "$Label must not retain: $Text" }
|
|
}
|
|
|
|
$m01 = Read-ProjectFile 'pages/profile/m01-profile-home.vue'
|
|
$m02 = Read-ProjectFile 'pages/profile/m02-edit-profile.vue'
|
|
|
|
foreach ($stale in @('fixture', 'currentUser', 'state-card__copy')) {
|
|
Forbid-Text $m01 $stale 'M01'
|
|
Forbid-Text $m02 $stale 'M02'
|
|
}
|
|
|
|
foreach ($required in @('appApi.getProfile', 'onShow(loadProfile)', 'profile.nickName', 'profile.realName', 'profile.phone', 'profile.sex', 'profile.birthday', 'profile.email')) {
|
|
Require-Text $m01 $required 'M01'
|
|
}
|
|
foreach ($required in @('appApi.getProfile', 'appApi.updateProfile', 'pickAndUploadImage', 'form.nickName', 'form.realName', 'form.sex', 'form.birthday', 'form.email', 'avatarId', 'buildUpdatePayload')) {
|
|
Require-Text $m02 $required 'M02'
|
|
}
|
|
foreach ($required in @('const sexOptions', 'value: "0"', 'value: "1"', 'value: "2"', 'range-key="label"', '@change="changeSex"')) {
|
|
Require-Text $m02 $required 'M02'
|
|
}
|
|
foreach ($forbidden in @('readonly-value', 'form-row--readonly')) {
|
|
Forbid-Text $m02 $forbidden 'M02'
|
|
}
|
|
foreach ($forbidden in @('avatarOssId', 'coverOssId', 'fileId')) {
|
|
Forbid-Text $m02 $forbidden 'M02'
|
|
}
|
|
|
|
Write-Output 'PROFILE-PAGES-CONTRACT PASS'
|