@bigbinary/neeto-playwright-commons 2.1.5 → 2.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 +1 -0
- package/index.cjs.js +332 -146
- package/index.cjs.js.map +1 -1
- package/index.d.ts +43 -22
- package/index.js +332 -149
- package/index.js.map +1 -1
- package/package.json +3 -2
- package/scripts/neeto-auth/playwright_email_capture.rb.template +59 -0
- package/scripts/neeto-auth/setup.sh +24 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-playwright-commons",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "A package encapsulating common playwright code across neeto projects.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-playwright-commons.git",
|
|
6
6
|
"license": "apache-2.0",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"index.*",
|
|
23
23
|
"index.d.ts",
|
|
24
|
-
"configs/*"
|
|
24
|
+
"configs/*",
|
|
25
|
+
"scripts/**"
|
|
25
26
|
],
|
|
26
27
|
"lint-staged": {
|
|
27
28
|
"**/*.{js,jsx,ts,tsx,json,mjs}": [
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Injected by Playwright to capture neetoAuth emails in Redis,
|
|
4
|
+
# so host app's rake task can read OTP emails sent by neetoAuth.
|
|
5
|
+
|
|
6
|
+
return unless Rails.env.development?
|
|
7
|
+
|
|
8
|
+
ActionMailer::Base.delivery_method = :test
|
|
9
|
+
ActiveJob::Base.queue_adapter = :async
|
|
10
|
+
|
|
11
|
+
PLAYWRIGHT_REDIS = Redis.new(url: "redis://localhost:6379/1")
|
|
12
|
+
PLAYWRIGHT_TARGET_APP = "{{TARGET_APP}}"
|
|
13
|
+
|
|
14
|
+
$stderr.puts "[PlaywrightEmailCapture] Initializer loaded — capturing emails"
|
|
15
|
+
|
|
16
|
+
ActiveSupport::Notifications.subscribe("deliver.action_mailer") do |_name, _start, _finish, _id, payload|
|
|
17
|
+
begin
|
|
18
|
+
mail = payload[:mail]
|
|
19
|
+
mail = Mail.read_from_string(mail)
|
|
20
|
+
|
|
21
|
+
if mail.multipart?
|
|
22
|
+
text_part = mail.text_part&.decoded
|
|
23
|
+
html_part = mail.html_part&.decoded
|
|
24
|
+
text_part = html_part.gsub(/<[^>]*>/, " ") if html_part && text_part.to_s.empty?
|
|
25
|
+
else
|
|
26
|
+
body = mail.body.decoded
|
|
27
|
+
if mail.content_type.to_s =~ /html/
|
|
28
|
+
html_part = body
|
|
29
|
+
text_part = body.gsub(/<[^>]*>/, " ")
|
|
30
|
+
else
|
|
31
|
+
text_part = body
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
codes = (text_part || "").scan(/\b\d{4,8}\b/).uniq
|
|
36
|
+
|
|
37
|
+
email_data = {
|
|
38
|
+
to: mail.to,
|
|
39
|
+
from: mail.from,
|
|
40
|
+
subject: mail.subject,
|
|
41
|
+
reply_to: mail.reply_to,
|
|
42
|
+
received_at: Time.now.iso8601,
|
|
43
|
+
cc: mail.cc || [],
|
|
44
|
+
bcc: mail.bcc || [],
|
|
45
|
+
text_body: text_part,
|
|
46
|
+
html_body: html_part,
|
|
47
|
+
links: [],
|
|
48
|
+
codes: codes,
|
|
49
|
+
attachments: []
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
PLAYWRIGHT_REDIS.lpush("captured_emails:#{PLAYWRIGHT_TARGET_APP}", email_data.to_json)
|
|
53
|
+
|
|
54
|
+
$stderr.puts "[PlaywrightEmailCapture] Captured email to=#{mail.to} subject=#{mail.subject} codes=#{codes}"
|
|
55
|
+
rescue => exception
|
|
56
|
+
$stderr.puts "[PlaywrightEmailCapture] Error: #{exception.message}"
|
|
57
|
+
$stderr.puts exception.backtrace.first(5).join("\n")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
DIR="${1:?'Usage: setup.sh <target-directory>'}"
|
|
5
|
+
: "${GITHUB_TOKEN:?'GITHUB_TOKEN is required'}"
|
|
6
|
+
|
|
7
|
+
echo "[NeetoAuth] Cloning neeto-auth-web into ${DIR}..."
|
|
8
|
+
git clone --depth 1 \
|
|
9
|
+
"https://x-access-token:${GITHUB_TOKEN}@github.com/neetozone/neeto-auth-web.git" \
|
|
10
|
+
"${DIR}"
|
|
11
|
+
|
|
12
|
+
cd "${DIR}"
|
|
13
|
+
|
|
14
|
+
echo "[NeetoAuth] Copying database config..."
|
|
15
|
+
cp config/database.yml.ci config/database.yml
|
|
16
|
+
|
|
17
|
+
echo "[NeetoAuth] Installing gems..."
|
|
18
|
+
bundle install
|
|
19
|
+
|
|
20
|
+
echo "[NeetoAuth] Setting up database..."
|
|
21
|
+
bundle exec rake db:create db:schema:load
|
|
22
|
+
|
|
23
|
+
echo "[NeetoAuth] Seeding sample data..."
|
|
24
|
+
bundle exec rake populate_sample_data
|