@sun-asterisk/sungen 2.2.3 β 2.3.0
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 +4 -4
- package/dist/cli/commands/update.d.ts +3 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +21 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/index.js +3 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/generators/gherkin-parser/index.d.ts +2 -0
- package/dist/generators/gherkin-parser/index.d.ts.map +1 -1
- package/dist/generators/gherkin-parser/index.js +16 -2
- package/dist/generators/gherkin-parser/index.js.map +1 -1
- package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/attribute-assertion.hbs +3 -0
- package/dist/generators/test-generator/adapters/playwright/templates/steps/partials/locator-base.hbs +12 -1
- package/dist/generators/test-generator/adapters/playwright/templates/steps/partials/locator.hbs +12 -1
- package/dist/generators/test-generator/patterns/assertion-patterns.d.ts.map +1 -1
- package/dist/generators/test-generator/patterns/assertion-patterns.js +12 -0
- package/dist/generators/test-generator/patterns/assertion-patterns.js.map +1 -1
- package/dist/generators/test-generator/patterns/index.d.ts +9 -0
- package/dist/generators/test-generator/patterns/index.d.ts.map +1 -1
- package/dist/generators/test-generator/patterns/index.js +32 -0
- package/dist/generators/test-generator/patterns/index.js.map +1 -1
- package/dist/generators/test-generator/patterns/table-patterns.d.ts.map +1 -1
- package/dist/generators/test-generator/patterns/table-patterns.js +8 -5
- package/dist/generators/test-generator/patterns/table-patterns.js.map +1 -1
- package/dist/orchestrator/ai-rules-updater.d.ts +13 -0
- package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -0
- package/dist/orchestrator/ai-rules-updater.js +157 -0
- package/dist/orchestrator/ai-rules-updater.js.map +1 -0
- package/dist/orchestrator/project-initializer.d.ts.map +1 -1
- package/dist/orchestrator/project-initializer.js +2 -27
- package/dist/orchestrator/project-initializer.js.map +1 -1
- package/dist/orchestrator/screen-manager.d.ts +1 -0
- package/dist/orchestrator/screen-manager.d.ts.map +1 -1
- package/dist/orchestrator/screen-manager.js +70 -3
- package/dist/orchestrator/screen-manager.js.map +1 -1
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +18 -9
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md +11 -4
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +9 -11
- package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +27 -8
- package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +91 -25
- package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +124 -71
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +13 -5
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-make-tc.md +12 -4
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +9 -11
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +27 -8
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +72 -31
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +124 -72
- package/dist/orchestrator/templates/readme.md +13 -8
- package/package.json +1 -1
- package/src/cli/commands/update.ts +18 -0
- package/src/cli/index.ts +3 -1
- package/src/generators/gherkin-parser/index.ts +19 -2
- package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/attribute-assertion.hbs +3 -0
- package/src/generators/test-generator/adapters/playwright/templates/steps/partials/locator-base.hbs +12 -1
- package/src/generators/test-generator/adapters/playwright/templates/steps/partials/locator.hbs +12 -1
- package/src/generators/test-generator/patterns/assertion-patterns.ts +13 -0
- package/src/generators/test-generator/patterns/index.ts +41 -0
- package/src/generators/test-generator/patterns/table-patterns.ts +8 -5
- package/src/orchestrator/ai-rules-updater.ts +139 -0
- package/src/orchestrator/project-initializer.ts +2 -32
- package/src/orchestrator/screen-manager.ts +72 -3
- package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +18 -9
- package/src/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md +11 -4
- package/src/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +9 -11
- package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +27 -8
- package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +91 -25
- package/src/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +124 -71
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +13 -5
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-make-tc.md +12 -4
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +9 -11
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +27 -8
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +72 -31
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +124 -72
- package/src/orchestrator/templates/readme.md +13 -8
- package/docs/gherkin standards/gherkin-core-standard.md +0 -431
- package/docs/gherkin standards/gherkin-core-standard.vi.md +0 -399
- package/docs/gherkin-dictionary.md +0 -1126
- package/docs/makeauth.md +0 -225
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
# Tieu Chuan Gherkin - Cot Loi v2.1
|
|
2
|
-
|
|
3
|
-
**Ap dung cho: Kiem thu thu cong & Kiem thu tu dong**
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 1οΈβ£ Dinh Dang Scenario (Cap do Flow)
|
|
8
|
-
|
|
9
|
-
### Dinh dang
|
|
10
|
-
```gherkin
|
|
11
|
-
Scenario: <Ai> <Lam gi> <De dat ket qua gi>
|
|
12
|
-
Given ...
|
|
13
|
-
When ...
|
|
14
|
-
Then ...
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### Nguyen tac
|
|
18
|
-
- **Doc lap**: 1 Scenario = 1 hanh vi nghiep vu hoan chinh (khong dung chung du lieu giua cac scenario)
|
|
19
|
-
- **Hanh vi**: Mo ta "User lam gi" va "Thay gi" β tap trung vao hanh vi nguoi dung
|
|
20
|
-
- **Khach quan**: Mo ta ket qua nghiep vu. Khong chua chi tiet ky thuat (CSS, XPath)
|
|
21
|
-
|
|
22
|
-
### Luong
|
|
23
|
-
**Qua khu (Setup) β Hien tai (Tuong tac) β Tuong lai (Ket qua)**
|
|
24
|
-
|
|
25
|
-
```gherkin
|
|
26
|
-
Scenario: User logs in successfully with valid credentials
|
|
27
|
-
# 1. Thiet lap
|
|
28
|
-
Given User is on [Login] page
|
|
29
|
-
# 2. Tuong tac
|
|
30
|
-
When User fill [Email] field with {{valid_email}}
|
|
31
|
-
And User fill [Password] field with {{valid_password}}
|
|
32
|
-
And User click [Submit] button
|
|
33
|
-
# 3. Ket qua
|
|
34
|
-
Then User see [Dashboard] page
|
|
35
|
-
And User see [Welcome] heading with {{username}}
|
|
36
|
-
And User see [Logout] button is enabled
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Quy tac tu khoa
|
|
40
|
-
- **Given** β chi `is on` (thiet lap ngu canh)
|
|
41
|
-
- **When / And** β `click`, `fill`, `select`, `press`, `clear`, `check`, `uncheck`, `hover`, `wait for`
|
|
42
|
-
- **Then / And** β chi `see` (xac nhan)
|
|
43
|
-
- **And** β ke thua tu khoa truoc do
|
|
44
|
-
|
|
45
|
-
> Toi da 5-7 buoc `Then/And` moi scenario. Tach thanh scenario rieng neu can nhieu hon.
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## 2οΈβ£ Ngu Phap (Cap do Step)
|
|
50
|
-
|
|
51
|
-
### Dinh dang
|
|
52
|
-
```
|
|
53
|
-
[Keyword] User <Action> [Target Name] <Target Type> <with {{Value}}> <is State>
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Quy tac
|
|
57
|
-
- β
`Actor` + `Action` la **bat buoc**
|
|
58
|
-
- β
`Target` la **bat buoc** voi hau het action (tru `wait for` timeout)
|
|
59
|
-
- β
`with {{Value}}` chi dung khi action can du lieu
|
|
60
|
-
- β
`is State` chi dung cho assertion va wait
|
|
61
|
-
- β Khong viet tu do (free-text)
|
|
62
|
-
- β Khong dung tu dong nghia
|
|
63
|
-
|
|
64
|
-
### Cau truc chi tiet
|
|
65
|
-
|
|
66
|
-
| Thanh phan | Bat buoc | Vi du |
|
|
67
|
-
|-----------|----------|---------|
|
|
68
|
-
| Actor | β
Luon luon | `User` |
|
|
69
|
-
| Action | β
Luon luon | `click`, `fill`, `see` |
|
|
70
|
-
| Target | β
Hau het | `[Login] button` |
|
|
71
|
-
| Value | β οΈ Khi can | `{{valid_email}}` |
|
|
72
|
-
| State | β οΈ Khi can | `is disabled` |
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## 3οΈβ£ Actor (Tac nhan)
|
|
77
|
-
|
|
78
|
-
### Actor duoc phep
|
|
79
|
-
- β
**`User`** (duy nhat)
|
|
80
|
-
|
|
81
|
-
### Quy tac
|
|
82
|
-
- **Chi dung**: `User`
|
|
83
|
-
- **KHONG dung**: `System`, `Backend`, `API`, `App`
|
|
84
|
-
- Hanh vi cua he thong duoc verify bang `Then`, khong phai Actor
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
## 4οΈβ£ Action (Hanh dong)
|
|
89
|
-
|
|
90
|
-
### Ma tran Action
|
|
91
|
-
|
|
92
|
-
| Nhom | Action | `with {{Value}}` | `is State` | Target Types |
|
|
93
|
-
|------|--------|:-:|:-:|---|
|
|
94
|
-
| **Setup** | `is on` | β | β | `page`, `dialog`, `modal`, `tab` |
|
|
95
|
-
| **Tuong tac** | `click` | Chi list dong β± | β | Moi phan tu tuong tac |
|
|
96
|
-
| **Tuong tac** | `double click` | β | β | Bat ky |
|
|
97
|
-
| **Tuong tac** | `hover` | β | β | `icon`, `image`, `row`, `card`, `menuitem` |
|
|
98
|
-
| **Tuong tac** | `drag` | β | β | Bat ky |
|
|
99
|
-
| **Tuong tac** | `expand` / `collapse` | β | β | `row`, `section` |
|
|
100
|
-
| **Form** | `fill` | β
| β | `field`, `textarea`, `search`, `uploader`, `slider`, `date-picker` |
|
|
101
|
-
| **Form** | `select` | β
| β | `dropdown`, `select`, `option` |
|
|
102
|
-
| **Form** | `clear` | β | β | `field`, `textarea` |
|
|
103
|
-
| **Form** | `check` | β | β | `checkbox`, `toggle`, `radio` |
|
|
104
|
-
| **Form** | `uncheck` | β | β | `checkbox`, `toggle` (KHONG cho radio) |
|
|
105
|
-
| **Phim** | `press` | β | β | `key` (bat buoc) |
|
|
106
|
-
| **Cuon** | `scroll to` | β | β | `section`, bat ky |
|
|
107
|
-
| **Frame** | `switch to` | β | β | `frame` |
|
|
108
|
-
| **Cho** | `wait for` | β οΈ | β οΈ | `page`, `dialog`, `modal`, `message`, bat ky |
|
|
109
|
-
| **Xac nhan** | `see` | β
| β
| Tat ca |
|
|
110
|
-
| **Alert** | `click` | β | β | `alert` (OK/Cancel) |
|
|
111
|
-
| **Alert** | `fill` | β
| β | `alert` (prompt) |
|
|
112
|
-
|
|
113
|
-
> β± **`click` + `with {{Value}}`**: Chi cho list dong (`row`, `item`, `card`, `option`). Khong dung cho phan tu tinh (`button`, `link`, `icon`, `tab`).
|
|
114
|
-
|
|
115
|
-
### Quy tac
|
|
116
|
-
- β
Dung **dong tu chinh xac** tu danh sach
|
|
117
|
-
- β Khong dung tu dong nghia: `type`, `enter`, `input`, `verify`, `expect`, v.v.
|
|
118
|
-
- β Khong dung action ket hop: `click and wait`, `fill and submit`
|
|
119
|
-
|
|
120
|
-
### Anti-patterns (Mau sai)
|
|
121
|
-
```gherkin
|
|
122
|
-
β User types {{password}} into [Password] field β Dung: User fill [Password] field with {{password}}
|
|
123
|
-
β User opens [Home] page β Dung: User is on [Home] page
|
|
124
|
-
β User click [Terms] checkbox β Dung: User check [Terms] checkbox
|
|
125
|
-
β User uncheck [Male] radio β Radio khong the uncheck, dung: User check [Female] radio
|
|
126
|
-
β User verifies [Success] message β Dung: User see [Success] message
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
---
|
|
130
|
-
|
|
131
|
-
## 5οΈβ£ Target (Doi tuong)
|
|
132
|
-
|
|
133
|
-
### Dinh dang
|
|
134
|
-
```
|
|
135
|
-
[name] <element type>
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Cac loai Element
|
|
139
|
-
|
|
140
|
-
| Nhom | Types | Vi du |
|
|
141
|
-
|---|---|---|
|
|
142
|
-
| **Context** | `page` `dialog` `modal` `drawer` `tab` `alert` `overlay` `step` | `[Login] page`, `[Confirm] dialog` |
|
|
143
|
-
| **Input** | `field` `textarea` `search` `dropdown` `option` `checkbox` `radio` `toggle` `uploader` `slider` `date-picker` | `[Email] field`, `[Global] search` |
|
|
144
|
-
| **Trigger** | `button` `link` `icon` `menuitem` `tag` | `[Submit] button`, `[Close] icon` |
|
|
145
|
-
| **Data** | `table` `row` `column` `cell` `list` `item` `card` `section` | `[Users] table`, `[Order] row` |
|
|
146
|
-
| **Feedback** | `message` `header` `label` `text` `tooltip` `badge` `breadcrumb` `image` | `[Error] message`, `[Total] label` |
|
|
147
|
-
| **System** | `key` `frame` `spinner` `progressbar` | `[Enter] key`, `[Payment] frame` |
|
|
148
|
-
|
|
149
|
-
### Quy tac dat ten
|
|
150
|
-
- β
Dung **ten co nghia nghiep vu/UI**, khong dung selector ky thuat
|
|
151
|
-
- β
Co visible text β dung dung nhan UI: `[Dang nhap] button`
|
|
152
|
-
- β
Khong co visible text β danh tu ngan gon: `[close] icon`
|
|
153
|
-
- β
Ten > 30 ky tu β rut gon 1-3 tu co nghia
|
|
154
|
-
- β Khong dung CSS: `#email`, `.btn-primary`
|
|
155
|
-
- β Khong gop element type vao ngoac vuong: `[login button]` β `[login] button`
|
|
156
|
-
|
|
157
|
-
---
|
|
158
|
-
|
|
159
|
-
## 6οΈβ£ Value (Gia tri)
|
|
160
|
-
|
|
161
|
-
### Dinh dang
|
|
162
|
-
```
|
|
163
|
-
{{value}}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Quy uoc
|
|
167
|
-
- **snake_case** (chu thuong voi dau gach duoi)
|
|
168
|
-
- Mo ta ro rang va theo ngu canh
|
|
169
|
-
|
|
170
|
-
### Quy tac
|
|
171
|
-
- β
Su dung cu phap `{{variable}}`
|
|
172
|
-
- β
Ten phan anh **muc dich cua du lieu**, khong phai noi dung
|
|
173
|
-
- β Khong hard-code du lieu trong step
|
|
174
|
-
- β Khong chua du lieu that (email, password, token)
|
|
175
|
-
|
|
176
|
-
### Vi du
|
|
177
|
-
|
|
178
|
-
| β
Dung | β Sai |
|
|
179
|
-
|--------|-------|
|
|
180
|
-
| `{{valid_email}}` | `{{user@example.com}}` |
|
|
181
|
-
| `{{invalid_password}}` | `{{123456}}` |
|
|
182
|
-
| `{{product_name}}` | `{{iPhone 15 Pro}}` |
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
## 7οΈβ£ Assertion (Xac nhan)
|
|
187
|
-
|
|
188
|
-
### Dong tu
|
|
189
|
-
- **Duy nhat**: `see`
|
|
190
|
-
|
|
191
|
-
### 7 Pattern Verify
|
|
192
|
-
|
|
193
|
-
| # | Pattern | Assertion | Vi du |
|
|
194
|
-
|---|---------|-----------|-------|
|
|
195
|
-
| 1 | **Hien thi** | `toBeVisible()` / `toBeHidden()` | `see [Success] message` / `see [Ads] modal is hidden` |
|
|
196
|
-
| 2 | **Noi dung text** | `toHaveText()` (khop chinh xac) | `see [Error] message with {{err_msg}}` |
|
|
197
|
-
| 3 | **Text mot phan** | `toContainText()` | `see [Title] heading contains {{text}}` |
|
|
198
|
-
| 4 | **Gia tri input** | `toHaveValue()` | `see [Email] field with {{user_email}}` |
|
|
199
|
-
| 5 | **Trang thai** | `toBeDisabled()` / `toBeChecked()` v.v. | `see [Submit] button is disabled` |
|
|
200
|
-
| 6 | **So luong** | `toHaveCount()` | `see [Result] row with {{result_count}}` |
|
|
201
|
-
| 7 | **Dieu huong** | `toHaveURL()` | `see [Dashboard] page` |
|
|
202
|
-
|
|
203
|
-
> **Phan biet quan trong**: `see [T] <input type> with {{v}}` β `toHaveValue()` cho input (field, textarea, search, dropdown, slider, date-picker). `see [T] <other type> with {{v}}` β `toHaveText()` cho tat ca con lai.
|
|
204
|
-
|
|
205
|
-
### States (Trang thai)
|
|
206
|
-
|
|
207
|
-
| State | Mo ta |
|
|
208
|
-
|-------|-------|
|
|
209
|
-
| `hidden` | Element bi an |
|
|
210
|
-
| `visible` | Element hien thi |
|
|
211
|
-
| `disabled` | Element bi vo hieu |
|
|
212
|
-
| `enabled` | Element co the tuong tac |
|
|
213
|
-
| `checked` | Checkbox/radio/toggle duoc chon |
|
|
214
|
-
| `unchecked` | Checkbox/radio/toggle chua chon |
|
|
215
|
-
| `focused` | Element dang duoc focus |
|
|
216
|
-
| `empty` | Element rong |
|
|
217
|
-
| `loading` | Dang tai |
|
|
218
|
-
| `selected` | Duoc chon |
|
|
219
|
-
| `sorted ascending` | Sap xep tang dan |
|
|
220
|
-
| `sorted descending` | Sap xep giam dan |
|
|
221
|
-
|
|
222
|
-
### Ket hop Value + State
|
|
223
|
-
```gherkin
|
|
224
|
-
Then User see [Ads] modal with {{promo_title}} is hidden
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### Xac nhan bang (Table)
|
|
228
|
-
|
|
229
|
-
| Mau | Vi du |
|
|
230
|
-
|------|-------|
|
|
231
|
-
| Dong ton tai | `User see [Users] table has row with {{name}}` |
|
|
232
|
-
| Khong co dong | `User see [Users] table has no row with {{name}}` |
|
|
233
|
-
| Dem dong | `User see [Users] table has {{count}} rows` |
|
|
234
|
-
| Cot ton tai | `User see [Users] table has [Email] column` |
|
|
235
|
-
| Bang rong | `User see [Users] table is empty` |
|
|
236
|
-
| O theo bo loc | `User see [Users] table row with {{filter}} has [Status] with {{status}}` |
|
|
237
|
-
| O theo chi so | `User see [Users] table row 1 [Name] cell with {{name}}` |
|
|
238
|
-
| Hanh dong trong dong | `User click [Edit] in [Users] table row with {{name}}` |
|
|
239
|
-
|
|
240
|
-
### Quy tac
|
|
241
|
-
- β
Assertion **chi xuat hien trong `Then`**
|
|
242
|
-
- β
Moi step = **1 assertion**
|
|
243
|
-
- β Khong dung tu dong nghia: `verify`, `expect`, `check`, `validate`
|
|
244
|
-
|
|
245
|
-
---
|
|
246
|
-
|
|
247
|
-
## 8οΈβ£ Browser Alert (System Dialog)
|
|
248
|
-
|
|
249
|
-
Cho dialog he thong (`window.alert`, `window.confirm`, `window.prompt`):
|
|
250
|
-
|
|
251
|
-
```gherkin
|
|
252
|
-
# Buoc alert phai dat TRUOC hanh dong kich hoat dialog
|
|
253
|
-
When User click [OK] alert # chap nhan (OK/Accept/Yes/Confirm)
|
|
254
|
-
And User click [Delete] button # hanh dong kich hoat alert
|
|
255
|
-
|
|
256
|
-
When User click [Cancel] alert # tu choi (Cancel/Dismiss/No)
|
|
257
|
-
And User click [Delete] button
|
|
258
|
-
|
|
259
|
-
When User fill [Name] alert with {{v}} # nhap prompt + chap nhan
|
|
260
|
-
And User click [Rename] button
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
> **Quan trong**: Dang ky dialog handler TRUOC hanh dong kich hoat. Sungen sinh `page.once('dialog', ...)`.
|
|
264
|
-
|
|
265
|
-
---
|
|
266
|
-
|
|
267
|
-
## π·οΈ Tags
|
|
268
|
-
|
|
269
|
-
### Tags phan loai
|
|
270
|
-
|
|
271
|
-
| Tag | Mo ta |
|
|
272
|
-
|-----|-------|
|
|
273
|
-
| `@auto` | Scenario tu dong, san sang chay |
|
|
274
|
-
| `@manual` | Bo qua khi sinh code |
|
|
275
|
-
| `@smoke` | Tap kiem thu Smoke |
|
|
276
|
-
| `@regression` | Tap kiem thu Regression |
|
|
277
|
-
|
|
278
|
-
### Tags xac thuc
|
|
279
|
-
|
|
280
|
-
| Tag | Mo ta |
|
|
281
|
-
|-----|-------|
|
|
282
|
-
| `@auth:<role>` | Su dung trang thai auth Playwright cho role |
|
|
283
|
-
| `@no-auth` | Tat authentication ke thua |
|
|
284
|
-
|
|
285
|
-
**Thu tu uu tien Auth**: Scenario ke thua `@auth` > Scenario goc `@auth` > Feature `@auth`
|
|
286
|
-
|
|
287
|
-
### Tags ke thua (@steps / @extend)
|
|
288
|
-
|
|
289
|
-
```gherkin
|
|
290
|
-
@auto @auth:user @steps:kudos__open_modal
|
|
291
|
-
Scenario: Setup for opening Kudos modal
|
|
292
|
-
Given User is on [Home] page
|
|
293
|
-
When User click [Today you want...] button
|
|
294
|
-
Then User see [Send thanks] dialog # β bo qua khi @extend goi
|
|
295
|
-
|
|
296
|
-
@auto @auth:user @extend:kudos__open_modal
|
|
297
|
-
Scenario: User successfully sends a thank you message
|
|
298
|
-
Given User is on [Send thanks] dialog # β bat buoc: xac nhan trang thai sau extend
|
|
299
|
-
When User fill [Search teammate] field with {{teammate_name}}
|
|
300
|
-
And User click [Send] button
|
|
301
|
-
Then User see [Success] message with {{msg_success}}
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
**Hanh vi:**
|
|
305
|
-
- `@extend` thuc thi **chi GivenβWhen** cua `@steps` (bo qua Then)
|
|
306
|
-
- `Given` trong `@extend` la **assertion xac nhan trang thai** sau khi base steps chay
|
|
307
|
-
- Neu `@steps` **fail**, `@extend` se **tu dong bo qua (skip)**
|
|
308
|
-
- Dinh dang ten: `snake_case` hoac `kebab-case` voi prefix module: `@steps:kudos__open_modal`
|
|
309
|
-
|
|
310
|
-
---
|
|
311
|
-
|
|
312
|
-
## π Vi du hoan chinh
|
|
313
|
-
|
|
314
|
-
```gherkin
|
|
315
|
-
@feature_auth
|
|
316
|
-
Feature: Xac thuc nguoi dung
|
|
317
|
-
Path: /auth/login
|
|
318
|
-
|
|
319
|
-
# Happy Path
|
|
320
|
-
@auto @smoke @regression
|
|
321
|
-
Scenario: User logs in successfully with valid credentials
|
|
322
|
-
Given User is on [Login] page
|
|
323
|
-
When User fill [Email] field with {{valid_email}}
|
|
324
|
-
And User fill [Password] field with {{valid_password}}
|
|
325
|
-
And User check [Remember me] checkbox
|
|
326
|
-
And User click [Login] button
|
|
327
|
-
Then User see [Dashboard] page
|
|
328
|
-
And User see [Welcome] message with {{user_fullname}}
|
|
329
|
-
And User see [Logout] button is enabled
|
|
330
|
-
|
|
331
|
-
# Error Path
|
|
332
|
-
@auto @regression
|
|
333
|
-
Scenario: Login fails with invalid credentials
|
|
334
|
-
Given User is on [Login] page
|
|
335
|
-
When User fill [Email] field with {{invalid_email}}
|
|
336
|
-
And User fill [Password] field with {{invalid_password}}
|
|
337
|
-
And User click [Login] button
|
|
338
|
-
Then User see [Login] page
|
|
339
|
-
And User see [Login error] message with {{err_invalid_credentials}}
|
|
340
|
-
And User see [Login] button is enabled
|
|
341
|
-
|
|
342
|
-
# Dung @extend
|
|
343
|
-
@auto @auth:user @steps:navigate_to_profile
|
|
344
|
-
Scenario: Setup β Navigate to Profile page
|
|
345
|
-
Given User is on [Dashboard] page
|
|
346
|
-
When User click [Avatar] icon
|
|
347
|
-
And User click [My account] menuitem
|
|
348
|
-
Then User see [Profile] page # β @extend bo qua buoc nay
|
|
349
|
-
|
|
350
|
-
@auto @auth:user @extend:navigate_to_profile
|
|
351
|
-
Scenario: User updates display name successfully
|
|
352
|
-
Given User is on [Profile] page # β Xac nhan trang thai sau extend
|
|
353
|
-
When User fill [Display name] field with {{new_display_name}}
|
|
354
|
-
And User click [Save changes] button
|
|
355
|
-
Then User see [Success] message with {{msg_save_success}}
|
|
356
|
-
And User see [Display name] field with {{new_display_name}}
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
---
|
|
360
|
-
|
|
361
|
-
## β
Tham Khao Nhanh
|
|
362
|
-
|
|
363
|
-
### Nen lam β
|
|
364
|
-
- Dung **action chuan** tu ma tran action
|
|
365
|
-
- Dung **`User`** la actor duy nhat
|
|
366
|
-
- Dung dinh dang **`[Target] <element type>`**
|
|
367
|
-
- Dung **`{{snake_case}}`** cho gia tri
|
|
368
|
-
- Dung **`is <state>`** cho xac nhan trang thai
|
|
369
|
-
- Dung **tags** (`@auth`, `@steps`, `@extend`) de quan ly scenario
|
|
370
|
-
- **1 Scenario = 1 flow nghiep vu**
|
|
371
|
-
- **1 Step = 1 action hoac assertion**
|
|
372
|
-
|
|
373
|
-
### Khong nen lam β
|
|
374
|
-
- Khong dung tu dong nghia hoac viet tu do
|
|
375
|
-
- Khong dung system/backend/API lam actor
|
|
376
|
-
- Khong dung selector ky thuat (CSS/XPath/ID)
|
|
377
|
-
- Khong hard-code du lieu trong step
|
|
378
|
-
- Khong dung action ket hop
|
|
379
|
-
- Khong dung `verify`/`check`/`expect` thay cho `see`
|
|
380
|
-
- Khong `click` checkbox/toggle (dung `check`/`uncheck`)
|
|
381
|
-
- Khong `uncheck` radio (dung `check` option khac)
|
|
382
|
-
|
|
383
|
-
### Loi thuong gap
|
|
384
|
-
|
|
385
|
-
| β Sai | β
Dung | Ly do |
|
|
386
|
-
|---|---|---|
|
|
387
|
-
| `Given User click [Login] button` | `When User click [Login] button` | `click` thuoc WHEN |
|
|
388
|
-
| `When User click [Terms] checkbox` | `When User check [Terms] checkbox` | Dung `check` cho checkbox |
|
|
389
|
-
| `When User press [Submit] button` | `When User press [Enter] key` | `press` chi di voi `key` |
|
|
390
|
-
| `When User uncheck [Male] radio` | `When User check [Female] radio` | Radio khong the uncheck |
|
|
391
|
-
| `fill [email] with {{admin@mail}}` | `fill [email] field with {{admin_email}}` | Khong hardcode + thieu type |
|
|
392
|
-
| `see [msg] with {{text}} hidden` | `see [msg] with {{text}} is hidden` | Thieu tu noi `is` |
|
|
393
|
-
| `see [btn] button with {{disabled}}` | `see [btn] button is disabled` | State dung `is`, khong dung `{{}}` |
|
|
394
|
-
|
|
395
|
-
---
|
|
396
|
-
|
|
397
|
-
**Phien ban**: 2.1
|
|
398
|
-
**Trang thai**: Final
|
|
399
|
-
**Cap nhat lan cuoi**: 31 thang 3, 2026
|