Skip to content

Commit d0110e1

Browse files
feat: add HTTP scenarios for form QA test
1 parent 16ffee2 commit d0110e1

7 files changed

Lines changed: 611 additions & 0 deletions

File tree

scenarios/smoke/health.http

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
###
2+
3+
# @title Check Health Status
4+
GET {{BASE_URL}}/healthz
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Environment variables for Form Lifecycle Tests
2+
# Copy this file to .env and fill in the values
3+
4+
# Base URL for the API (dev, mock, or local)
5+
BASE_URL=http://127.0.0.1:4010
6+
7+
# User ID for internal login (debug authentication)
8+
# This should be a valid UUID of a user in the system
9+
LOGIN_USER_ID=00000000-0000-0000-0000-000000000001
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# ============================================
2+
# Phase 1: Setup - Prerequisites & Auth
3+
# ============================================
4+
# This file sets up the necessary prerequisites for form lifecycle testing:
5+
# - Authentication (using shared common.http)
6+
# - Organization setup
7+
# - Store IDs for subsequent tests
8+
9+
# Import common auth setup
10+
# @import ../shared/common.http
11+
12+
###
13+
14+
# ============================================
15+
# Check if SDC Organization Exists
16+
# ============================================
17+
# @name getSDCOrg
18+
# @ref userLogin
19+
GET {{BASE_URL}}/orgs/SDC
20+
21+
{{
22+
test.status(200);
23+
test.hasResponseBody();
24+
25+
const { equal } = require('assert');
26+
27+
test('SDC org exists', () => {
28+
const data = JSON.parse(response.body);
29+
equal(data.slug, 'SDC', 'Organization slug should be SDC');
30+
});
31+
32+
test('Organization ID is valid UUID', () => {
33+
const data = JSON.parse(response.body);
34+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
35+
equal(uuidRegex.test(data.id), true, 'Organization ID should be a valid UUID');
36+
});
37+
38+
const data = JSON.parse(response.body);
39+
exports.orgSlug = "SDC";
40+
exports.orgId = data.id;
41+
}}
42+
43+
###
44+
45+
# ============================================
46+
# Get Current User Info (to confirm login and get user details)
47+
# ============================================
48+
# @name getMe
49+
# @ref getSDCOrg
50+
GET {{BASE_URL}}/users/me
51+
52+
{{
53+
test.status(200);
54+
test.hasResponseBody();
55+
56+
const { equal } = require('assert');
57+
58+
test('User info contains expected properties', () => {
59+
const data = JSON.parse(response.body);
60+
equal(data.id !== undefined, true, 'User ID should exist');
61+
equal(data.emails !== undefined, true, 'User email should exist');
62+
});
63+
64+
const data = JSON.parse(response.body);
65+
exports.userId = data.id;
66+
exports.userEmail = data.emails[0];
67+
}}
68+
69+
###
70+
71+
# ============================================
72+
# Verify Organization
73+
# ============================================
74+
# @name verifyOrg
75+
# @ref getMe
76+
GET {{BASE_URL}}/orgs/{{orgSlug}}
77+
78+
?? status == 200
79+
?? js response.parsedBody.id == {{orgId}}
80+
?? js response.parsedBody.slug == {{ orgSlug}}
81+
82+
###
83+
84+
# ============================================
85+
# Add User to Organization (if not already a member)
86+
# ============================================
87+
# @name addUserToOrg
88+
# @ref verifyOrg
89+
POST {{BASE_URL}}/orgs/{{orgSlug}}/members
90+
Content-Type: application/json
91+
{
92+
"email": "{{userEmail}}"
93+
}
94+
?? status <= 201
95+
{{
96+
test.hasResponseBody();
97+
98+
const { equal } = require('assert');
99+
100+
test('User added to organization successfully', () => {
101+
const data = JSON.parse(response.body);
102+
equal(data.member.id, userId, 'User ID should match');
103+
equal(data.orgId, orgId, 'Organization ID should match');
104+
});
105+
}}
106+
107+
108+
###
109+
110+
# ============================================
111+
# List Forms of Current User (Should be empty initially)
112+
# ============================================
113+
# @name listUserForms
114+
# @ref addUserToOrg
115+
GET {{BASE_URL}}/forms/me
116+
117+
?? status == 200
118+
?? js Array.isArray(response.body)
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
# ============================================
2+
# Phase 2: Form Creation - Form CRUD & Metadata
3+
# ============================================
4+
# This file covers form creation and basic CRUD operations:
5+
# - Create form
6+
# - Get form by ID
7+
# - Update form metadata
8+
# - List forms
9+
# - Get available fonts
10+
# - Upload cover image (optional)
11+
12+
# Import setup from Phase 1
13+
# @import ./01-setup.http
14+
15+
###
16+
17+
# ============================================
18+
# Get Available Fonts
19+
# ============================================
20+
# @name getFonts
21+
GET {{BASE_URL}}/forms/fonts
22+
23+
{{
24+
test.status(200);
25+
test.hasResponseBody();
26+
27+
const { equal } = require('assert');
28+
29+
test('Fonts array is returned', () => {
30+
const data = JSON.parse(response.body);
31+
equal(Array.isArray(data), true, 'Response should be an array');
32+
equal(data.length > 0, true, 'Fonts array should not be empty');
33+
});
34+
35+
const data = JSON.parse(response.body);
36+
exports.firstFontId = data[0].id;
37+
}}
38+
39+
###
40+
41+
# ============================================
42+
# Create Form
43+
# ============================================
44+
# @name createForm
45+
# @ref addUserToOrg
46+
POST {{BASE_URL}}/orgs/{{orgSlug}}/forms
47+
Content-Type: application/json
48+
49+
{
50+
"title": "Form Lifecycle Test Form",
51+
"description": "This is a comprehensive test form covering all question types and form lifecycle operations. It demonstrates form creation, question management, workflow setup, and response handling.",
52+
"previewMessage": "Complete test form",
53+
"messageAfterSubmission": "Thank you for completing this test form! Your response has been recorded.",
54+
"visibility": "PUBLIC"
55+
}
56+
57+
?? status <= 201
58+
{{
59+
test.hasResponseBody();
60+
61+
const { equal } = require('assert');
62+
63+
test('Form created with correct properties', () => {
64+
const data = JSON.parse(response.body);
65+
equal(data.id !== undefined, true, 'Form ID should exist');
66+
equal(data.title, 'Form Lifecycle Test Form', 'Form title should match');
67+
equal(data.description, 'This is a comprehensive test form covering all question types and form lifecycle operations. It demonstrates form creation, question management, workflow setup, and response handling.', 'Form description should match');
68+
equal(data.previewMessage, 'Complete test form', 'Preview message should match');
69+
equal(data.messageAfterSubmission, 'Thank you for completing this test form! Your response has been recorded.', 'Message after submission should match');
70+
equal(data.visibility, 'PUBLIC', 'Form visibility should be PUBLIC');
71+
equal(data.status, 'DRAFT', 'Form status should be DRAFT');
72+
equal(data.lastEditor.id, userId, 'Last editor should be the current user');
73+
equal(data.unitId, orgId, 'Organization ID should match');
74+
});
75+
76+
const data = JSON.parse(response.body);
77+
exports.formId = data.id;
78+
}}
79+
80+
###
81+
82+
# ============================================
83+
# Get Form by ID
84+
# ============================================
85+
# @name getForm
86+
# @ref createForm
87+
GET {{BASE_URL}}/forms/{{formId}}
88+
89+
{{
90+
test.status(200);
91+
test.hasResponseBody();
92+
93+
const { equal } = require('assert');
94+
95+
test('Form retrieved successfully', () => {
96+
const data = JSON.parse(response.body);
97+
equal(data.id, formId, 'Form ID should match');
98+
equal(data.title, 'Form Lifecycle Test Form', 'Form title should match');
99+
equal(data.status, 'DRAFT', 'Form status should be DRAFT');
100+
});
101+
}}
102+
103+
###
104+
105+
# ============================================
106+
# List Forms
107+
# ============================================
108+
# @name listForms
109+
# @ref getForm
110+
GET {{BASE_URL}}/forms
111+
112+
{{
113+
test.status(200);
114+
test.hasResponseBody();
115+
116+
const { equal } = require('assert');
117+
118+
test('Forms list contains created form', () => {
119+
const data = JSON.parse(response.body);
120+
equal(Array.isArray(data), true, 'Response should be an array');
121+
equal(data.some(f => f.id === formId), true, 'Created form should be in the list');
122+
});
123+
}}
124+
125+
###
126+
127+
# ============================================
128+
# Update Form - Add Dressing & Metadata
129+
# ============================================
130+
# @name updateForm
131+
# @ref listForms
132+
PUT {{BASE_URL}}/forms/{{formId}}
133+
Content-Type: application/json
134+
135+
{
136+
"title": "Form Lifecycle Test Form (Updated)",
137+
"description": "This is an updated comprehensive test form covering all question types and form lifecycle operations. Updated to test form editing capabilities.",
138+
"previewMessage": "Updated test form - complete all sections",
139+
"messageAfterSubmission": "Thank you for your submission! We will review your response shortly.",
140+
"visibility": "PUBLIC",
141+
"dressing": {
142+
"color": "#0066cc",
143+
"headerFont": "BoutiqueBitmap7x7CircleDot",
144+
"questionFont": "BoutiqueBitmap7x7SquareDot",
145+
"textFont": "ChillBitmap16px"
146+
},
147+
"deadline": "2026-12-31T23:59:59Z",
148+
"publishTime": "2026-02-01T00:00:00Z"
149+
}
150+
151+
{{
152+
test.status(200);
153+
test.hasResponseBody();
154+
155+
const { equal } = require('assert');
156+
157+
test('Form updated with correct properties', () => {
158+
const data = JSON.parse(response.body);
159+
equal(data.title, 'Form Lifecycle Test Form (Updated)', 'Form title should be updated');
160+
equal(data.dressing !== undefined, true, 'Dressing should exist');
161+
equal(data.dressing.color, '#0066cc', 'Dressing color should match');
162+
equal(data.dressing.headerFont, 'BoutiqueBitmap7x7CircleDot', 'Dressing header font should match');
163+
equal(data.dressing.questionFont, 'BoutiqueBitmap7x7SquareDot', 'Dressing question font should match');
164+
equal(data.dressing.textFont, 'ChillBitmap16px', 'Dressing text font should match');
165+
equal(data.deadline !== null, true, 'Deadline should be set');
166+
equal(data.publishTime !== null, true, 'Publish time should be set');
167+
});
168+
}}
169+
170+
###
171+
172+
# ============================================
173+
# Get Updated Form
174+
# ============================================
175+
# @name getUpdatedForm
176+
# @ref updateForm
177+
GET {{BASE_URL}}/forms/{{formId}}
178+
179+
{{
180+
test.status(200);
181+
test.hasResponseBody();
182+
183+
const { equal } = require('assert');
184+
185+
test('Form update persisted', () => {
186+
const data = JSON.parse(response.body);
187+
equal(data.title, 'Form Lifecycle Test Form (Updated)', 'Updated title should persist');
188+
equal(data.dressing.color, '#0066cc', 'Dressing color should persist');
189+
equal(data.dressing.headerFont, 'BoutiqueBitmap7x7CircleDot', 'Dressing header font should persist');
190+
equal(data.dressing.questionFont, 'BoutiqueBitmap7x7SquareDot', 'Dressing question font should persist');
191+
equal(data.dressing.textFont, 'ChillBitmap16px', 'Dressing text font should persist');
192+
});
193+
}}
194+
195+
###
196+
197+
# ============================================
198+
# List Forms by Organization
199+
# ============================================
200+
# @name listFormsByOrg
201+
# @ref getUpdatedForm
202+
GET {{BASE_URL}}/orgs/{{orgSlug}}/forms
203+
204+
{{
205+
test.status(200);
206+
test.hasResponseBody();
207+
208+
const { equal } = require('assert');
209+
210+
test('Organization forms list contains created form', () => {
211+
const data = JSON.parse(response.body);
212+
equal(Array.isArray(data), true, 'Response should be an array');
213+
equal(data.some(f => f.id === formId), true, 'Created form should be in organization forms list');
214+
});
215+
}}

0 commit comments

Comments
 (0)