@keber/qa-framework 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/integrations/ado-powershell/README.md +15 -6
- package/integrations/ado-powershell/scripts/create-testplan-from-mapping.ps1 +41 -30
- package/integrations/ado-powershell/scripts/inject-ado-ids.ps1 +70 -55
- package/integrations/ado-powershell/scripts/md-to-tc-mapping.ps1 +196 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -33,6 +33,32 @@ has been removed or parameterized. See `docs/comparison-matrix.md` and `docs/gen
|
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
36
|
+
## [1.9.1] - 2026-05-15
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- **`integrations/ado-powershell/scripts/md-to-tc-mapping.ps1`** — new script that parses a
|
|
41
|
+
Plan-de-Pruebas markdown file and generates `tc-mapping.json`. Reads the Tabla de Pruebas
|
|
42
|
+
table, detects columns dynamically, skips Bloqueado rows (PENDING-CODE), splits steps by
|
|
43
|
+
`<br>`, and strips leading numbering. Supports a `-TableSection` parameter for plans with
|
|
44
|
+
non-standard headings. This was previously missing from the framework, forcing agents to
|
|
45
|
+
implement ad-hoc parsers in each project.
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
- **`create-testplan-from-mapping.ps1`** — removed Unicode characters that caused
|
|
50
|
+
`MissingArrayIndexExpression` parser errors in PowerShell 5.1.
|
|
51
|
+
- **`create-testplan-from-mapping.ps1`** — added auto-load of `ado-powershell` skill when
|
|
52
|
+
`New-AdoTestCase` is not yet in scope; script no longer requires manual dot-sourcing before
|
|
53
|
+
invocation.
|
|
54
|
+
- **`create-testplan-from-mapping.ps1`** — added fallback to `$mapping.items` when
|
|
55
|
+
`$mapping.testCases` is absent, for compatibility with mappings generated by older sessions.
|
|
56
|
+
- **`inject-ado-ids.ps1`** — fixed broken regex (`\Q...\E` is not valid PowerShell); replaced
|
|
57
|
+
with `[regex]::Escape()`. Added `-AdonIdsDir` parameter to process all `ado-ids-*.json`
|
|
58
|
+
files in a directory in one pass. Added `-DryRun` switch. Fixed UTF-8 encoding on write.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
36
62
|
## [1.9.0] - 2026-05-15
|
|
37
63
|
|
|
38
64
|
### Changed
|
|
@@ -7,8 +7,9 @@ All scripts are parameterized and project-agnostic.
|
|
|
7
7
|
|
|
8
8
|
| Script | Purpose |
|
|
9
9
|
|--------|---------|
|
|
10
|
-
| `scripts/
|
|
11
|
-
| `scripts/create-testplan-from-mapping.ps1` | Create ADO Test Cases from
|
|
10
|
+
| `scripts/md-to-tc-mapping.ps1` | Parse a Plan-de-Pruebas markdown and generate `tc-mapping.json` |
|
|
11
|
+
| `scripts/create-testplan-from-mapping.ps1` | Create ADO Test Cases from `tc-mapping.json` |
|
|
12
|
+
| `scripts/inject-ado-ids.ps1` | Inject ADO WI IDs into Playwright spec file test titles |
|
|
12
13
|
| `scripts/sync-ado-titles.ps1` | Sync spec file test titles back to ADO WI titles |
|
|
13
14
|
| `pipelines/azure-pipeline-qa.yml` | CI pipeline template for running Playwright + ADO sync |
|
|
14
15
|
|
|
@@ -25,10 +26,18 @@ All scripts are parameterized and project-agnostic.
|
|
|
25
26
|
# 0. Load the ADO skill (initialises session from env vars)
|
|
26
27
|
. .github/skills/ado-powershell/load.ps1
|
|
27
28
|
|
|
28
|
-
# 1.
|
|
29
|
-
.\scripts\
|
|
30
|
-
-
|
|
31
|
-
-
|
|
29
|
+
# 1. Parse Plan de Pruebas markdown -> tc-mapping.json
|
|
30
|
+
.\node_modules\@keber\qa-framework\integrations\ado-powershell\scripts\md-to-tc-mapping.ps1 `
|
|
31
|
+
-PlanFile "qa/02-test-plans/sprints/Sprint-N/Plan-de-Pruebas-MyProject-Sprint-N-MOD-SUB.md" `
|
|
32
|
+
-SpecFile "mod/sub.spec.ts" `
|
|
33
|
+
-OutputFile "qa/08-azure-integration/tc-mapping-e2e-mod-sub.json" `
|
|
34
|
+
-PlanId <PLAN_ID> `
|
|
35
|
+
-SuiteId <SUITE_ID>
|
|
36
|
+
|
|
37
|
+
# 2. Create Test Cases in ADO from tc-mapping.json (session already loaded above)
|
|
38
|
+
.\node_modules\@keber\qa-framework\integrations\ado-powershell\scripts\create-testplan-from-mapping.ps1 `
|
|
39
|
+
-PlanId <PLAN_ID> `
|
|
40
|
+
-MappingFile "qa/08-azure-integration/tc-mapping-e2e-mod-sub.json"
|
|
32
41
|
|
|
33
42
|
# 2. Inject ADO IDs into spec files (idempotent)
|
|
34
43
|
.\scripts\inject-ado-ids.ps1 `
|
|
@@ -41,9 +41,19 @@ param(
|
|
|
41
41
|
Set-StrictMode -Version Latest
|
|
42
42
|
$ErrorActionPreference = 'Stop'
|
|
43
43
|
|
|
44
|
-
#
|
|
44
|
+
# Auto-load ADO session if not already active
|
|
45
45
|
if (-not (Get-Command 'New-AdoTestCase' -ErrorAction SilentlyContinue)) {
|
|
46
|
-
|
|
46
|
+
$loadScript = Join-Path $PSScriptRoot '..\..\..\node_modules\@keber\ado-powershell\.github\skills\ado-powershell\load.ps1'
|
|
47
|
+
if (Test-Path $loadScript) {
|
|
48
|
+
. $loadScript
|
|
49
|
+
} else {
|
|
50
|
+
Write-Error "ADO session not loaded and load.ps1 not found. Run: . node_modules\@keber\ado-powershell\.github\skills\ado-powershell\load.ps1"
|
|
51
|
+
exit 1
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (-not (Get-Command 'New-AdoTestCase' -ErrorAction SilentlyContinue)) {
|
|
56
|
+
Write-Error "New-AdoTestCase not available after loading ado-powershell. Check the skill version (requires >= 1.3.0)."
|
|
47
57
|
exit 1
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -53,40 +63,41 @@ $mapping = Get-Content $MappingFile -Raw | ConvertFrom-Json
|
|
|
53
63
|
|
|
54
64
|
$suiteId = if ($SuiteId -gt 0) { $SuiteId } else { $mapping.suiteId }
|
|
55
65
|
|
|
56
|
-
|
|
66
|
+
# Support both 'testCases' (canonical) and 'items' (legacy)
|
|
67
|
+
$tcList = if ($mapping.PSObject.Properties['testCases']) { $mapping.testCases } else { $mapping.items }
|
|
68
|
+
|
|
69
|
+
Write-Host "[create-testplan] Creating $($tcList.Count) test cases in Plan $PlanId / Suite $suiteId"
|
|
57
70
|
|
|
58
71
|
$results = @()
|
|
59
72
|
|
|
60
|
-
foreach ($tc in $
|
|
73
|
+
foreach ($tc in $tcList) {
|
|
61
74
|
$steps = if ($tc.PSObject.Properties['steps']) { $tc.steps } else { @() }
|
|
62
75
|
$expectedResult = if ($tc.PSObject.Properties['expectedResult']) { $tc.expectedResult } else { '' }
|
|
63
76
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
$
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
$
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
title = $tc.title
|
|
86
|
-
}
|
|
87
|
-
} catch {
|
|
88
|
-
Write-Warning " [FAILED] $($tc.localId) — $($_.Exception.Message)"
|
|
77
|
+
try {
|
|
78
|
+
$splatArgs = @{
|
|
79
|
+
Title = "[$($tc.localId)] $($tc.title)"
|
|
80
|
+
Confirm = $false
|
|
81
|
+
}
|
|
82
|
+
if ($steps.Count -gt 0) {
|
|
83
|
+
$splatArgs.Steps = $steps
|
|
84
|
+
$splatArgs.ExpectedResult = $expectedResult
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
$wi = New-AdoTestCase @splatArgs
|
|
88
|
+
$wiId = $wi.id
|
|
89
|
+
Write-Host " [CREATED] $($tc.localId) -> WI #$wiId"
|
|
90
|
+
|
|
91
|
+
Add-AdoTestCaseToSuite -PlanId $PlanId -SuiteId $suiteId -TestCaseIds @($wiId) -Confirm:$false
|
|
92
|
+
|
|
93
|
+
$results += [PSCustomObject]@{
|
|
94
|
+
localId = $tc.localId
|
|
95
|
+
adoWiId = $wiId
|
|
96
|
+
specFile = $tc.specFile
|
|
97
|
+
title = $tc.title
|
|
89
98
|
}
|
|
99
|
+
} catch {
|
|
100
|
+
Write-Warning " [FAILED] $($tc.localId) -- $($_.Exception.Message)"
|
|
90
101
|
}
|
|
91
102
|
}
|
|
92
103
|
|
|
@@ -94,6 +105,6 @@ foreach ($tc in $mapping.testCases) {
|
|
|
94
105
|
$outFile = if ($OutputFile) { $OutputFile } else {
|
|
95
106
|
Join-Path (Split-Path $MappingFile) 'ado-ids.json'
|
|
96
107
|
}
|
|
97
|
-
$results | ConvertTo-Json -Depth 5 | Set-Content $outFile
|
|
108
|
+
$results | ConvertTo-Json -Depth 5 | Set-Content $outFile -Encoding UTF8
|
|
98
109
|
Write-Host ""
|
|
99
110
|
Write-Host "[create-testplan] Done. $($results.Count) WIs created. Output: $outFile"
|
|
@@ -3,94 +3,109 @@
|
|
|
3
3
|
Prepends Azure DevOps Work Item IDs to Playwright spec file test titles.
|
|
4
4
|
|
|
5
5
|
.DESCRIPTION
|
|
6
|
-
Reads ado-ids
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
Reads one or more ado-ids-*.json files and updates every matching test()
|
|
7
|
+
call in the spec files to include the ADO WI ID as a [NNNNN] prefix.
|
|
8
|
+
This operation is IDEMPOTENT: if the ID is already present, it is skipped.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
Two modes:
|
|
11
|
+
-MappingFile Process a single ado-ids.json file (backward-compatible).
|
|
12
|
+
-AdonIdsDir Process all ado-ids-*.json files found in a directory.
|
|
12
13
|
|
|
13
14
|
.PARAMETER SpecDir
|
|
14
|
-
Root directory containing Playwright spec files (.spec.ts).
|
|
15
|
-
Searched recursively.
|
|
15
|
+
Root directory containing Playwright spec files (.spec.ts). Searched recursively.
|
|
16
16
|
|
|
17
17
|
.PARAMETER MappingFile
|
|
18
|
-
Path to ado-ids.json
|
|
18
|
+
Path to a single ado-ids.json file. Mutually exclusive with -AdonIdsDir.
|
|
19
|
+
|
|
20
|
+
.PARAMETER AdonIdsDir
|
|
21
|
+
Directory containing ado-ids-*.json files. All matching files are processed.
|
|
22
|
+
Mutually exclusive with -MappingFile.
|
|
23
|
+
|
|
24
|
+
.PARAMETER DryRun
|
|
25
|
+
Shows what would be changed without modifying any files.
|
|
19
26
|
|
|
20
27
|
.EXAMPLE
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
# Single file
|
|
29
|
+
.\inject-ado-ids.ps1 -SpecDir "qa/07-automation/e2e/tests" -MappingFile "qa/08-azure-integration/ado-ids.json"
|
|
30
|
+
|
|
31
|
+
.EXAMPLE
|
|
32
|
+
# All ado-ids-*.json files in a directory
|
|
33
|
+
.\inject-ado-ids.ps1 -SpecDir "qa/07-automation/e2e/tests" -AdonIdsDir "qa/08-azure-integration"
|
|
24
34
|
|
|
25
35
|
.NOTES
|
|
26
36
|
Does NOT require a network connection or ADO token.
|
|
27
37
|
Commit the modified spec files after running.
|
|
28
38
|
#>
|
|
29
|
-
[CmdletBinding(
|
|
39
|
+
[CmdletBinding()]
|
|
30
40
|
param(
|
|
31
41
|
[Parameter(Mandatory)]
|
|
32
42
|
[string] $SpecDir,
|
|
33
43
|
|
|
34
|
-
[Parameter(Mandatory)]
|
|
35
|
-
[string] $MappingFile
|
|
44
|
+
[Parameter(ParameterSetName='SingleFile', Mandatory)]
|
|
45
|
+
[string] $MappingFile,
|
|
46
|
+
|
|
47
|
+
[Parameter(ParameterSetName='MultiFile', Mandatory)]
|
|
48
|
+
[string] $AdonIdsDir,
|
|
49
|
+
|
|
50
|
+
[switch] $DryRun
|
|
36
51
|
)
|
|
37
52
|
|
|
38
53
|
Set-StrictMode -Version Latest
|
|
39
54
|
$ErrorActionPreference = 'Stop'
|
|
40
55
|
|
|
41
|
-
#
|
|
42
|
-
if (
|
|
43
|
-
Write-Error "
|
|
44
|
-
|
|
56
|
+
# Collect input files based on mode
|
|
57
|
+
$adoIdFiles = if ($PSCmdlet.ParameterSetName -eq 'SingleFile') {
|
|
58
|
+
if (-not (Test-Path $MappingFile)) { Write-Error "Not found: $MappingFile"; exit 1 }
|
|
59
|
+
@(Get-Item $MappingFile)
|
|
60
|
+
} else {
|
|
61
|
+
@(Get-ChildItem -Path $AdonIdsDir -Filter 'ado-ids-*.json')
|
|
45
62
|
}
|
|
46
|
-
$mapping = Get-Content $MappingFile -Raw | ConvertFrom-Json
|
|
47
63
|
|
|
48
|
-
Write-Host "[inject-ado-ids]
|
|
64
|
+
Write-Host "[inject-ado-ids] Processing $($adoIdFiles.Count) mapping file(s)"
|
|
49
65
|
|
|
50
|
-
$
|
|
51
|
-
$
|
|
66
|
+
$totalUpdated = 0
|
|
67
|
+
$totalSkipped = 0
|
|
52
68
|
|
|
53
|
-
foreach ($
|
|
54
|
-
$
|
|
55
|
-
$
|
|
69
|
+
foreach ($f in $adoIdFiles) {
|
|
70
|
+
$entries = Get-Content $f.FullName -Raw | ConvertFrom-Json
|
|
71
|
+
if ($entries -isnot [array]) { $entries = @($entries) }
|
|
72
|
+
Write-Host " $($f.Name) ($($entries.Count) entries)"
|
|
56
73
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
foreach ($entry in $entries) {
|
|
75
|
+
$localId = $entry.localId
|
|
76
|
+
$wiId = $entry.adoWiId
|
|
77
|
+
$specHint = $entry.specFile
|
|
61
78
|
|
|
62
|
-
|
|
63
|
-
$
|
|
79
|
+
$specHintNorm = $specHint -replace '/', '\'
|
|
80
|
+
$specFiles = Get-ChildItem -Path $SpecDir -Recurse -Filter '*.spec.ts' |
|
|
81
|
+
Where-Object { $_.FullName -like "*$specHintNorm*" }
|
|
64
82
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
$escapedId = [regex]::Escape($localId)
|
|
83
|
+
foreach ($sf in $specFiles) {
|
|
84
|
+
$content = Get-Content $sf.FullName -Raw
|
|
85
|
+
$wiPrefix = "[$wiId]"
|
|
69
86
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
87
|
+
# Idempotent: skip if this wiId is already associated with this localId
|
|
88
|
+
if ($content -match "$([regex]::Escape($wiPrefix)).*$([regex]::Escape($localId))") {
|
|
89
|
+
$totalSkipped++
|
|
90
|
+
continue
|
|
91
|
+
}
|
|
76
92
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
$
|
|
93
|
+
# Inject [wiId] before the title of any test containing this localId
|
|
94
|
+
$escaped = [regex]::Escape($localId)
|
|
95
|
+
$pattern = "(test(?:\.(?:skip|fail|fixme))?\s*\(\s*['""])(?!\[$wiId\])([^'""]*$escaped)"
|
|
96
|
+
$replacement = "`${1}$wiPrefix `${2}"
|
|
97
|
+
$newContent = [regex]::Replace($content, $pattern, $replacement)
|
|
98
|
+
|
|
99
|
+
if ($newContent -ne $content) {
|
|
100
|
+
if (-not $DryRun) {
|
|
101
|
+
[System.IO.File]::WriteAllText($sf.FullName, $newContent, [System.Text.Encoding]::UTF8)
|
|
102
|
+
}
|
|
103
|
+
Write-Host " [UPDATED] $($sf.Name) -- injected $wiPrefix for $localId$(if($DryRun){' (dry run)'})"
|
|
104
|
+
$totalUpdated++
|
|
88
105
|
}
|
|
89
|
-
} else {
|
|
90
|
-
Write-Verbose " [NO MATCH] $localId not found by pattern in $($file.Name)"
|
|
91
106
|
}
|
|
92
107
|
}
|
|
93
108
|
}
|
|
94
109
|
|
|
95
110
|
Write-Host ""
|
|
96
|
-
Write-Host "[inject-ado-ids] Done. Updated
|
|
111
|
+
Write-Host "[inject-ado-ids] Done. Updated=$totalUpdated Skipped=$totalSkipped$(if($DryRun){' (DRY RUN)'})"
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<#
|
|
2
|
+
.SYNOPSIS
|
|
3
|
+
Generates a tc-mapping.json from a Plan-de-Pruebas markdown file.
|
|
4
|
+
|
|
5
|
+
.DESCRIPTION
|
|
6
|
+
Reads the "Tabla de Pruebas" table in a Plan-de-Pruebas markdown file,
|
|
7
|
+
skips rows with Tipo = "Bloqueado" (PENDING-CODE), splits Steps by <br>,
|
|
8
|
+
and outputs a tc-mapping.json compatible with create-testplan-from-mapping.ps1.
|
|
9
|
+
|
|
10
|
+
Paths are resolved relative to the current working directory (project root).
|
|
11
|
+
Always run this script from the project root.
|
|
12
|
+
|
|
13
|
+
.PARAMETER PlanFile
|
|
14
|
+
Path to the Plan-de-Pruebas-*.md file to parse (relative to project root or absolute).
|
|
15
|
+
|
|
16
|
+
.PARAMETER SpecFile
|
|
17
|
+
Relative path to the Playwright spec file (e.g. "reg/apl.spec.ts").
|
|
18
|
+
Stored as metadata in the output; not validated by this script.
|
|
19
|
+
|
|
20
|
+
.PARAMETER OutputFile
|
|
21
|
+
Path to write the tc-mapping.json output (relative to project root or absolute).
|
|
22
|
+
|
|
23
|
+
.PARAMETER PlanId
|
|
24
|
+
ADO Test Plan ID to embed in the JSON. Fill in after creating the plan (default: 0).
|
|
25
|
+
|
|
26
|
+
.PARAMETER SuiteId
|
|
27
|
+
ADO Test Suite ID to embed in the JSON. Fill in after creating the suite (default: 0).
|
|
28
|
+
|
|
29
|
+
.PARAMETER TableSection
|
|
30
|
+
Heading text of the table section to parse. Defaults to "Tabla de Pruebas".
|
|
31
|
+
Use the exact heading text if your plan uses a different section name
|
|
32
|
+
(e.g. "6. Casos de prueba").
|
|
33
|
+
|
|
34
|
+
.EXAMPLE
|
|
35
|
+
.\integrations\ado-powershell\scripts\md-to-tc-mapping.ps1 `
|
|
36
|
+
-PlanFile "qa/02-test-plans/sprints/Sprint-2/Plan-de-Pruebas-MyProject-Sprint-2-REG-APL.md" `
|
|
37
|
+
-SpecFile "reg/apl.spec.ts" `
|
|
38
|
+
-OutputFile "qa/08-azure-integration/tc-mapping-e2e-reg-apl.json"
|
|
39
|
+
|
|
40
|
+
.EXAMPLE
|
|
41
|
+
# For plans where the table is under a different heading:
|
|
42
|
+
.\integrations\ado-powershell\scripts\md-to-tc-mapping.ps1 `
|
|
43
|
+
-PlanFile "qa/02-test-plans/sprints/Sprint-10/Plan-de-Pruebas-MyProject-Sprint-10-MOD-API-Neg.md" `
|
|
44
|
+
-SpecFile "mod.api.negative.spec.ts" `
|
|
45
|
+
-OutputFile "qa/08-azure-integration/tc-mapping-api-mod-neg.json" `
|
|
46
|
+
-TableSection "6. Casos de prueba"
|
|
47
|
+
#>
|
|
48
|
+
param(
|
|
49
|
+
[Parameter(Mandatory)][string]$PlanFile,
|
|
50
|
+
[Parameter(Mandatory)][string]$SpecFile,
|
|
51
|
+
[Parameter(Mandatory)][string]$OutputFile,
|
|
52
|
+
[int]$PlanId = 0,
|
|
53
|
+
[int]$SuiteId = 0,
|
|
54
|
+
[string]$TableSection = 'Tabla de Pruebas'
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
Set-StrictMode -Version Latest
|
|
58
|
+
$ErrorActionPreference = 'Stop'
|
|
59
|
+
|
|
60
|
+
function Trim-Cell([string]$cell) { return $cell.Trim() }
|
|
61
|
+
|
|
62
|
+
# Resolve paths relative to current working directory (project root)
|
|
63
|
+
$WorkspaceRoot = (Get-Location).Path
|
|
64
|
+
if (-not [System.IO.Path]::IsPathRooted($PlanFile)) {
|
|
65
|
+
$PlanFile = Join-Path $WorkspaceRoot $PlanFile
|
|
66
|
+
}
|
|
67
|
+
if (-not [System.IO.Path]::IsPathRooted($OutputFile)) {
|
|
68
|
+
$OutputFile = Join-Path $WorkspaceRoot $OutputFile
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (-not (Test-Path $PlanFile)) {
|
|
72
|
+
throw "Plan file not found: $PlanFile"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
$lines = Get-Content $PlanFile -Encoding UTF8
|
|
76
|
+
|
|
77
|
+
# Find the table section (configurable heading)
|
|
78
|
+
$tableStart = -1
|
|
79
|
+
for ($i = 0; $i -lt $lines.Count; $i++) {
|
|
80
|
+
if ($lines[$i] -match "##\s+$([regex]::Escape($TableSection))") {
|
|
81
|
+
$tableStart = $i + 1
|
|
82
|
+
break
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if ($tableStart -lt 0) {
|
|
86
|
+
throw "Section '## $TableSection' not found in: $PlanFile"
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# Find the header row (first line starting with |)
|
|
90
|
+
$headerIdx = -1
|
|
91
|
+
for ($i = $tableStart; $i -lt $lines.Count; $i++) {
|
|
92
|
+
if ($lines[$i].TrimStart().StartsWith('|')) {
|
|
93
|
+
$headerIdx = $i
|
|
94
|
+
break
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if ($headerIdx -lt 0) {
|
|
98
|
+
throw "Table header row not found after '## $TableSection'"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# Parse header to find column indices dynamically
|
|
102
|
+
$headerCells = $lines[$headerIdx] -split '\|' | Where-Object { $_ -ne '' }
|
|
103
|
+
$colMap = @{}
|
|
104
|
+
for ($c = 0; $c -lt $headerCells.Count; $c++) {
|
|
105
|
+
$name = (Trim-Cell $headerCells[$c]).ToLower()
|
|
106
|
+
$colMap[$name] = $c
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# Determine column indices (handle both E2E and API table formats)
|
|
110
|
+
$idxTcId = if ($colMap.ContainsKey('tc-id')) { $colMap['tc-id'] } else { 1 }
|
|
111
|
+
$idxTitulo = if ($colMap.ContainsKey('titulo')) { $colMap['titulo'] } else { 3 }
|
|
112
|
+
$idxSteps = if ($colMap.ContainsKey('steps')) { $colMap['steps'] } `
|
|
113
|
+
elseif ($colMap.ContainsKey('pasos')) { $colMap['pasos'] } else { 5 }
|
|
114
|
+
$idxResult = if ($colMap.ContainsKey('resultado esperado')) { $colMap['resultado esperado'] } else { 6 }
|
|
115
|
+
$idxTipo = if ($colMap.ContainsKey('tipo')) { $colMap['tipo'] } else { -1 }
|
|
116
|
+
|
|
117
|
+
# Data rows start after header + separator
|
|
118
|
+
$dataStart = $headerIdx + 2
|
|
119
|
+
|
|
120
|
+
$tcList = [System.Collections.Generic.List[hashtable]]::new()
|
|
121
|
+
|
|
122
|
+
for ($i = $dataStart; $i -lt $lines.Count; $i++) {
|
|
123
|
+
$line = $lines[$i].TrimStart()
|
|
124
|
+
|
|
125
|
+
# Stop at blank line or next section heading
|
|
126
|
+
if ($line -eq '' -or $line.StartsWith('#')) { break }
|
|
127
|
+
if (-not $line.StartsWith('|')) { continue }
|
|
128
|
+
|
|
129
|
+
# Split row into cells, strip leading empty element
|
|
130
|
+
$cells = $lines[$i] -split '\|'
|
|
131
|
+
if ($cells[0] -eq '' -or $cells[0] -match '^\s*$') {
|
|
132
|
+
$cells = $cells[1..($cells.Count - 1)]
|
|
133
|
+
}
|
|
134
|
+
if ($cells.Count -lt 3) { continue }
|
|
135
|
+
|
|
136
|
+
function Get-Cell([string[]]$arr, [int]$idx) {
|
|
137
|
+
if ($idx -ge 0 -and $idx -lt $arr.Count) { return (Trim-Cell $arr[$idx]) }
|
|
138
|
+
return ''
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
$tipo = Get-Cell $cells $idxTipo
|
|
142
|
+
$tcId = Get-Cell $cells $idxTcId
|
|
143
|
+
$titulo = Get-Cell $cells $idxTitulo
|
|
144
|
+
$steps = Get-Cell $cells $idxSteps
|
|
145
|
+
$result = Get-Cell $cells $idxResult
|
|
146
|
+
|
|
147
|
+
# Skip sub-header rows or empty rows
|
|
148
|
+
if ($tcId -eq '' -or $tcId -eq 'TC-ID') { continue }
|
|
149
|
+
|
|
150
|
+
# Skip blocked TCs (PENDING-CODE)
|
|
151
|
+
if ($tipo -ieq 'Bloqueado') {
|
|
152
|
+
Write-Host " [skip] $tcId - Bloqueado (PENDING-CODE)" -ForegroundColor DarkYellow
|
|
153
|
+
continue
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
# Fallback: use Descripcion column as title if Titulo is absent
|
|
157
|
+
if ($titulo -eq '' -or $titulo -eq 'N/A') {
|
|
158
|
+
$idxDesc = if ($colMap.ContainsKey('descripcion')) { $colMap['descripcion'] } else { 1 }
|
|
159
|
+
$titulo = Get-Cell $cells $idxDesc
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
# Parse steps: split on <br>, strip leading numbering (e.g. "1. ", "2) ")
|
|
163
|
+
$stepList = @()
|
|
164
|
+
if ($steps -ne '' -and $steps -ne 'N/A') {
|
|
165
|
+
$rawSteps = $steps -split '(?i)<br\s*/?>'
|
|
166
|
+
foreach ($s in $rawSteps) {
|
|
167
|
+
$cleaned = $s.Trim() -replace '^\d+[\.\)]\s*', ''
|
|
168
|
+
if ($cleaned -ne '') { $stepList += $cleaned }
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
$tcList.Add(@{
|
|
173
|
+
localId = $tcId
|
|
174
|
+
title = $titulo
|
|
175
|
+
specFile = $SpecFile
|
|
176
|
+
steps = $stepList
|
|
177
|
+
expectedResult = $result
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
$output = @{
|
|
182
|
+
planId = $PlanId
|
|
183
|
+
suiteId = $SuiteId
|
|
184
|
+
testCases = @($tcList)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
# Ensure output directory exists
|
|
188
|
+
$outputDir = Split-Path $OutputFile
|
|
189
|
+
if (-not (Test-Path $outputDir)) {
|
|
190
|
+
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
$json = $output | ConvertTo-Json -Depth 10
|
|
194
|
+
[System.IO.File]::WriteAllText($OutputFile, $json, [System.Text.Encoding]::UTF8)
|
|
195
|
+
|
|
196
|
+
Write-Host "(ok) Generated $($tcList.Count) TC mappings -> $OutputFile" -ForegroundColor Green
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keber/qa-framework",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "Reusable spec-driven QA framework for IDE-agent-assisted automated testing. Installable as an npm package. Provides structure, templates, agent instructions, and optional integrations for Playwright and Azure DevOps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"qa",
|