Skip to content

Commit

Permalink
Trigger base on keyboard (#44)
Browse files Browse the repository at this point in the history
* Add keydown event

* 0.12.2

* Bump version
  • Loading branch information
abdala authored Jan 9, 2025
1 parent 1e4e018 commit 302053d
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion assert/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/assert",
"version": "0.12.1",
"version": "0.13.0",
"description": "Extra assert library",
"type": "module",
"repository": {
Expand Down
10 changes: 5 additions & 5 deletions dtc-aws-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/dtc-aws-plugin",
"version": "0.12.1",
"version": "0.13.0",
"description": "AWS plugin for Declarative TestCases",
"repository": {
"type": "git",
Expand All @@ -22,10 +22,10 @@
"@aws-sdk/client-sns": "^3.645.0",
"@aws-sdk/lib-dynamodb": "^3.645.0",
"@aws-sdk/util-dynamodb": "^3.645.0",
"@cgauge/assert": "^0.12.0",
"@cgauge/dtc": "^0.12.0",
"@cgauge/nock-aws": "^0.12.0",
"@cgauge/type-guard": "^0.12.0"
"@cgauge/assert": "^0.13.0",
"@cgauge/dtc": "^0.13.0",
"@cgauge/nock-aws": "^0.13.0",
"@cgauge/type-guard": "^0.13.0"
},
"scripts": {
"build": "tsc --build --verbose",
Expand Down
8 changes: 4 additions & 4 deletions dtc-graphql-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/dtc-graphql-plugin",
"version": "0.12.1",
"version": "0.13.0",
"description": "GraphQl plugin for Declarative TestCases",
"repository": {
"type": "git",
Expand All @@ -15,9 +15,9 @@
"author": "Salam Suleymanov",
"license": "LGPL-3.0-or-later",
"dependencies": {
"@cgauge/assert": "^0.12.0",
"@cgauge/dtc": "^0.12.0",
"@cgauge/type-guard": "^0.12.0",
"@cgauge/assert": "^0.13.0",
"@cgauge/dtc": "^0.13.0",
"@cgauge/type-guard": "^0.13.0",
"graphql-request": "^7.1.2"
},
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions dtc-mysql-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/dtc-mysql-plugin",
"version": "0.12.1",
"version": "0.13.0",
"description": "MySQL plugin for Declarative TestCases",
"repository": {
"type": "git",
Expand All @@ -15,9 +15,9 @@
"author": "Abdala Cerqueira",
"license": "LGPL-3.0-or-later",
"dependencies": {
"@cgauge/assert": "^0.12.0",
"@cgauge/dtc": "^0.12.0",
"@cgauge/type-guard": "^0.12.0",
"@cgauge/assert": "^0.13.0",
"@cgauge/dtc": "^0.13.0",
"@cgauge/type-guard": "^0.13.0",
"mysql2": "^3.11.0",
"node-sql-parser": "^5.1.0",
"type-assurance": "^1.5.1"
Expand Down
8 changes: 4 additions & 4 deletions dtc-playwright-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/dtc-playwright-plugin",
"version": "0.12.1",
"version": "0.13.0",
"description": "Playwright plugin for Declarative TestCases",
"repository": {
"type": "git",
Expand All @@ -15,9 +15,9 @@
"author": "Abdala Cerqueira",
"license": "LGPL-3.0-or-later",
"dependencies": {
"@cgauge/assert": "^0.12.0",
"@cgauge/dtc": "^0.12.0",
"@cgauge/type-guard": "^0.12.0",
"@cgauge/assert": "^0.13.0",
"@cgauge/dtc": "^0.13.0",
"@cgauge/type-guard": "^0.13.0",
"@playwright/test": "^1.47.0"
},
"scripts": {
Expand Down
8 changes: 7 additions & 1 deletion dtc-playwright-plugin/src/playwright-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const PlaywrightAction = {
action: optional(union(String, PlaywrightActionArgs)),
fill: optional(String),
click: optional(Boolean),
keydown: optional(Boolean),
toBeVisible: optional(Boolean),
options: optional(record(String, unknown)),
}
Expand Down Expand Up @@ -66,6 +67,11 @@ const executeActions = async (actions: PlaywrightAction[], page: Page) => {
await element.fill(act.fill, act.options)
} else if (act.click !== undefined) {
await element.click(act.options)
} else if (act.keydown !== undefined) {
await element.focus()
await element.evaluate((htmlElement, options) => {
htmlElement.dispatchEvent(new KeyboardEvent('keydown', {bubbles: true, key: 'ArrowDown', ...options}))
}, act.options)
} else if (act.toBeVisible !== undefined) {
await expect(element.first()).toBeVisible({visible: act.toBeVisible, ...act.options})
}
Expand All @@ -77,7 +83,7 @@ export const arrange = async (args: unknown, _basePath: string, {page}: {page: P
if (!page) {
throw new Error('Page not defined')
}

if (!is(args, {playwright: Playwright})) {
return
}
Expand Down
6 changes: 3 additions & 3 deletions dtc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/dtc",
"version": "0.12.1",
"version": "0.13.0",
"description": "Declarative TestCases",
"repository": {
"type": "git",
Expand All @@ -18,8 +18,8 @@
"author": "Abdala Cerqueira",
"license": "LGPL-3.0-or-later",
"dependencies": {
"@cgauge/assert": "^0.12.0",
"@cgauge/type-guard": "^0.12.0",
"@cgauge/assert": "^0.13.0",
"@cgauge/type-guard": "^0.13.0",
"cleye": "^1.3.2",
"nock": "^14.0.0-beta.15"
},
Expand Down
2 changes: 1 addition & 1 deletion nock-aws/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/nock-aws",
"version": "0.12.1",
"version": "0.13.0",
"description": "AWS Request mocker based on Nock",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion type-guard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/type-guard",
"version": "0.12.1",
"version": "0.13.0",
"description": "Typescript type guards",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion yaml/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cgauge/yaml",
"version": "0.12.1",
"version": "0.13.0",
"description": "YAML parser with extra tags",
"repository": {
"type": "git",
Expand Down

0 comments on commit 302053d

Please sign in to comment.