Test & Deploy Guide
This guide covers the complete testing and deployment workflow in SoftyFlow, including running tests and managing versions across different environments.
Testing Your Application
Running Tests
SoftyFlow provides multiple ways to test your application components:
1. Component-Level Testing
- UI Testing: Test individual user interfaces in isolation
- Process Testing: Execute workflows step-by-step to validate business logic
- API Testing: Verify API endpoints and data flow
- Report Testing: Validate report generation and data accuracy
2. Integration Testing
- Test complete workflows from UI to backend processes
- Validate data flow between different components
- Ensure proper integration between APIs and databases
3. Real-Time Testing
// Example: Testing a process workflow
const testWorkflow = async () => {
// Trigger workflow instance
const instance = await ProcessService.createInstance(processId, testData);
// Monitor execution in real-time
const result = await instance.execute();
// Validate results
assert(result.status === 'completed');
};
Version Management System
SoftyFlow implements a comprehensive version management system that tracks every change across all application components.
Version Schema Structure
// Version Model Structure
{
name: String, // Version identifier
description: String, // Version description
ui: [{ // UI components
id: ObjectId, // Component ID
version: ObjectId // Specific version ID
}],
api: [{ // API components
id: ObjectId,
version: ObjectId
}],
process: [{ // Process components
id: ObjectId,
version: ObjectId
}],
report: [{ // Report components
id: ObjectId,
version: ObjectId
}],
customList: [{ // Custom list components
id: ObjectId,
version: ObjectId
}],
mode: String, // Environment: "test", "uat", "prod"
pushedToProd: Boolean, // Production deployment flag
projectId: ObjectId, // Associated project
createdBy: ObjectId, // Creator user
updatedBy: ObjectId // Last modifier
}
Creating and Managing Versions
1. Version Creation Process
<!-- Version Creation Form -->
<el-form :model="versionConfigForm" ref="versionConfigForm">
<el-form-item label="Name" prop="name">
<el-input v-model="versionConfigForm.name" placeholder="Version Name"></el-input>
</el-form-item>
<el-form-item label="Description" prop="description">
<el-input type="textarea" v-model="versionConfigForm.description"
placeholder="Version Description"></el-input>
</el-form-item>
<el-form-item label="Mode" prop="mode">
<div class="version-mode-selector">
<el-button @click="versionConfigForm.mode = 'test'"
:class="versionConfigForm.mode === 'test' ? 'selected' : ''">
TEST
</el-button>
<el-button @click="versionConfigForm.mode = 'uat'"
:class="versionConfigForm.mode === 'uat' ? 'selected' : ''"
disabled>
UAT
</el-button>
<el-button @click="versionConfigForm.mode = 'prod'"
:class="versionConfigForm.mode === 'prod' ? 'selected' : ''"
disabled>
PROD
</el-button>
</div>
</el-form-item>
</el-form>
2. Resource Selection and Versioning
The version management system allows you to:
- Select Components: Choose which UI, API, Process, Report, and Custom List components to include
- Version Control: Select specific versions of each component
- Bulk Operations: Add all resources at once or refresh to latest versions
- Cross-Project Resources: Import components from other projects
// Resource Management Methods
methods: {
// Add all resources to version
addAll(resourceType) {
const matchingResources = {
ui: "uis",
api: "apis",
process: "processes",
report: "reports",
customList: "customLists"
};
this[matchingResources[resourceType]].forEach((elem, index) => {
if (!this.version[resourceType].find(el => elem._id === el.id)) {
this.version[resourceType].push({
id: elem._id,
version: elem.latestVersion._id || elem.latestVersion
});
this.$set(this[matchingResources[resourceType]][index], 'checked', true);
}
});
},
// Refresh resources to latest versions
refreshResource(resourceType) {
this.version[resourceType].forEach((elem, index) => {
const resource = this[matchingResources[resourceType]].find(el => el._id === elem.id);
if (resource) {
this.$set(this.version[resourceType][index], 'version',
resource.latestVersion._id || resource.latestVersion);
}
});
}
}
Environment Management: TEST, UAT, PROD
SoftyFlow supports three distinct environments with specific characteristics and deployment flows.
Environment Hierarchy
TEST → UAT → PROD
1. TEST Environment
Purpose: Development and initial testing
- Color Code: Red (#F72B3D)
- Characteristics:
- Full editing capabilities
- Rapid iteration and testing
- No restrictions on changes
- Default environment for new versions
Usage:
// Creating a TEST version
const testVersion = {
name: "Feature-Login-v1.2",
description: "New login functionality with 2FA",
mode: "test",
ui: [{ id: uiId, version: latestUIVersion }],
process: [{ id: processId, version: latestProcessVersion }]
};
2. UAT Environment (User Acceptance Testing)
Purpose: Business user testing and validation
- Color Code: Orange (#FFBC6E)
- Characteristics:
- Stable versions ready for business testing
- Limited editing (promoted from TEST)
- End-user validation environment
- Pre-production testing
Promotion Process:
// Promoting from TEST to UAT
const promoteToUAT = async (versionId) => {
const version = await VersionApi.getVersion(versionId);
version.mode = 'uat';
// Create copies of all component versions for UAT
await VersionApi.updateVersion(versionId, version);
};
3. PROD Environment (Production)
Purpose: Live production environment
- Color Code: Green (#00BF78)
- Characteristics:
- Live production system
- Highest stability requirements
- Automatic
pushedToProd
flag setting - Component latest production version tracking
Production Deployment:
// Production deployment process
const deployToProd = async (versionId) => {
const version = await VersionApi.getVersion(versionId);
// Set production mode
version.mode = 'prod';
version.pushedToProd = true;
// Update component production versions
const updatePromises = [];
// Update UI components
version.ui.forEach(ui => {
updatePromises.push(
UI.findByIdAndUpdate(ui.id, {
latestProd: ui.version,
latestVProd: versionId
})
);
});
// Similar updates for other component types...
await Promise.all(updatePromises);
// Demote previous PROD versions to TEST
await Versions.updateMany(
{ projectId: version.projectId, mode: 'prod' },
{ mode: 'test' }
);
};
Advanced Version Management Features
1. Version History and Comparison
// Get version history for a component
const getVersionHistory = async (componentId, componentType) => {
const history = await VersionService.getHistory(componentId, componentType);
return history.map(version => ({
id: version._id,
createdAt: version.createdAt,
createdBy: version.createdBy.email,
comment: version.comment,
mode: version.mode
}));
};
2. Version Status Tracking
The system provides real-time status tracking across environments:
<!-- Version Status Display -->
<div class="version-status-container">
<VersionInfoBox
:data="{
color: '#F72B3D',
title: 'TEST',
value: versionsStatus.test,
progressValue: (versionsStatus.test * 100) / versionsStatus.total
}"
/>
<VersionInfoBox
:data="{
color: '#FFBC6E',
title: 'UAT',
value: versionsStatus.uat,
progressValue: (versionsStatus.uat * 100) / versionsStatus.total
}"
/>
<VersionInfoBox
:data="{
color: '#00BF78',
title: 'PROD',
value: versionsStatus.prod,
progressValue: (versionsStatus.prod * 100) / versionsStatus.total
}"
/>
</div>
3. Instance Management
Track running instances across environments:
// Get version instances status
const getVersionInstancesStatus = async (projectId, versionId) => {
const aggregation = [
{
$match: {
$and: [
{ projectId: ObjectId(projectId) },
{ versionId: ObjectId(versionId) }
]
}
},
{
$group: {
_id: "$mode",
count: { $sum: 1 }
}
}
];
const instances = await InstanceService.getInstances(aggregation);
return {
test: instances.find(i => i._id === 'test')?.count || 0,
uat: instances.find(i => i._id === 'uat')?.count || 0,
prod: instances.find(i => i._id === 'prod')?.count || 0
};
};
Deployment Workflow
1. Standard Deployment Process
graph TD
A[Develop in TEST] --> B[Test & Validate]
B --> C[Create Version]
C --> D[Push to UAT]
D --> E[Business Testing]
E --> F[Push to PROD]
F --> G[Production Monitoring]
2. Version Promotion
// Version promotion workflow
const promoteVersion = async (versionId, targetMode) => {
// Validation
if (targetMode === 'prod') {
const confirmed = await confirmProductionDeployment();
if (!confirmed) return;
}
// Get current version
const version = await VersionApi.getVersion(versionId);
// Create component version copies for target environment
await createComponentVersions(version, targetMode);
// Update version mode
version.mode = targetMode;
// Save updated version
await VersionApi.updateVersion(versionId, version);
// Update project global mode if necessary
await updateProjectGlobalMode(version.projectId);
};
3. Rollback Capabilities
// Rollback to previous version
const rollbackVersion = async (projectId, targetMode) => {
// Find previous stable version
const previousVersion = await Versions.findOne({
projectId,
mode: targetMode,
pushedToProd: true
}).sort({ updatedAt: -1 }).skip(1);
if (previousVersion) {
// Restore previous version
await promoteVersion(previousVersion._id, targetMode);
}
};
Best Practices
1. Version Naming Conventions
- Use semantic versioning:
v1.2.3
- Include feature descriptions:
Login-Enhancement-v1.2
- Add environment indicators:
UAT-Release-2024.01
2. Testing Strategy
- Unit Testing: Test individual components in TEST
- Integration Testing: Validate component interactions in UAT
- User Acceptance: Business validation in UAT
- Production Monitoring: Continuous monitoring in PROD
3. Deployment Safety
- Always test in TEST environment first
- Validate in UAT before PROD deployment
- Maintain rollback plans for PROD deployments
- Monitor system health after deployments
4. Version Control
- Create meaningful version descriptions
- Tag important releases
- Maintain version history
- Document breaking changes
Monitoring and Troubleshooting
1. Version Status Monitoring
Monitor version deployment status across environments:
// Monitor deployment status
const monitorDeployment = async (versionId) => {
const status = await VersionApi.getDeploymentStatus(versionId);
return {
deployed: status.deployed,
instances: status.instances,
errors: status.errors,
performance: status.performance
};
};
2. Error Handling
// Handle deployment errors
const handleDeploymentError = (error, versionId) => {
if (error.code === 'TIMEOUT') {
// Handle timeout scenarios
showTimeoutDialog(versionId);
} else if (error.code === 'VALIDATION_FAILED') {
// Handle validation errors
showValidationErrors(error.details);
}
};
This comprehensive version management system ensures safe, traceable, and efficient deployment of applications across all environments while maintaining full control over component versions and deployment history.