@digital-commons-official/codeceptjs-storyboard 3.1.1 → 3.2.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/README.md CHANGED
@@ -157,14 +157,16 @@ For example, `storyboards/login/sign-in.md` can link to `../../screenshots/base/
157
157
  Runtime Markdown references actual captures and, for a failure, the expected/diff/actual images. Keep `_output/` and `screenshots/` in their original relative layout when downloading reports. A Markdown file alone does not include its images. SVG is the self-contained option. Repository rendering does not imply that GitLab's CI artifact viewer previews Markdown.
158
158
 
159
159
  Markdown keeps chapters, sentence order, annotations, multilingual keywords and failure information.
160
- The report starts with its recorded outcome and frame/step counts, followed by links to chapters,
160
+ The page title is the scenario, with the feature on the line below, named with the keyword of its
161
+ feature file. The report then gives its recorded outcome and frame/step counts, followed by links to chapters,
161
162
  the result and replay information. A standalone render without an explicit outcome says
162
163
  "Outcome not recorded"; it does not infer success from the absence of a visual failure.
163
164
 
164
165
  Each chapter starts with a plain Markdown heading. Screenshots sit in two equal-width columns by default. Each card keeps
165
166
  its title, image, note and copyable command together. Each pair has its own table so GitLab does not put
166
- an entire chapter inside one scrolling region. Commands fold within their card; replay and source
167
- details fold at the end. A failed comparison keeps Expected / Diff / Actual and unavailable-image
167
+ an entire chapter inside one scrolling region. A one-line command shows under its note as inline code,
168
+ which wraps, so both columns keep their width; a command on several lines shows as an open code block.
169
+ Replay and source details fold at the end. A failed comparison keeps Expected / Diff / Actual and unavailable-image
168
170
  labels visible, regardless of the details setting.
169
171
 
170
172
  ### Markdown layout
@@ -185,7 +187,7 @@ storyboard: {
185
187
 
186
188
  The example shows the defaults. Set `columns: 1` for full-width cards, especially when reading on
187
189
  narrow screens. GitLab tables do not automatically stack like a responsive HTML grid.
188
- Set `technicalDetails: 'expanded'` to open commands and replay/source details, or
190
+ Set `technicalDetails: 'expanded'` to open the replay and source details, or
189
191
  `tableOfContents: false` to omit navigation. Neither option removes evidence or notes.
190
192
 
191
193
  Unsupported options and invalid layout values raise a clear error before the plugin registers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-commons-official/codeceptjs-storyboard",
3
- "version": "3.1.1",
3
+ "version": "3.2.1",
4
4
  "description": "Storyboard plugin for CodeceptJS: one Gherkin sentence = one card = one pixel baseline, with Markdown or SVG reports",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/gherkin.js CHANGED
@@ -102,7 +102,7 @@ function readScenario (file, title, { occurrence = 0 } = {}) {
102
102
  sourceLine: step.location.line
103
103
  }
104
104
  })
105
- return { lines, keyword: scenario.keyword, title: pickle.name, exampleLine: example ? example.line : null }
105
+ return { lines, keyword: scenario.keyword, featureKeyword: document.feature.keyword, title: pickle.name, exampleLine: example ? example.line : null }
106
106
  }
107
107
 
108
108
  module.exports = { readScenario }
package/src/index.d.ts CHANGED
@@ -107,7 +107,7 @@ export interface MarkdownPresentation {
107
107
  columns?: 1 | 2
108
108
  /** Show chapter/result/replay navigation; defaults to true. */
109
109
  tableOfContents?: boolean
110
- /** Commands and replay/source details; defaults to collapsed. */
110
+ /** Replay and source details; defaults to collapsed. Card commands always show. */
111
111
  technicalDetails?: 'collapsed' | 'expanded'
112
112
  }
113
113
 
package/src/index.js CHANGED
@@ -86,6 +86,7 @@ function begin (meta) {
86
86
  feature: meta.feature || '',
87
87
  scenario: scenario ? scenario.title : (meta.scenario || ''),
88
88
  scenarioKeyword: scenario ? scenario.keyword : 'Scenario',
89
+ featureKeyword: scenario ? scenario.featureKeyword : 'Feature',
89
90
  exampleLine: scenario ? scenario.exampleLine : null,
90
91
  file: meta.file || '',
91
92
  rerun: meta.rerun || '',
package/src/markdown.js CHANGED
@@ -18,6 +18,16 @@ function codeBlock (value, language = '') {
18
18
  return `${fence}${language}\n${content}\n${fence}`
19
19
  }
20
20
 
21
+ // Inline code wraps in GitLab cells; a code block would widen its column.
22
+ function command (value) {
23
+ const content = String(value)
24
+ if (/[\r\n]/.test(content)) return codeBlock(content, 'shell')
25
+ const runs = content.match(/`+/g) || []
26
+ const ticks = '`'.repeat(Math.max(1, ...runs.map(run => run.length + 1)))
27
+ const pad = /^[ `]|[ `]$/.test(content) ? ' ' : ''
28
+ return `${ticks}${pad}${content}${pad}${ticks}`
29
+ }
30
+
21
31
  function relativeLink (outFile, file) {
22
32
  return path.relative(path.dirname(outFile), file).split(path.sep)
23
33
  .map(segment => encodeURIComponent(segment).replace(/[!'()*]/g, character => `%${character.charCodeAt(0).toString(16).toUpperCase()}`))
@@ -56,11 +66,10 @@ function details (title, content, presentation) {
56
66
  return `<details${open}>\n<summary>${title}</summary>\n\n${content}\n\n</details>`
57
67
  }
58
68
 
59
- function annotations (card, presentation) {
60
- if (!card.note && !card.copy) return []
69
+ function annotations (card) {
61
70
  return [
62
71
  ...(card.note ? [text(card.note)] : []),
63
- ...(card.copy ? [details('Command', codeBlock(card.copy, 'shell'), presentation)] : [])
72
+ ...(card.copy ? [command(card.copy)] : [])
64
73
  ]
65
74
  }
66
75
 
@@ -68,11 +77,11 @@ function pair (outFile, cards, presentation) {
68
77
  const columns = presentation.columns === 2 && cards.length === 1 ? [...cards, null] : cards
69
78
  const width = 100 / presentation.columns
70
79
  const headings = columns.map(card => `<th width="${width}%">\n\n${card ? `**${card.number}. ${caption(card.title)}**` : ''}\n\n</th>`)
71
- const bodies = columns.map(card => `<td width="${width}%" valign="top">\n\n${card ? [image(outFile, card.file, card.title), ...annotations(card, presentation)].join('\n\n') : ''}\n\n</td>`)
80
+ const bodies = columns.map(card => `<td width="${width}%" valign="top">\n\n${card ? [image(outFile, card.file, card.title), ...annotations(card)].join('\n\n') : ''}\n\n</td>`)
72
81
  return `<table width="100%">\n<tr>\n${headings.join('\n')}\n</tr>\n<tr>\n${bodies.join('\n')}\n</tr>\n</table>`
73
82
  }
74
83
 
75
- function comparison (outFile, card, frame, presentation) {
84
+ function comparison (outFile, card, frame) {
76
85
  const pictures = [
77
86
  image(outFile, frame.baseline, 'Expected'),
78
87
  frame.diff ? image(outFile, frame.diff, 'Diff') : '(not generated)',
@@ -86,7 +95,7 @@ function comparison (outFile, card, frame, presentation) {
86
95
  `**${label[0].toUpperCase() + label.slice(1)} path**`,
87
96
  codeBlock(paths[label] || '(not available)')
88
97
  ]),
89
- ...annotations(card, presentation)
98
+ ...annotations(card)
90
99
  ]
91
100
  }
92
101
 
@@ -98,8 +107,8 @@ function renderMarkdown (board, outFile, options = {}) {
98
107
  const chapters = cards.filter(card => card.chapter)
99
108
  const summary = `${board.lines.length || board.panels.length} steps · ${cards.length} frames`
100
109
  const chunks = [
101
- `# ${caption(board.feature || 'Storyboard')}`,
102
- `**${caption(board.scenarioKeyword || 'Scenario')}:** ${caption(board.scenario)}`,
110
+ `# ${caption(board.scenario || board.feature || 'Storyboard')}`,
111
+ ...(board.scenario && board.feature ? [`**${caption(board.featureKeyword || 'Feature')}:** ${caption(board.feature)}`] : []),
103
112
  '<a name="storyboard-result"></a>',
104
113
  `> [!${verdict === 'FAILED' ? 'caution' : verdict === 'PASSED' ? 'tip' : 'note'}] ${verdict}\n> ${summary}`
105
114
  ]
@@ -124,7 +133,7 @@ function renderMarkdown (board, outFile, options = {}) {
124
133
  }
125
134
  if (failure && failure.frame && path.basename(card.file) === failure.frame.name) {
126
135
  flush()
127
- chunks.push(...comparison(outFile, card, failure.frame, presentation))
136
+ chunks.push(...comparison(outFile, card, failure.frame))
128
137
  } else {
129
138
  pending.push(card)
130
139
  if (pending.length === presentation.columns) flush()
@@ -137,7 +146,7 @@ function renderMarkdown (board, outFile, options = {}) {
137
146
  chunks.push('<a name="storyboard-replay"></a>', details('Replay this scenario · source and checks', [
138
147
  ...(board.rerun ? [codeBlock(board.rerun, 'shell')] : []),
139
148
  ...(board.file ? ['**Source**', codeBlock(board.file, 'text')] : []),
140
- 'Every frame is its own pixel baseline (tolerance: 0).'
149
+ 'Each screenshot is compared pixel by pixel with a reviewed reference image (tolerance: 0).'
141
150
  ].join('\n\n'), presentation))
142
151
  fs.mkdirSync(path.dirname(outFile), { recursive: true })
143
152
  fs.writeFileSync(outFile, chunks.join('\n\n') + '\n')