sus-fixtures-async-webdriver 0.1.2 → 0.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/context/getting-started.md +59 -0
- data/context/index.yaml +13 -0
- data/lib/sus/fixtures/async/webdriver/session_context.rb +40 -4
- data/lib/sus/fixtures/async/webdriver/version.rb +2 -2
- data/readme.md +11 -3
- data/releases.md +5 -0
- data.tar.gz.sig +0 -0
- metadata +10 -12
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13796a43b11df5959aa1c2e61af561b337ab98395ac06755665c8c2b6f655af8
|
4
|
+
data.tar.gz: 36ad7b10080390c72879d81a3ba8f63cf232943889cf19fb05574c12b3f11bed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9487d809b255d6e6c12309c690a72c778d661602d0cc19e5186944cb6bfa5aebe87a524180765f6fd3055d20a45fd3a3e9566574c9d486e3e07427f466bbc35
|
7
|
+
data.tar.gz: 496f5c1e1d4c2c692d13ef976516c3df65968c53c07e404191418c8c9931f96faa330b9c20bdbb2ba98a4cefa9830e10c691170c6d06bd458ac8ee0b716328c9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Getting Started
|
2
|
+
|
3
|
+
This guide is designed to help you get started with the `sus-fixtures-async-webdriver` gem.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add the gem to your project:
|
8
|
+
|
9
|
+
``` bash
|
10
|
+
$ bundle add sus-fixtures-async-webdriver
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Simply add the appropriate fixtures to your integration tests:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'sus/fixtures/async/http/server_context'
|
19
|
+
require 'sus/fixtures/async/webdriver/session_context'
|
20
|
+
|
21
|
+
require 'protocol/rack/adapter'
|
22
|
+
require 'rack/builder'
|
23
|
+
|
24
|
+
describe "my website" do
|
25
|
+
include Sus::Fixtures::Async::HTTP::ServerContext
|
26
|
+
include Sus::Fixtures::Async::WebDriver::SessionContext
|
27
|
+
|
28
|
+
def middleware
|
29
|
+
Protocol::Rack::Adapter.new(app)
|
30
|
+
end
|
31
|
+
|
32
|
+
def app
|
33
|
+
Rack::Builder.load_file(File.expand_path('../config.ru', __dir__))
|
34
|
+
end
|
35
|
+
|
36
|
+
it "has a title" do
|
37
|
+
navigate_to('/')
|
38
|
+
|
39
|
+
expect(session.document_title).to be == "Example"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
See `examples/rack` for a full example.
|
45
|
+
|
46
|
+
## Automatic Debugging
|
47
|
+
|
48
|
+
When tests fail, the `SessionContext` automatically captures debugging information to help you understand what went wrong:
|
49
|
+
|
50
|
+
- **HTML Source**: The current page DOM structure is saved to a timestamped `.html` file
|
51
|
+
- **Screenshot**: A visual screenshot of the page is saved to a timestamped `.png` file
|
52
|
+
|
53
|
+
Debug files are automatically saved to the `tmp/debug/` directory and named with the test class and timestamp (e.g., `tmp/debug/MyTestClass-20250923-143022.html`). When a test fails, you'll see output like:
|
54
|
+
|
55
|
+
```
|
56
|
+
🐛 Test failed, debug files captured: 📄 HTML: tmp/debug/MyTestClass-20250923-143022.html 📸 Screenshot: tmp/debug/MyTestClass-20250923-143022.png ❌ Error: NoSuchElementError: Element not found
|
57
|
+
```
|
58
|
+
|
59
|
+
This debugging information is captured automatically without any additional setup - just include the `SessionContext` fixture and it will handle debug capture on test failures.
|
data/context/index.yaml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Automatically generated context index for Utopia::Project guides.
|
2
|
+
# Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
|
3
|
+
---
|
4
|
+
description: A set of sus fixtures for writing integration tests.
|
5
|
+
metadata:
|
6
|
+
documentation_uri: https://socketry.github.io/sus-fixtures-async-webdriver/
|
7
|
+
funding_uri: https://github.com/sponsors/ioquatix/
|
8
|
+
source_code_uri: https://github.com/socketry/sus-fixtures-async-webdriver.git
|
9
|
+
files:
|
10
|
+
- path: getting-started.md
|
11
|
+
title: Getting Started
|
12
|
+
description: This guide is designed to help you get started with the `sus-fixtures-async-webdriver`
|
13
|
+
gem.
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2023, by Samuel Williams.
|
4
|
+
# Copyright, 2023-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "async/webdriver"
|
7
|
+
require "async/webdriver/bridge/pool"
|
8
|
+
require "fileutils"
|
8
9
|
|
9
10
|
module Sus
|
10
11
|
module Fixtures
|
@@ -44,8 +45,13 @@ module Sus
|
|
44
45
|
@session = nil
|
45
46
|
end
|
46
47
|
|
47
|
-
def after
|
48
|
+
def after(error = nil)
|
48
49
|
if @session
|
50
|
+
# Capture debugging information if there was an error
|
51
|
+
if error
|
52
|
+
capture_debug_state(error)
|
53
|
+
end
|
54
|
+
|
49
55
|
SessionContext.pool.reuse(@session)
|
50
56
|
@session = nil
|
51
57
|
end
|
@@ -53,6 +59,36 @@ module Sus
|
|
53
59
|
super
|
54
60
|
end
|
55
61
|
|
62
|
+
private
|
63
|
+
|
64
|
+
def capture_debug_state(error)
|
65
|
+
return unless @session
|
66
|
+
|
67
|
+
begin
|
68
|
+
# Create debug directory if it doesn't exist
|
69
|
+
debug_dir = "tmp/debug"
|
70
|
+
::FileUtils.mkdir_p(debug_dir)
|
71
|
+
|
72
|
+
timestamp = Time.now.strftime("%Y%m%d-%H%M%S")
|
73
|
+
test_name = self.class.name&.gsub("::", "-") || "unknown-test"
|
74
|
+
prefix = "#{test_name}-#{timestamp}"
|
75
|
+
|
76
|
+
# Capture HTML source
|
77
|
+
html = @session.document_source
|
78
|
+
html_file = ::File.join(debug_dir, "#{prefix}.html")
|
79
|
+
::File.write(html_file, html)
|
80
|
+
|
81
|
+
# Capture screenshot
|
82
|
+
screenshot_data = @session.screenshot
|
83
|
+
screenshot_file = ::File.join(debug_dir, "#{prefix}.png")
|
84
|
+
::File.binwrite(screenshot_file, screenshot_data)
|
85
|
+
|
86
|
+
inform "🐛 Test failed, debug files captured: 📄 HTML: #{html_file} 📸 Screenshot: #{screenshot_file} ❌ Error: #{error.class.name}: #{error.message}"
|
87
|
+
rescue => debug_error
|
88
|
+
inform "⚠️ Failed to capture debug state: #{debug_error.class.name}: #{debug_error.message}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
56
92
|
# Navigate to a specific path within the website.
|
57
93
|
# @parameter path [String] The path to navigate to.
|
58
94
|
def navigate_to(path)
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2023, by Samuel Williams.
|
4
|
+
# Copyright, 2023-2024, by Samuel Williams.
|
5
5
|
|
6
6
|
module Sus
|
7
7
|
module Fixtures
|
8
8
|
module Async
|
9
9
|
module WebDriver
|
10
|
-
VERSION = "0.
|
10
|
+
VERSION = "0.3.0"
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/readme.md
CHANGED
@@ -10,6 +10,14 @@ Please see the [project documentation](https://socketry.github.io/sus-fixtures-a
|
|
10
10
|
|
11
11
|
- [Getting Started](https://socketry.github.io/sus-fixtures-async-webdriver/guides/getting-started/index) - This guide is designed to help you get started with the `sus-fixtures-async-webdriver` gem.
|
12
12
|
|
13
|
+
## Releases
|
14
|
+
|
15
|
+
Please see the [project releases](https://socketry.github.io/sus-fixtures-async-webdriver/releases/index) for all releases.
|
16
|
+
|
17
|
+
### v0.3.0
|
18
|
+
|
19
|
+
- Dump screenshot and HTML of the browser session on test failure for easier debugging.
|
20
|
+
|
13
21
|
## See Also
|
14
22
|
|
15
23
|
- [async-webdriver](https://github.com/socketry/async-webdriver) - Asynchronous WebDriver client used by this fixture.
|
@@ -26,8 +34,8 @@ We welcome contributions to this project.
|
|
26
34
|
|
27
35
|
### Developer Certificate of Origin
|
28
36
|
|
29
|
-
|
37
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
30
38
|
|
31
|
-
###
|
39
|
+
### Community Guidelines
|
32
40
|
|
33
|
-
This project is
|
41
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
data/releases.md
ADDED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sus-fixtures-async-webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain:
|
11
10
|
- |
|
@@ -37,7 +36,7 @@ cert_chain:
|
|
37
36
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
37
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
38
|
-----END CERTIFICATE-----
|
40
|
-
date:
|
39
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
41
40
|
dependencies:
|
42
41
|
- !ruby/object:Gem::Dependency
|
43
42
|
name: async-webdriver
|
@@ -45,32 +44,32 @@ dependencies:
|
|
45
44
|
requirements:
|
46
45
|
- - "~>"
|
47
46
|
- !ruby/object:Gem::Version
|
48
|
-
version: '0.
|
47
|
+
version: '0.9'
|
49
48
|
type: :runtime
|
50
49
|
prerelease: false
|
51
50
|
version_requirements: !ruby/object:Gem::Requirement
|
52
51
|
requirements:
|
53
52
|
- - "~>"
|
54
53
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0.
|
56
|
-
description:
|
57
|
-
email:
|
54
|
+
version: '0.9'
|
58
55
|
executables: []
|
59
56
|
extensions: []
|
60
57
|
extra_rdoc_files: []
|
61
58
|
files:
|
59
|
+
- context/getting-started.md
|
60
|
+
- context/index.yaml
|
62
61
|
- lib/sus/fixtures/async/webdriver/session_context.rb
|
63
62
|
- lib/sus/fixtures/async/webdriver/version.rb
|
64
63
|
- license.md
|
65
64
|
- readme.md
|
65
|
+
- releases.md
|
66
66
|
homepage: https://github.com/socketry/sus-fixtures-async-webdriver
|
67
67
|
licenses:
|
68
68
|
- MIT
|
69
69
|
metadata:
|
70
70
|
documentation_uri: https://socketry.github.io/sus-fixtures-async-webdriver/
|
71
|
-
funding_uri: https://github.com/sponsors/ioquatix
|
71
|
+
funding_uri: https://github.com/sponsors/ioquatix/
|
72
72
|
source_code_uri: https://github.com/socketry/sus-fixtures-async-webdriver.git
|
73
|
-
post_install_message:
|
74
73
|
rdoc_options: []
|
75
74
|
require_paths:
|
76
75
|
- lib
|
@@ -78,15 +77,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
77
|
requirements:
|
79
78
|
- - ">="
|
80
79
|
- !ruby/object:Gem::Version
|
81
|
-
version: '3.
|
80
|
+
version: '3.2'
|
82
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
82
|
requirements:
|
84
83
|
- - ">="
|
85
84
|
- !ruby/object:Gem::Version
|
86
85
|
version: '0'
|
87
86
|
requirements: []
|
88
|
-
rubygems_version: 3.
|
89
|
-
signing_key:
|
87
|
+
rubygems_version: 3.6.9
|
90
88
|
specification_version: 4
|
91
89
|
summary: A set of sus fixtures for writing integration tests.
|
92
90
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|