haven-cypress-integration 1.6.0 โ†’ 1.6.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.
@@ -19,13 +19,16 @@ Options:
19
19
  --tag=name:version Docker image tag (default: haven-cypress-tests:latest)
20
20
  --product=name Product name for ECR organization (required for --push)
21
21
  --push Push image to ECR haven-test-images repository
22
- --automationIds=ID1,ID2 Run specific test cases
22
+ --automationIds=ID1,ID2 Run specific test cases by automation ID
23
+ --customTags=tag1,tag2 Run tests with custom tags (smoke, regression, p1, etc.)
23
24
 
24
25
  Examples:
25
26
  npx haven-cypress build --product=BE
26
27
  npx haven-cypress build --product=BE --push
27
28
  npx haven-cypress build --product=BE --tag=v2.1.0 --push
28
29
  npx haven-cypress run --automationIds=TC-AUTO-123,TC-AUTO-124
30
+ npx haven-cypress run --customTags=smoke,p1
31
+ npx haven-cypress run --automationIds=TC-AUTO-123 --customTags=smoke
29
32
 
30
33
  Versioning:
31
34
  --tag=latest โ†’ ECR tag: BE-{package.json.version} or BE-1.0.{BUILD_NUMBER}
@@ -60,7 +63,8 @@ try {
60
63
 
61
64
  case 'run':
62
65
  const automationIds = options.automationIds || '';
63
- integration.runTests(automationIds);
66
+ const customTags = options.customTags || '';
67
+ integration.runTests(automationIds, customTags);
64
68
  break;
65
69
 
66
70
  default:
package/index.js CHANGED
@@ -217,9 +217,10 @@ class HavenCypressIntegration {
217
217
  * Run tests with Haven integration
218
218
  * This is called by Haven when the container runs
219
219
  */
220
- runTests(automationIds = '') {
220
+ runTests(automationIds = '', customTags = '') {
221
221
  console.log('๐Ÿงช Running Haven-integrated Cypress tests...');
222
- console.log(`๐Ÿ” Automation IDs: ${automationIds || 'All tests'}`);
222
+ console.log(`๐Ÿ” Automation IDs: ${automationIds || 'None'}`);
223
+ console.log(`๐Ÿ” Custom Tags: ${customTags || 'None'}`);
223
224
 
224
225
  // This will be handled by run-filtered.sh when container runs
225
226
  // The library just provides the interface
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haven-cypress-integration",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Seamless Cypress integration with HAVEN test case management",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -5,15 +5,20 @@ WORKDIR /app
5
5
  # Copy project files
6
6
  COPY . .
7
7
 
8
- # Install zip utility (AWS CLI removed - EC2 handles S3 uploads)
8
+ # โœ… Install zip and AWS CLI v2 via official method
9
9
  RUN apt-get update && \
10
- apt-get install -y zip && \
11
- apt-get clean && \
12
- rm -rf /var/lib/apt/lists/*
10
+ apt-get install -y \
11
+ zip \
12
+ unzip \
13
+ curl && \
14
+ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
15
+ unzip awscliv2.zip && \
16
+ ./aws/install && \
17
+ rm -rf aws awscliv2.zip
13
18
 
14
19
  # โœ… Install Node deps (including dev dependencies for mochawesome)
15
20
  RUN npm ci --include=dev
16
- RUN npm install --no-save mochawesome mochawesome-merge mochawesome-report-generator
21
+ RUN npm install --no-save aws-sdk mochawesome mochawesome-merge mochawesome-report-generator
17
22
 
18
23
  # โœ… Ensure script is executable
19
24
  COPY run-filtered.sh /app/run-filtered.sh
@@ -4,31 +4,56 @@ echo "๐Ÿ”ฅ RUN SCRIPT:"
4
4
  echo "โœ… ENTERED run-filtered.sh"
5
5
  echo "โš™๏ธ Raw args: $@"
6
6
 
7
- # Extract automation IDs from CLI args
7
+ # Extract automation IDs and custom tags from CLI args
8
8
  AUTOMATION_IDS=""
9
+ CUSTOM_TAGS=""
9
10
  for arg in "$@"; do
10
11
  case $arg in
11
12
  --automationIds=*)
12
13
  AUTOMATION_IDS="${arg#*=}"
13
14
  shift
14
15
  ;;
16
+ --customTags=*)
17
+ CUSTOM_TAGS="${arg#*=}"
18
+ shift
19
+ ;;
15
20
  esac
16
21
  done
17
22
 
18
23
  echo "๐Ÿ” Extracted automation IDs: ${AUTOMATION_IDS}"
24
+ echo "๐Ÿ” Extracted custom tags: ${CUSTOM_TAGS}"
19
25
  echo "๐Ÿ“‚ Current working directory: $(pwd)"
20
26
 
27
+ # Build grep arguments for Cypress
28
+ CYPRESS_GREP=""
29
+ GREP_TAGS=""
21
30
 
22
- if [ -z "$AUTOMATION_IDS" ]; then
23
- echo "๐Ÿ” No automation IDs provided. Running all tests..."
24
- CYPRESS_GREP=""
25
- else
31
+ if [ -n "$AUTOMATION_IDS" ]; then
26
32
  # Strip quotes from arg, replace commas with spaces
27
33
  RAW_IDS=$(echo "$AUTOMATION_IDS" | sed "s/^['\"]//;s/['\"]$//")
28
34
  CLEANED_IDS="${RAW_IDS//,/ }"
35
+ GREP_TAGS="${CLEANED_IDS}"
36
+ echo "๐Ÿš€ Running Cypress with automation IDs: ${CLEANED_IDS}"
37
+ fi
38
+
39
+ if [ -n "$CUSTOM_TAGS" ]; then
40
+ # Strip quotes from arg, replace commas with spaces
41
+ RAW_TAGS=$(echo "$CUSTOM_TAGS" | sed "s/^['\"]//;s/['\"]$//")
42
+ CLEANED_TAGS="${RAW_TAGS//,/ }"
43
+
44
+ if [ -n "$GREP_TAGS" ]; then
45
+ GREP_TAGS="${GREP_TAGS} ${CLEANED_TAGS}"
46
+ else
47
+ GREP_TAGS="${CLEANED_TAGS}"
48
+ fi
49
+ echo "๐Ÿš€ Running Cypress with custom tags: ${CLEANED_TAGS}"
50
+ fi
29
51
 
30
- echo "๐Ÿš€ Running Cypress with filtered tags: ${CLEANED_IDS}"
31
- CYPRESS_GREP="--env grepTags='${CLEANED_IDS}'"
52
+ if [ -n "$GREP_TAGS" ]; then
53
+ CYPRESS_GREP="--env grepTags='${GREP_TAGS}'"
54
+ echo "๐Ÿ’ก Final grep tags: ${GREP_TAGS}"
55
+ else
56
+ echo "๐Ÿ” No tags provided. Running all tests..."
32
57
  fi
33
58
 
34
59
  # Set environment variables
@@ -37,6 +62,7 @@ PRODUCT_NAME=${PRODUCT_NAME:-unknown_product}
37
62
  PLAN_ID=${PLAN_ID:-unknown_plan}
38
63
  RUN_ID=${RUN_ID:-unknown_run}
39
64
  BUCKET_NAME=${BUCKET_NAME:-your-default-bucket}
65
+ TEST_ENVIRONMENT=${TEST_ENVIRONMENT:-QA}
40
66
 
41
67
  # Ensure results directory exists
42
68
  mkdir -p results/mochawesome
@@ -45,14 +71,14 @@ echo "๐Ÿงน Cleaning mochawesome reports"
45
71
  rm -rf results/mochawesome/*
46
72
 
47
73
  # Run Cypress
48
- echo "๐Ÿš€ Running Cypress with filtered tags: ${AUTOMATION_IDS}"
74
+ echo "๐Ÿš€ Running Cypress tests..."
49
75
  echo "๐Ÿ’ก Final grep arg: $CYPRESS_GREP"
50
76
  eval "npx cypress run \
51
77
  --headless \
52
78
  --browser chrome \
53
79
  --reporter mochawesome \
54
80
  --reporter-options 'reportDir=results/mochawesome,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss' \
55
- --env grepFilterSpecs=true,grepUntagged=false,grepEnabled=true \
81
+ --env grepFilterSpecs=true,grepUntagged=false,grepEnabled=true,TEST_ENVIRONMENT=${TEST_ENVIRONMENT} \
56
82
  $CYPRESS_GREP \
57
83
  > results/logs.txt 2>&1"
58
84
 
@@ -128,7 +154,7 @@ fi
128
154
 
129
155
  # Run result sync
130
156
  echo "๐Ÿ”„ Running syncCypressResults.js"
131
- PLAN_ID="${PLAN_ID}" RUN_ID="${RUN_ID}" node syncCypressResults.js >> results/logs.txt 2>&1 || echo "โš ๏ธ syncCypressResults.js failed"
157
+ PLAN_ID="${PLAN_ID}" RUN_ID="${RUN_ID}" TEST_ENVIRONMENT="${TEST_ENVIRONMENT}" node syncCypressResults.js >> results/logs.txt 2>&1 || echo "โš ๏ธ syncCypressResults.js failed"
132
158
 
133
159
  # Final output
134
160
  echo "๐Ÿ“ค Dumping results/logs.txt for runner capture:"
@@ -112,23 +112,25 @@ try {
112
112
 
113
113
  const planId = process.env.PLAN_ID || "unknown";
114
114
  const runId = process.env.RUN_ID || "unknown";
115
+ const testEnvironment = process.env.TEST_ENVIRONMENT || "QA";
115
116
 
116
117
  if (!planId || !runId || isNaN(Number(planId)) || isNaN(Number(runId))) {
117
118
  console.error("โŒ Invalid or missing PLAN_ID / RUN_ID");
118
119
  process.exit(1);
119
120
  }
120
121
 
121
- await postResults(formatted, notFound, planId, runId);
122
- await postSummary(formatted, notFound, planId, runId);
122
+ await postResults(formatted, notFound, planId, runId, testEnvironment);
123
+ await postSummary(formatted, notFound, planId, runId, testEnvironment);
123
124
  })();
124
125
 
125
- async function postResults(formattedResults, notFoundList, planId, runId) {
126
+ async function postResults(formattedResults, notFoundList, planId, runId, testEnvironment) {
126
127
  const postUrl = baseUrl; // baseUrl already includes the complete endpoint
127
128
  console.log(`๐Ÿ”— Posting to URL: ${postUrl}`);
128
129
 
129
130
  const payload = {
130
131
  planId,
131
132
  runId,
133
+ environment: testEnvironment,
132
134
  results: formattedResults,
133
135
  not_found: notFoundList,
134
136
  triggered_by: triggeredBy,
@@ -154,7 +156,7 @@ async function postResults(formattedResults, notFoundList, planId, runId) {
154
156
  }
155
157
  }
156
158
 
157
- async function postSummary(results, notFound, planId, runId) {
159
+ async function postSummary(results, notFound, planId, runId, testEnvironment) {
158
160
  // Replace test-results with test-run-summary in the baseUrl
159
161
  const url = baseUrl.replace('/api/test-results', '/api/test-run-summary');
160
162
 
@@ -164,6 +166,7 @@ async function postSummary(results, notFound, planId, runId) {
164
166
  const summaryPayload = {
165
167
  runId,
166
168
  planId,
169
+ environment: testEnvironment,
167
170
  status: computeOverallStatus(results, notFound),
168
171
  logs,
169
172
  result: {