Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: handle cleanup data cypress #214

Merged
merged 5 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,3 @@ SEEDING=true docker compose -f docker-compose.e2e.yml up -d --build
```bash
yarn test:open-cypress
```

### Cypress Architecture

Structure in E2E folder:

- Cypress Configuration:
- `cypress.config.js`: Contains the configuration for Cypress.
- `tsconfig.json`: Contains the TypeScript configuration for Cypress.
- `package.json`: Contains the scripts and library for running Cypress.
- Test Files:
- Tests are organized under cypress/e2e/ . For example:
- cypress/e2e/issue_workflow_test/DFR/ for DFR related tests.
- Support Files:
- `e2e.ts`: Contains custom commands for Cypress.
- `index.ts`: Contains the setup for Cypress.
- Fixtures:
- JSON files for test data are stored in cypress/fixtures/.
2 changes: 1 addition & 1 deletion docker-compose.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ services:
context: .
dockerfile: Dockerfile
args:
CONFIG_FILE: ./cypress/fixtures/app-config.json
CONFIG_FILE: ./e2e/cypress/fixtures/app-config.json
ports:
- '3003:80'

Expand Down
21 changes: 21 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

### Cypress Architecture

Structure in E2E folder:

- Cypress Configuration:
- `cypress.config.js`: Contains the configuration for Cypress.
- `tsconfig.json`: Contains the TypeScript configuration for Cypress.
- `package.json`: Contains the scripts and libraries for running Cypress.
- Test Files:
- Tests are organized under cypress/e2e/ . For example:
- cypress/e2e/issue_workflow_test/DFR/ for DFR related tests.
- Support Files:
- `e2e.ts`: Contains custom commands for Cypress.
- `index.ts`: Contains the setup for Cypress.
- Fixtures:
- JSON files for test data are stored in cypress/fixtures/.

### Clean up data

Currently, the E2E tests clean up the data by deleting the Minio folder, which is bind-mounted from the Docker Compose file.
34 changes: 24 additions & 10 deletions e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,30 @@ export default defineConfig({
throw error;
}
},
deleteFileCredentialE2E(fileName: string) {
const filePath = path.resolve('cypress/fixtures/credentials-e2e', fileName);
return new Promise((resolve, reject) => {
fs.unlink(filePath, (err) => {
if (err) {
return reject(err);
}
resolve(null);
});
});
resetData(file?: string) {

const targetDir = path.resolve(
process.cwd(),
`../minio_data/identity-resolver-service-object-store/data-test/idr-bucket-1/gs1${file ? `/${file}` : ''}`
);

if (fs.existsSync(targetDir)) {
console.log(`Found folder: ${targetDir}`);
console.log('Deleting folder...');

fs.rmdirSync(targetDir, { recursive: true });

if (!fs.existsSync(targetDir)) {
console.log('Folder deleted successfully.');
return { success: true };
} else {
console.log('Failed to delete the folder.');
return { success: false };
}
} else {
console.log(`Folder not found: ${targetDir}`);
return { success: true };
}
},
async runUntpTest({ type, version, testData }) {
const { testCredentialHandler } = await import('untp-test-suite/src/interfaces/lib/testSuiteHandler');
Expand Down
1 change: 0 additions & 1 deletion e2e/cypress/e2e/issue_workflow_test/DCC/issueDCC.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class DCCIssueFlow extends IssuePage {
'General features',
'Generate DCC',
'getConformityCredential',
'DigitalConformityCredential_instance-v0.5.0.json',
'generalFeatures',
);
}
Expand Down
1 change: 0 additions & 1 deletion e2e/cypress/e2e/issue_workflow_test/DFR/issueDFR.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class DFRIssueFlow extends IssuePage {
'General features',
'Generate DFR',
'DigitalFacilityRecord',
'DigitalFacilityRecord_instance-v0.5.0.json',
'generalFeatures',
);
}
Expand Down
1 change: 0 additions & 1 deletion e2e/cypress/e2e/issue_workflow_test/DIA/issueDIA.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class DIAIssueFlow extends IssuePage {
'General features',
'Generate DIA',
'DigitalIdentityAnchor',
'DigitalIdentityAnchor_instance-v0.2.1.json',
'generalFeatures',
);
}
Expand Down
1 change: 0 additions & 1 deletion e2e/cypress/e2e/issue_workflow_test/DPP/issueDPP.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class DPPIssueFlow extends IssuePage {
'Orchard Facility',
'Issue DPP',
'DigitalProductPassport',
'DigitalProductPassport_instance-v0.5.0.json',
'apps',
);
}
Expand Down
Loading
Loading