@globisnv/cypress-core 0.0.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 +255 -0
- package/bin/create-customer-repo.mjs +89 -0
- package/biome.json +49 -0
- package/dist/apiMethods/IGS_request.d.ts +98 -0
- package/dist/apiMethods/IGS_request.js +161 -0
- package/dist/apiMethods/IGS_response.d.ts +47 -0
- package/dist/apiMethods/IGS_response.js +1 -0
- package/dist/blueprints/GLO_addressPopup.d.ts +45 -0
- package/dist/blueprints/GLO_addressPopup.js +96 -0
- package/dist/blueprints/GLO_article.d.ts +45 -0
- package/dist/blueprints/GLO_article.js +110 -0
- package/dist/blueprints/GLO_articleLot.d.ts +12 -0
- package/dist/blueprints/GLO_articleLot.js +23 -0
- package/dist/blueprints/GLO_articleVersion.d.ts +4 -0
- package/dist/blueprints/GLO_articleVersion.js +4 -0
- package/dist/blueprints/GLO_attachmentPopup.d.ts +9 -0
- package/dist/blueprints/GLO_attachmentPopup.js +10 -0
- package/dist/blueprints/GLO_bankAccount.d.ts +7 -0
- package/dist/blueprints/GLO_bankAccount.js +7 -0
- package/dist/blueprints/GLO_billingProcess.d.ts +4 -0
- package/dist/blueprints/GLO_billingProcess.js +4 -0
- package/dist/blueprints/GLO_billingProposal.d.ts +9 -0
- package/dist/blueprints/GLO_billingProposal.js +9 -0
- package/dist/blueprints/GLO_cancel.d.ts +7 -0
- package/dist/blueprints/GLO_cancel.js +7 -0
- package/dist/blueprints/GLO_commandlist.d.ts +10 -0
- package/dist/blueprints/GLO_commandlist.js +10 -0
- package/dist/blueprints/GLO_complaint.d.ts +27 -0
- package/dist/blueprints/GLO_complaint.js +51 -0
- package/dist/blueprints/GLO_composition.d.ts +14 -0
- package/dist/blueprints/GLO_composition.js +20 -0
- package/dist/blueprints/GLO_consignment.d.ts +61 -0
- package/dist/blueprints/GLO_consignment.js +104 -0
- package/dist/blueprints/GLO_consignmentContainerGroup.d.ts +6 -0
- package/dist/blueprints/GLO_consignmentContainerGroup.js +6 -0
- package/dist/blueprints/GLO_consignmentGoods.d.ts +40 -0
- package/dist/blueprints/GLO_consignmentGoods.js +62 -0
- package/dist/blueprints/GLO_consignmentHandling.d.ts +4 -0
- package/dist/blueprints/GLO_consignmentHandling.js +4 -0
- package/dist/blueprints/GLO_consignmentOrder.d.ts +31 -0
- package/dist/blueprints/GLO_consignmentOrder.js +37 -0
- package/dist/blueprints/GLO_consignmentPart.d.ts +13 -0
- package/dist/blueprints/GLO_consignmentPart.js +13 -0
- package/dist/blueprints/GLO_consignmentParts.d.ts +5 -0
- package/dist/blueprints/GLO_consignmentParts.js +12 -0
- package/dist/blueprints/GLO_consignmentPrice.d.ts +11 -0
- package/dist/blueprints/GLO_consignmentPrice.js +19 -0
- package/dist/blueprints/GLO_consignmentSupplier.d.ts +6 -0
- package/dist/blueprints/GLO_consignmentSupplier.js +11 -0
- package/dist/blueprints/GLO_contacts.d.ts +10 -0
- package/dist/blueprints/GLO_contacts.js +14 -0
- package/dist/blueprints/GLO_container.d.ts +6 -0
- package/dist/blueprints/GLO_container.js +4 -0
- package/dist/blueprints/GLO_contract.d.ts +22 -0
- package/dist/blueprints/GLO_contract.js +30 -0
- package/dist/blueprints/GLO_contractArticle.d.ts +17 -0
- package/dist/blueprints/GLO_contractArticle.js +35 -0
- package/dist/blueprints/GLO_contractArticleCost.d.ts +5 -0
- package/dist/blueprints/GLO_contractArticleCost.js +8 -0
- package/dist/blueprints/GLO_countryVatZone.d.ts +8 -0
- package/dist/blueprints/GLO_countryVatZone.js +9 -0
- package/dist/blueprints/GLO_currencyDeviation.d.ts +14 -0
- package/dist/blueprints/GLO_currencyDeviation.js +15 -0
- package/dist/blueprints/GLO_customerArticle.d.ts +12 -0
- package/dist/blueprints/GLO_customerArticle.js +15 -0
- package/dist/blueprints/GLO_customsFlow.d.ts +8 -0
- package/dist/blueprints/GLO_customsFlow.js +19 -0
- package/dist/blueprints/GLO_customsFlowDefinition.d.ts +15 -0
- package/dist/blueprints/GLO_customsFlowDefinition.js +14 -0
- package/dist/blueprints/GLO_customsUnion.d.ts +4 -0
- package/dist/blueprints/GLO_customsUnion.js +4 -0
- package/dist/blueprints/GLO_deliveryReceipt.d.ts +10 -0
- package/dist/blueprints/GLO_deliveryReceipt.js +22 -0
- package/dist/blueprints/GLO_departureSchedule.d.ts +27 -0
- package/dist/blueprints/GLO_departureSchedule.js +57 -0
- package/dist/blueprints/GLO_departureScheduleTimes.d.ts +49 -0
- package/dist/blueprints/GLO_departureScheduleTimes.js +61 -0
- package/dist/blueprints/GLO_document.d.ts +7 -0
- package/dist/blueprints/GLO_document.js +7 -0
- package/dist/blueprints/GLO_documentAttachment.d.ts +4 -0
- package/dist/blueprints/GLO_documentAttachment.js +4 -0
- package/dist/blueprints/GLO_documentDefinitionEntity.d.ts +5 -0
- package/dist/blueprints/GLO_documentDefinitionEntity.js +5 -0
- package/dist/blueprints/GLO_documentGroup.d.ts +4 -0
- package/dist/blueprints/GLO_documentGroup.js +4 -0
- package/dist/blueprints/GLO_documentType.d.ts +12 -0
- package/dist/blueprints/GLO_documentType.js +11 -0
- package/dist/blueprints/GLO_enterCountry.d.ts +21 -0
- package/dist/blueprints/GLO_enterCountry.js +47 -0
- package/dist/blueprints/GLO_enterDiscount.d.ts +8 -0
- package/dist/blueprints/GLO_enterDiscount.js +9 -0
- package/dist/blueprints/GLO_equipment.d.ts +34 -0
- package/dist/blueprints/GLO_equipment.js +55 -0
- package/dist/blueprints/GLO_equipmentCategory.d.ts +15 -0
- package/dist/blueprints/GLO_equipmentCategory.js +14 -0
- package/dist/blueprints/GLO_equipmentEntity.d.ts +5 -0
- package/dist/blueprints/GLO_equipmentEntity.js +5 -0
- package/dist/blueprints/GLO_equipmentServiceCategory.d.ts +13 -0
- package/dist/blueprints/GLO_equipmentServiceCategory.js +13 -0
- package/dist/blueprints/GLO_equipmentType.d.ts +21 -0
- package/dist/blueprints/GLO_equipmentType.js +20 -0
- package/dist/blueprints/GLO_equipmentTypeServiceCategory.d.ts +13 -0
- package/dist/blueprints/GLO_equipmentTypeServiceCategory.js +12 -0
- package/dist/blueprints/GLO_fieldInputValidation.d.ts +46 -0
- package/dist/blueprints/GLO_fieldInputValidation.js +73 -0
- package/dist/blueprints/GLO_formula.d.ts +9 -0
- package/dist/blueprints/GLO_formula.js +9 -0
- package/dist/blueprints/GLO_gang.d.ts +12 -0
- package/dist/blueprints/GLO_gang.js +12 -0
- package/dist/blueprints/GLO_holiday.d.ts +7 -0
- package/dist/blueprints/GLO_holiday.js +8 -0
- package/dist/blueprints/GLO_journey.d.ts +18 -0
- package/dist/blueprints/GLO_journey.js +24 -0
- package/dist/blueprints/GLO_journeyStop.d.ts +32 -0
- package/dist/blueprints/GLO_journeyStop.js +44 -0
- package/dist/blueprints/GLO_layout.d.ts +6 -0
- package/dist/blueprints/GLO_layout.js +6 -0
- package/dist/blueprints/GLO_logging.d.ts +9 -0
- package/dist/blueprints/GLO_logging.js +12 -0
- package/dist/blueprints/GLO_logisticConnection.d.ts +10 -0
- package/dist/blueprints/GLO_logisticConnection.js +11 -0
- package/dist/blueprints/GLO_logisticConnectionType.d.ts +5 -0
- package/dist/blueprints/GLO_logisticConnectionType.js +5 -0
- package/dist/blueprints/GLO_logisticContract.d.ts +28 -0
- package/dist/blueprints/GLO_logisticContract.js +80 -0
- package/dist/blueprints/GLO_logisticContractDetail.d.ts +42 -0
- package/dist/blueprints/GLO_logisticContractDetail.js +122 -0
- package/dist/blueprints/GLO_logisticContractDetailHandling.d.ts +11 -0
- package/dist/blueprints/GLO_logisticContractDetailHandling.js +14 -0
- package/dist/blueprints/GLO_logisticContractDetailItem.d.ts +5 -0
- package/dist/blueprints/GLO_logisticContractDetailItem.js +8 -0
- package/dist/blueprints/GLO_logisticContractItem.d.ts +14 -0
- package/dist/blueprints/GLO_logisticContractItem.js +40 -0
- package/dist/blueprints/GLO_logisticContractItemActivity.d.ts +4 -0
- package/dist/blueprints/GLO_logisticContractItemActivity.js +4 -0
- package/dist/blueprints/GLO_logisticContractItemSurcharge.d.ts +7 -0
- package/dist/blueprints/GLO_logisticContractItemSurcharge.js +7 -0
- package/dist/blueprints/GLO_logisticContractItemSurchargeItem.d.ts +4 -0
- package/dist/blueprints/GLO_logisticContractItemSurchargeItem.js +4 -0
- package/dist/blueprints/GLO_logisticContractReference.d.ts +4 -0
- package/dist/blueprints/GLO_logisticContractReference.js +4 -0
- package/dist/blueprints/GLO_logisticContractVolumeConstraint.d.ts +9 -0
- package/dist/blueprints/GLO_logisticContractVolumeConstraint.js +8 -0
- package/dist/blueprints/GLO_logisticLocation.d.ts +7 -0
- package/dist/blueprints/GLO_logisticLocation.js +7 -0
- package/dist/blueprints/GLO_logisticPriceRequestDetailExternalPrice.d.ts +19 -0
- package/dist/blueprints/GLO_logisticPriceRequestDetailExternalPrice.js +30 -0
- package/dist/blueprints/GLO_logisticPurchaseOrder.d.ts +4 -0
- package/dist/blueprints/GLO_logisticPurchaseOrder.js +4 -0
- package/dist/blueprints/GLO_logistic_waiting_hours.d.ts +6 -0
- package/dist/blueprints/GLO_logistic_waiting_hours.js +6 -0
- package/dist/blueprints/GLO_operationalDefault.d.ts +23 -0
- package/dist/blueprints/GLO_operationalDefault.js +25 -0
- package/dist/blueprints/GLO_outputDetailMail.d.ts +14 -0
- package/dist/blueprints/GLO_outputDetailMail.js +13 -0
- package/dist/blueprints/GLO_postalcode.d.ts +6 -0
- package/dist/blueprints/GLO_postalcode.js +6 -0
- package/dist/blueprints/GLO_priceDependency.d.ts +5 -0
- package/dist/blueprints/GLO_priceDependency.js +4 -0
- package/dist/blueprints/GLO_priceEntry.d.ts +17 -0
- package/dist/blueprints/GLO_priceEntry.js +17 -0
- package/dist/blueprints/GLO_priceRequest.d.ts +8 -0
- package/dist/blueprints/GLO_priceRequest.js +20 -0
- package/dist/blueprints/GLO_priceRequestLine.d.ts +12 -0
- package/dist/blueprints/GLO_priceRequestLine.js +17 -0
- package/dist/blueprints/GLO_principal.d.ts +9 -0
- package/dist/blueprints/GLO_principal.js +13 -0
- package/dist/blueprints/GLO_printPopup.d.ts +10 -0
- package/dist/blueprints/GLO_printPopup.js +62 -0
- package/dist/blueprints/GLO_production.d.ts +9 -0
- package/dist/blueprints/GLO_production.js +9 -0
- package/dist/blueprints/GLO_productionLineMaterial.d.ts +8 -0
- package/dist/blueprints/GLO_productionLineMaterial.js +13 -0
- package/dist/blueprints/GLO_productionMaterial.d.ts +5 -0
- package/dist/blueprints/GLO_productionMaterial.js +5 -0
- package/dist/blueprints/GLO_purchaseCosts.d.ts +6 -0
- package/dist/blueprints/GLO_purchaseCosts.js +9 -0
- package/dist/blueprints/GLO_purchaseInvoice.d.ts +12 -0
- package/dist/blueprints/GLO_purchaseInvoice.js +25 -0
- package/dist/blueprints/GLO_purchaseInvoiceLine.d.ts +8 -0
- package/dist/blueprints/GLO_purchaseInvoiceLine.js +13 -0
- package/dist/blueprints/GLO_purchaseOrder.d.ts +14 -0
- package/dist/blueprints/GLO_purchaseOrder.js +25 -0
- package/dist/blueprints/GLO_purchaseOrderLine.d.ts +10 -0
- package/dist/blueprints/GLO_purchaseOrderLine.js +24 -0
- package/dist/blueprints/GLO_purchasePrices.d.ts +10 -0
- package/dist/blueprints/GLO_purchasePrices.js +10 -0
- package/dist/blueprints/GLO_quotation.d.ts +12 -0
- package/dist/blueprints/GLO_quotation.js +32 -0
- package/dist/blueprints/GLO_quotationLine.d.ts +12 -0
- package/dist/blueprints/GLO_quotationLine.js +28 -0
- package/dist/blueprints/GLO_receipt.d.ts +13 -0
- package/dist/blueprints/GLO_receipt.js +17 -0
- package/dist/blueprints/GLO_receiptFromTempReceipt.d.ts +8 -0
- package/dist/blueprints/GLO_receiptFromTempReceipt.js +8 -0
- package/dist/blueprints/GLO_receiptLine.d.ts +22 -0
- package/dist/blueprints/GLO_receiptLine.js +28 -0
- package/dist/blueprints/GLO_relationAddress.d.ts +26 -0
- package/dist/blueprints/GLO_relationAddress.js +58 -0
- package/dist/blueprints/GLO_relationBankAccount.d.ts +9 -0
- package/dist/blueprints/GLO_relationBankAccount.js +9 -0
- package/dist/blueprints/GLO_relationContact.d.ts +23 -0
- package/dist/blueprints/GLO_relationContact.js +45 -0
- package/dist/blueprints/GLO_relationGroupType.d.ts +7 -0
- package/dist/blueprints/GLO_relationGroupType.js +6 -0
- package/dist/blueprints/GLO_relations.d.ts +67 -0
- package/dist/blueprints/GLO_relations.js +186 -0
- package/dist/blueprints/GLO_relationtype.d.ts +15 -0
- package/dist/blueprints/GLO_relationtype.js +31 -0
- package/dist/blueprints/GLO_remarkType.d.ts +10 -0
- package/dist/blueprints/GLO_remarkType.js +9 -0
- package/dist/blueprints/GLO_remarkTypeDefaultValue.d.ts +4 -0
- package/dist/blueprints/GLO_remarkTypeDefaultValue.js +14 -0
- package/dist/blueprints/GLO_remarkTypeEntityType.d.ts +10 -0
- package/dist/blueprints/GLO_remarkTypeEntityType.js +9 -0
- package/dist/blueprints/GLO_representative.d.ts +7 -0
- package/dist/blueprints/GLO_representative.js +6 -0
- package/dist/blueprints/GLO_salesInvoice.d.ts +9 -0
- package/dist/blueprints/GLO_salesInvoice.js +15 -0
- package/dist/blueprints/GLO_salesInvoiceLine.d.ts +9 -0
- package/dist/blueprints/GLO_salesInvoiceLine.js +13 -0
- package/dist/blueprints/GLO_salesOrder.d.ts +13 -0
- package/dist/blueprints/GLO_salesOrder.js +25 -0
- package/dist/blueprints/GLO_salesOrderLine.d.ts +13 -0
- package/dist/blueprints/GLO_salesOrderLine.js +34 -0
- package/dist/blueprints/GLO_stockCorrection.d.ts +14 -0
- package/dist/blueprints/GLO_stockCorrection.js +24 -0
- package/dist/blueprints/GLO_stopSchedule.d.ts +4 -0
- package/dist/blueprints/GLO_stopSchedule.js +4 -0
- package/dist/blueprints/GLO_supplierArticle.d.ts +8 -0
- package/dist/blueprints/GLO_supplierArticle.js +8 -0
- package/dist/blueprints/GLO_tclSetting.d.ts +6 -0
- package/dist/blueprints/GLO_tclSetting.js +6 -0
- package/dist/blueprints/GLO_todo.d.ts +10 -0
- package/dist/blueprints/GLO_todo.js +21 -0
- package/dist/blueprints/GLO_todoSchedule.d.ts +23 -0
- package/dist/blueprints/GLO_todoSchedule.js +79 -0
- package/dist/blueprints/GLO_tractionDistance.d.ts +6 -0
- package/dist/blueprints/GLO_tractionDistance.js +6 -0
- package/dist/blueprints/GLO_transportOrder.d.ts +4 -0
- package/dist/blueprints/GLO_transportOrder.js +4 -0
- package/dist/blueprints/GLO_transportPrice.d.ts +18 -0
- package/dist/blueprints/GLO_transportPrice.js +34 -0
- package/dist/blueprints/GLO_transportRequirement.d.ts +18 -0
- package/dist/blueprints/GLO_transportRequirement.js +32 -0
- package/dist/blueprints/GLO_transportRequirementContainer.d.ts +8 -0
- package/dist/blueprints/GLO_transportRequirementContainer.js +8 -0
- package/dist/blueprints/GLO_transportRequirementGoods.d.ts +33 -0
- package/dist/blueprints/GLO_transportRequirementGoods.js +51 -0
- package/dist/blueprints/GLO_transportScenarioExecutionLeg.d.ts +6 -0
- package/dist/blueprints/GLO_transportScenarioExecutionLeg.js +6 -0
- package/dist/blueprints/GLO_transportStock.d.ts +4 -0
- package/dist/blueprints/GLO_transportStock.js +4 -0
- package/dist/blueprints/GLO_visit.d.ts +9 -0
- package/dist/blueprints/GLO_visit.js +10 -0
- package/dist/blueprints/GLO_warehouseMove.d.ts +9 -0
- package/dist/blueprints/GLO_warehouseMove.js +9 -0
- package/dist/blueprints/GLO_warehouseOrderSubline.d.ts +6 -0
- package/dist/blueprints/GLO_warehouseOrderSubline.js +11 -0
- package/dist/blueprints/GLO_workflowLoggingTable.d.ts +20 -0
- package/dist/blueprints/GLO_workflowLoggingTable.js +20 -0
- package/dist/blueprints/GLO_workflowVerification.d.ts +10 -0
- package/dist/blueprints/GLO_workflowVerification.js +19 -0
- package/dist/blueprints/GLO_zone.d.ts +9 -0
- package/dist/blueprints/GLO_zone.js +9 -0
- package/dist/blueprints/GLO_zone_postalcode.d.ts +12 -0
- package/dist/blueprints/GLO_zone_postalcode.js +10 -0
- package/dist/blueprints/GLO_zone_type.d.ts +8 -0
- package/dist/blueprints/GLO_zone_type.js +7 -0
- package/dist/blueprints/GLT_goods.d.ts +2 -0
- package/dist/blueprints/GLT_goods.js +12 -0
- package/dist/commands/FOB_commands.d.ts +124 -0
- package/dist/commands/FOB_commands.js +211 -0
- package/dist/commands/GLJ_commands.d.ts +28 -0
- package/dist/commands/GLJ_commands.js +40 -0
- package/dist/commands/GLO_commands.d.ts +685 -0
- package/dist/commands/GLO_commands.js +2315 -0
- package/dist/commands/GLS_commands.d.ts +63 -0
- package/dist/commands/GLS_commands.js +103 -0
- package/dist/commands/GLT_commands.d.ts +78 -0
- package/dist/commands/GLT_commands.js +148 -0
- package/dist/commands/POR_commands.d.ts +85 -0
- package/dist/commands/POR_commands.js +122 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +115 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +15 -0
- package/dist/plugins/prometheusWriter.d.ts +15 -0
- package/dist/plugins/prometheusWriter.js +111 -0
- package/dist/register.d.ts +8 -0
- package/dist/register.js +23 -0
- package/dist/tsHelper.d.ts +161 -0
- package/dist/tsHelper.js +294 -0
- package/dist/types.d.ts +363 -0
- package/dist/types.js +4 -0
- package/dist/websocketDetector.d.ts +71 -0
- package/dist/websocketDetector.js +1593 -0
- package/package.json +58 -0
- package/scripts/check-unnecessary-waiting.mjs +119 -0
- package/template/CODEOWNERS +20 -0
- package/template/biome.json +7 -0
- package/template/cypress/e2e/__CUSTOMER__/template.cy.ts.example +18 -0
- package/template/cypress/support/e2e.ts +21 -0
- package/template/cypress/support/record.mjs +46 -0
- package/template/cypress.config.ts +3 -0
- package/template/cypress.env.json.example +24 -0
- package/template/package.json +20 -0
- package/template/tsconfig.json +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# @globisnv/cypress-core
|
|
2
|
+
|
|
3
|
+
Core building blocks for Globis Cypress E2E tests.
|
|
4
|
+
|
|
5
|
+
This package holds everything that is *not* customer-specific: the shared Cypress config factory, the custom command library for the Servoy-based Globis solutions, the WebSocket-aware loading detector, the reusable data-entry blueprints, and the lint scripts. Customer repos install it, call `defineGlobisConfig()` in their `cypress.config.ts`, import `@globisnv/cypress-core/register` in their support file, and only keep their own specs and customer-specific commands locally.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @globisnv/cypress-core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Peer dependencies (must be installed in the consumer repo):
|
|
16
|
+
|
|
17
|
+
| Package | Range |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| `cypress` | `^15.19.0` |
|
|
20
|
+
| `cypress-real-events` | `^1.15.0` |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Compatibility with Globis Online
|
|
25
|
+
|
|
26
|
+
Core's own version is plain semver, deliberately **not** tied to globis-online's version numbers — the two release on independent schedules, and forcing them to share digits would mean bumping core every time globis-online ships a release that doesn't touch anything core depends on.
|
|
27
|
+
|
|
28
|
+
Instead, each core release declares the **minimum** globis-online version it requires — a floor, not a pin. Blueprints and commands are written against a given release's Servoy DOM/behavior; they keep working on every later globis-online release *until* one of them actually changes something a blueprint depends on, at which point core needs a new version anyway, with its floor bumped to that release. There's no meaningful upper bound to declare in advance — you only find out a version broke something by running against it.
|
|
29
|
+
|
|
30
|
+
| Core version | Minimum globis-online version |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| `0.0.1` | `11.0.2` |
|
|
33
|
+
|
|
34
|
+
The floor is recorded in `package.json` under `globisOnline.minVersion` (machine-readable, in case tooling wants to check it later) and here in this table (human-readable, updated on every release alongside `CHANGELOG.md`). `globis-cypress` stays pinned to the latest core version — since it's Globis's own suite, it's the first thing to catch a globis-online release breaking something, before any customer repo would.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Setting up a new customer repo
|
|
39
|
+
|
|
40
|
+
Starting a brand-new customer test repo from a blank slate — no manual copy-pasting from an existing one:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx -p @globisnv/cypress-core create-globis-customer-repo
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
It asks two questions — a target folder (e.g. `acme-cypress`) and the customer's 3-letter abbreviation (e.g. `ACM`) — then:
|
|
47
|
+
|
|
48
|
+
- Copies a minimal template into that folder: `package.json`, `tsconfig.json`, `biome.json`, `cypress.config.ts`, `cypress.env.json.example`, `CODEOWNERS`, `.gitignore`, `cypress/support/{e2e.ts,record.ts}`, and a starter `cypress/e2e/<abbrev>/template.cy.ts.example`.
|
|
49
|
+
- Runs `git init` and `npm install`.
|
|
50
|
+
|
|
51
|
+
The generated repo has fresh history (nothing cloned or filtered from any other repo) and depends on `@globisnv/cypress-core` like any other consumer — no local customer commands or blueprints are pre-populated, so it can never leak another customer's code. From there:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cd acme-cypress
|
|
55
|
+
cp cypress.env.json.example cypress.env.json # fill in your credentials
|
|
56
|
+
npx cypress open --e2e --browser chrome
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
|
|
63
|
+
### 1. `cypress.config.ts`
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { defineGlobisConfig } from '@globisnv/cypress-core/config';
|
|
67
|
+
|
|
68
|
+
export default defineGlobisConfig({
|
|
69
|
+
// Scalar e2e overrides — merged over the core defaults
|
|
70
|
+
e2e: {
|
|
71
|
+
specPattern: 'cypress/e2e/**/*.cy.ts',
|
|
72
|
+
defaultCommandTimeout: 20000,
|
|
73
|
+
// Optional: runs *after* the core wiring, on the same `on`/`config`
|
|
74
|
+
setupNodeEvents(on, config) {
|
|
75
|
+
// customer-specific node events
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
// Optional: extra cy.task() handlers alongside the core ones
|
|
79
|
+
extraTasks: {
|
|
80
|
+
myTask(arg) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`defineGlobisConfig()` ([src/config.ts](src/config.ts)) sets the shared defaults — 1920×1080 viewport, video on without compression, a 120s response timeout, `experimentalMemoryManagement`, `scrollBehavior: 'center'` — and wires:
|
|
88
|
+
|
|
89
|
+
- **Env exposure** — every `config.env` key is copied to `config.expose` *except* the sensitive ones (`password`, `password2`, `api_key`, `QLIKURLS`, `S3_KEY`, `S3_SECRET`), which stay node-side.
|
|
90
|
+
- **Core tasks** — `log`, `set`, `get` (a process-scoped key/value store shared across specs), `bufferWsMetrics` and `flushWsMetrics`.
|
|
91
|
+
- **Browser sizing** — a `before:browser:launch` hook forcing 1920×1080 and `--force-device-scale-factor=1` for headless Chrome, plus Firefox/Electron equivalents.
|
|
92
|
+
|
|
93
|
+
### 2. `cypress/support/e2e.ts`
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import '@globisnv/cypress-core/register';
|
|
97
|
+
|
|
98
|
+
// Customer-specific commands stay local:
|
|
99
|
+
import './commands/ACME_commands';
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
[src/register.ts](src/register.ts) imports all generic command files, the WebSocket detector, and `cypress-real-events`. It also registers a `beforeEach` + `Cypress.on('fail')` pair that flags a failed test through the `set`/`get` task, so cleanup commands like `GLO_closeDashboard` can bail out instead of masking the real error with a secondary failure in the cloud report.
|
|
103
|
+
|
|
104
|
+
### 3. Blueprints, commands and helpers
|
|
105
|
+
|
|
106
|
+
Blueprints and generic command files are **not** re-exported from the package root — import them via their subpath:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { GLO_enterEquipment, type objEquipment } from '@globisnv/cypress-core/blueprints/GLO_equipment';
|
|
110
|
+
import { getUUID, getDate, open, close, check } from '@globisnv/cypress-core/tsHelper';
|
|
111
|
+
import { createRequestVariables } from '@globisnv/cypress-core/apiMethods/IGS_request';
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Available subpaths:
|
|
115
|
+
|
|
116
|
+
| Subpath | Contents |
|
|
117
|
+
| --- | --- |
|
|
118
|
+
| `.` | `defineGlobisConfig` only — safe to import from `cypress.config.ts` |
|
|
119
|
+
| `./register` | Side-effect import that registers all commands |
|
|
120
|
+
| `./config` | The config factory on its own |
|
|
121
|
+
| `./tsHelper` | Constants, branded flags and helper functions |
|
|
122
|
+
| `./types` | Ambient/global type declarations |
|
|
123
|
+
| `./blueprints/*` | Per-program data-entry blueprints |
|
|
124
|
+
| `./commands/*` | Individual command files |
|
|
125
|
+
| `./apiMethods/*` | REST request/response helpers |
|
|
126
|
+
|
|
127
|
+
> Do **not** try to reach these through custom tsconfig path aliases pointing into `node_modules`. `tsconfig-paths-webpack-plugin` (which Cypress's default preprocessor uses) silently ignores mappings that resolve inside `node_modules` — they typecheck but fail to bundle. Real package subpath exports resolve correctly in both `tsc` and webpack.
|
|
128
|
+
|
|
129
|
+
> `tsHelper` is deliberately **not** re-exported from the package root. Its top-level `Cypress.expose(...)` call only works in a browser-context (spec/support) process — `cypress.config.ts` runs in Node, so the root import (`.`) has to stay safe to use there. Always import `tsHelper` via `@globisnv/cypress-core/tsHelper` explicitly.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## What's in the box
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
src/
|
|
137
|
+
├── config.ts # defineGlobisConfig() — the shared cypress.config factory
|
|
138
|
+
├── register.ts # side-effect entrypoint: loads all generic commands
|
|
139
|
+
├── index.ts # public API (config factory + tsHelper re-export)
|
|
140
|
+
├── tsHelper.ts # constants, branded boolean flags, date/UUID/number helpers, cleanup formulas
|
|
141
|
+
├── types.ts # global ambient types (selectors, dialogs, WebSocket protocol, extended filters)
|
|
142
|
+
├── websocketDetector.ts # WebSocket spy + WS_loadingCheck state machine
|
|
143
|
+
├── blueprints/ # 132 per-program data-entry blueprints
|
|
144
|
+
├── commands/ # 6 generic command files (~128 custom commands)
|
|
145
|
+
├── apiMethods/ # IGS REST request/response helpers
|
|
146
|
+
└── plugins/ # prometheusWriter — SigV4-signed remote write to AWS AMP
|
|
147
|
+
scripts/ # standalone lint rules (shipped to consumers)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Command families
|
|
151
|
+
|
|
152
|
+
Each command file targets one Globis solution. All are loaded by `register.ts`.
|
|
153
|
+
|
|
154
|
+
| Prefix | Solution | Commands |
|
|
155
|
+
| --- | --- | --- |
|
|
156
|
+
| `GLO_` | Globis Online (the main Servoy client) | 79 |
|
|
157
|
+
| `FOB_` | Form Builder | 17 |
|
|
158
|
+
| `GLT_` | GlobTake (`/solution/globtake`) | 11 |
|
|
159
|
+
| `POR_` | Portal | 10 |
|
|
160
|
+
| `GLS_` | GlobScan (`/solution/globscan`) | 8 |
|
|
161
|
+
| `GLJ_` | GlobJob (`/solution/globjob`) | 3 |
|
|
162
|
+
| `WS_` | WebSocket helpers (from `websocketDetector.ts`) | 3 |
|
|
163
|
+
|
|
164
|
+
`GLO_commands.ts` is the backbone: login/logout and company/user switching, element lookup (`GLO_getElement`), input/date/checkbox/radio entry, grid interaction (select, sort, filter, row lookup, custom views), dialog handling, datacontrol buttons, extended filters, file upload/read, and value storage between steps. Every command carries a JSDoc block with its parameters — that is the reference documentation.
|
|
165
|
+
|
|
166
|
+
### Blueprints
|
|
167
|
+
|
|
168
|
+
A blueprint is a typed object plus a function that fills in one program's detail form. For example [GLO_equipment.ts](src/blueprints/GLO_equipment.ts) exports `objEquipment` and `GLO_enterEquipment(obj, tabName?)`, which walks the fields with `cy.GLO_addInput`, `cy.GLO_checkbox`, `cy.GLO_popupWindow`, and delegates nested blocks to other blueprints (`GLO_enterAddressPopup`). Specs then read as data, not as clicks:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
GLO_enterEquipment({
|
|
172
|
+
equipmentCode: `CYP-${getUUID(4)}`,
|
|
173
|
+
equipmentCategory: 'Trailer',
|
|
174
|
+
flagIsActive: check
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
131 blueprints cover Globis Online programs (articles, contracts, transport orders, invoices, consignments, warehouse, customs, …) and 1 covers GlobTake.
|
|
179
|
+
|
|
180
|
+
### WebSocket detector
|
|
181
|
+
|
|
182
|
+
Servoy's frontend talks to its backend over a single persistent WebSocket, which `cy.intercept()` cannot observe — historically that meant `cy.wait(N)`. [websocketDetector.ts](src/websocketDetector.ts) replaces those with a semantics-aware idle check:
|
|
183
|
+
|
|
184
|
+
- `WS_visitWithSpy(url)` — visits a URL with `window.WebSocket` patched so every frame is mirrored into `win.wsMessages`.
|
|
185
|
+
- `WS_loadingCheck(options?)` — resolves only once pending requests, the Sablo loading indicator, pending `svyPush` data syncs, and the DOM loading indicator are all idle for a quiet period. Handles dialogs, popup forms, `closeNode`/`cellClick` bursts, window destroy and navigation.
|
|
186
|
+
- `WS_toggleDialogHandler('enable' | 'disable')` — controls whether plain `Info` dialogs are auto-dismissed or left to the test.
|
|
187
|
+
|
|
188
|
+
It is opt-in per run: `cypressWebsocketLoader` / `cypressWebsocketDebug` are read from the `extraParams` env object (see below).
|
|
189
|
+
|
|
190
|
+
### Metrics
|
|
191
|
+
|
|
192
|
+
`WS_loadingCheck` can emit per-action timing metrics. They are buffered in-memory through the `bufferWsMetrics` task and pushed by `flushWsMetrics`, which SigV4-signs a Snappy-compressed Prometheus remote-write payload with container IMDS credentials ([src/plugins/prometheusWriter.ts](src/plugins/prometheusWriter.ts)). The flush is a **no-op unless `AMP_REMOTE_WRITE_URL` is set**, so consumer repos without an AMP endpoint simply never push.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Environment variables
|
|
197
|
+
|
|
198
|
+
Set via Cypress env (`config.env`, `CYPRESS_*`, or `--env`) unless noted.
|
|
199
|
+
|
|
200
|
+
| Key | Purpose |
|
|
201
|
+
| --- | --- |
|
|
202
|
+
| `globisUrl` | Base solution URL. `GLJ/GLS/GLT_login` rewrite the `/solution/<name>` segment off this. |
|
|
203
|
+
| `portalUrl`, `formBuilderUrl`, `oktaUrl` | Entry URLs for the portal, form builder and Okta login flows. |
|
|
204
|
+
| `username`, `username2` | Default and alternate login users. |
|
|
205
|
+
| `password`, `password2`, `api_key` | Secrets — kept node-side, never exposed to the browser. |
|
|
206
|
+
| `loginType`, `ownerName`, `formBuilderStandalone`, `saveData` | Login/flow switches read by the commands. |
|
|
207
|
+
| `BUILD_NUMBER` | Used by `getOrCreateUuid()` to build a stable `CYP<build>` test-data prefix. |
|
|
208
|
+
| `extraParams` | Object of Jenkins-passed extras; `cypressWebsocketLoader` and `cypressWebsocketDebug` (`'true'`) live here. |
|
|
209
|
+
| `AMP_REMOTE_WRITE_URL`, `AMP_REGION` | Node `process.env` — Prometheus remote-write target and region. |
|
|
210
|
+
| `numTestsKeptInMemory` | Node `process.env` — overrides Cypress's default of `0`. |
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Development
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
npm run build # tsc -p tsconfig.build.json → dist/
|
|
218
|
+
npm run build:watch # incremental build for local linking
|
|
219
|
+
npm run typescript # tsc --noEmit --skipLibCheck
|
|
220
|
+
npm run lint # biome check .
|
|
221
|
+
npm run lint:fix # biome check . --write
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Formatting is Biome ([biome.json](biome.json)): 4-space indent, single quotes, semicolons, no trailing commas, 180-column lines, LF endings. `src/types.ts` has `noUnusedVariables` disabled since it is declaration-only.
|
|
225
|
+
|
|
226
|
+
### Shipped lint scripts
|
|
227
|
+
|
|
228
|
+
`scripts/` is published with the package so consumer repos can run the same rule over their specs. It's a standalone Node script (no ESLint) that reads the invoking repo's `tsconfig.json` from `process.cwd()`, using the TypeScript 7 `typescript/unstable/*` preview API — the classic in-process Compiler API that `typescript-eslint` and `ts-morph` depend on was removed in TS7, which is why those tools cap their peer range below it.
|
|
229
|
+
|
|
230
|
+
| Script | What it does |
|
|
231
|
+
| --- | --- |
|
|
232
|
+
| [check-unnecessary-waiting.mjs](scripts/check-unnecessary-waiting.mjs) | Fails on `cy.wait(<number>)`, including numeric constants/default params aliased in the enclosing scope. Exempt a call with a `// biome-ignore plugin: <reason>` comment on the line directly above — Biome's GritQL plugins have no suppression mechanism, hence the standalone script. |
|
|
233
|
+
|
|
234
|
+
Wire it into the consumer repo:
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"scripts": {
|
|
239
|
+
"lint:waiting": "node node_modules/@globisnv/cypress-core/scripts/check-unnecessary-waiting.mjs"
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
`check-deprecated-get-commands.mjs` (the old-positional-API-to-tuple-form codemod) is **not** shipped here — it lives in `globis-cypress`'s own `scripts/`. It only matters for that repo's older version branches (`11.0.1`, `11.0.0`, `10.5.19`), which never adopted the tuple-based API and never will; no customer repo has ever had the old API, so there's nothing for it to do there.
|
|
245
|
+
|
|
246
|
+
### Conventions
|
|
247
|
+
|
|
248
|
+
- **ESM only** (`"type": "module"`) — internal imports carry the `.js` extension.
|
|
249
|
+
- Commands are declared on `Cypress.Chainable` inside a `declare global` block in the file that implements them, with JSDoc on every parameter.
|
|
250
|
+
- Boolean arguments use the branded flag constants from `tsHelper.ts` (`open`/`close`, `check`/`unCheck`, `skipCheck`/`noSkipCheck`, …) so a call site reads as intent rather than `true`/`false`.
|
|
251
|
+
- New generic commands, blueprints and helpers belong here; anything customer-specific stays in the consumer repo.
|
|
252
|
+
|
|
253
|
+
### Review ownership
|
|
254
|
+
|
|
255
|
+
[CODEOWNERS](CODEOWNERS) protects the shared surface — `package.json`, `tsconfig*.json`, `biome.json`, `src/config.ts`, `src/register.ts`, `src/commands/`, `src/plugins/` and `.github/`. Changes there need a review from the listed owners.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Scaffolds a blank customer test repo: copies template/ into a target
|
|
3
|
+
// directory, fills in the company abbreviation, then runs git init and
|
|
4
|
+
// npm install. No dependencies beyond Node's own stdlib.
|
|
5
|
+
|
|
6
|
+
import { execSync } from 'node:child_process';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { createInterface } from 'node:readline/promises';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
|
|
12
|
+
const packageRoot = path.resolve(fileURLToPath(import.meta.url), '..', '..');
|
|
13
|
+
const templateDir = path.join(packageRoot, 'template');
|
|
14
|
+
const corePackageJson = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf-8'));
|
|
15
|
+
|
|
16
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
17
|
+
const ask = async (question) => (await rl.question(question)).trim();
|
|
18
|
+
|
|
19
|
+
let targetDir = await ask('Target folder (e.g. acme-cypress): ');
|
|
20
|
+
while (!targetDir) {
|
|
21
|
+
targetDir = await ask('Target folder cannot be empty: ');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let abbrev = await ask('Company abbreviation, 3 letters (e.g. ACM): ');
|
|
25
|
+
while (!/^[A-Za-z]{3}$/.test(abbrev)) {
|
|
26
|
+
abbrev = await ask('Must be exactly 3 letters (e.g. ACM): ');
|
|
27
|
+
}
|
|
28
|
+
rl.close();
|
|
29
|
+
|
|
30
|
+
const abbrevUpper = abbrev.toUpperCase();
|
|
31
|
+
const abbrevLower = abbrev.toLowerCase();
|
|
32
|
+
const targetPath = path.resolve(process.cwd(), targetDir);
|
|
33
|
+
const packageName = `${abbrevLower}-cypress`;
|
|
34
|
+
|
|
35
|
+
if (fs.existsSync(targetPath) && fs.readdirSync(targetPath).length > 0) {
|
|
36
|
+
console.error(`Error: ${targetPath} already exists and is not empty.`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Resolves child inside root and rejects anything that would escape it
|
|
41
|
+
// (defense in depth — entry names come from our own bundled template/
|
|
42
|
+
// today, but the read/write roots must never be escapable regardless).
|
|
43
|
+
function resolveWithin(root, name) {
|
|
44
|
+
const resolvedRoot = path.resolve(root);
|
|
45
|
+
const resolved = path.resolve(resolvedRoot, name);
|
|
46
|
+
const relative = path.relative(resolvedRoot, resolved);
|
|
47
|
+
if (relative.startsWith('..') || path.isAbsolute(relative)) {
|
|
48
|
+
console.error(`Error: refusing to touch a path outside ${resolvedRoot}: ${name}`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
return resolved;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function copyTemplate(src, dest) {
|
|
55
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
56
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
57
|
+
const srcPath = resolveWithin(src, entry.name);
|
|
58
|
+
const destName = entry.name === '__CUSTOMER__' ? abbrevLower : entry.name;
|
|
59
|
+
const destPath = resolveWithin(dest, destName);
|
|
60
|
+
if (entry.isDirectory()) {
|
|
61
|
+
copyTemplate(srcPath, destPath);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
let content = fs.readFileSync(srcPath, 'utf-8');
|
|
65
|
+
if (entry.name === 'package.json') {
|
|
66
|
+
content = content.replace('__PACKAGE_NAME__', packageName).replace('__CORE_VERSION__', corePackageJson.version);
|
|
67
|
+
}
|
|
68
|
+
if (entry.name === 'e2e.ts') {
|
|
69
|
+
content = content.replace(/__CUSTOMER_LOWER__/g, abbrevLower).replace(/__CUSTOMER_UPPER__/g, abbrevUpper);
|
|
70
|
+
}
|
|
71
|
+
fs.writeFileSync(destPath, content);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
copyTemplate(templateDir, targetPath);
|
|
76
|
+
|
|
77
|
+
console.log(`\nFiles created at ${targetPath}\n`);
|
|
78
|
+
|
|
79
|
+
console.log('Running git init...');
|
|
80
|
+
execSync('git init', { cwd: targetPath, stdio: 'inherit' });
|
|
81
|
+
|
|
82
|
+
console.log('Running npm install...');
|
|
83
|
+
execSync('npm install', { cwd: targetPath, stdio: 'inherit' });
|
|
84
|
+
|
|
85
|
+
console.log(`\n${packageName} is ready.\n`);
|
|
86
|
+
console.log('Next steps:');
|
|
87
|
+
console.log(` cd ${targetDir}`);
|
|
88
|
+
console.log(' cp cypress.env.json.example cypress.env.json # then fill it in');
|
|
89
|
+
console.log(' npx cypress open --e2e --browser chrome');
|
package/biome.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.5.7/schema.json",
|
|
3
|
+
"files": {
|
|
4
|
+
"includes": ["**", "!dist", "!template"]
|
|
5
|
+
},
|
|
6
|
+
"formatter": {
|
|
7
|
+
"enabled": true,
|
|
8
|
+
"indentStyle": "space",
|
|
9
|
+
"indentWidth": 4,
|
|
10
|
+
"lineEnding": "lf",
|
|
11
|
+
"lineWidth": 180
|
|
12
|
+
},
|
|
13
|
+
"javascript": {
|
|
14
|
+
"formatter": {
|
|
15
|
+
"quoteStyle": "single",
|
|
16
|
+
"semicolons": "always",
|
|
17
|
+
"trailingCommas": "none"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"linter": {
|
|
21
|
+
"enabled": true,
|
|
22
|
+
"rules": {
|
|
23
|
+
"preset": "recommended",
|
|
24
|
+
"complexity": {
|
|
25
|
+
"noUselessTernary": "error"
|
|
26
|
+
},
|
|
27
|
+
"style": {
|
|
28
|
+
"useTemplate": "error",
|
|
29
|
+
"noNonNullAssertion": "off",
|
|
30
|
+
"useNamingConvention": "off"
|
|
31
|
+
},
|
|
32
|
+
"suspicious": {
|
|
33
|
+
"noDoubleEquals": "error"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"overrides": [
|
|
38
|
+
{
|
|
39
|
+
"includes": ["src/types.ts"],
|
|
40
|
+
"linter": {
|
|
41
|
+
"rules": {
|
|
42
|
+
"correctness": {
|
|
43
|
+
"noUnusedVariables": "off"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the type of the body object for HTTP requests.
|
|
3
|
+
* @template T - Type of the body.
|
|
4
|
+
*/
|
|
5
|
+
interface BodyType<T> {
|
|
6
|
+
[key: string]: T;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Represents the type for the primary key object.
|
|
10
|
+
*/
|
|
11
|
+
type primaryKeyType = {
|
|
12
|
+
pkName: string;
|
|
13
|
+
value: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Creates request variables object for HTTP request.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
19
|
+
* @param {apiMethodType} method - The HTTP method for the request.
|
|
20
|
+
* @param {object} [body] - The body of the request.
|
|
21
|
+
* @param {number} [timeout] - A custom timeout to override the default
|
|
22
|
+
* @param {string} [api_key_overide] - An api key to use instead of the `api_key` environment variable.
|
|
23
|
+
* @returns {object} The request variables object.
|
|
24
|
+
*/
|
|
25
|
+
export declare const createRequestVariables: (apiUrl: string, method: apiMethodType, body?: object, timeout?: number, api_key_overide?: string) => Cypress.Chainable<{
|
|
26
|
+
url: string;
|
|
27
|
+
method: string;
|
|
28
|
+
headers: {
|
|
29
|
+
[key: string]: string;
|
|
30
|
+
};
|
|
31
|
+
body?: object;
|
|
32
|
+
timeout?: number;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Sends a HTTP request and verifies the response status.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
38
|
+
* @param {apiMethodType} method - The HTTP method for the request.
|
|
39
|
+
* @param {object} [body] - The body of the request.
|
|
40
|
+
* @param {number} [status=200] - The expected status code of the response.
|
|
41
|
+
* @param {number} [timeout] - A custom timeout, overriding the default.
|
|
42
|
+
* @param
|
|
43
|
+
* @returns {void}
|
|
44
|
+
*/
|
|
45
|
+
export declare const requestWithResponse: (apiUrl: string, method: apiMethodType, body?: object, status?: number, timeout?: number) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Represents the primary key object.
|
|
48
|
+
* @type {primaryKeyType}
|
|
49
|
+
*/
|
|
50
|
+
export declare const primaryKeyObject: primaryKeyType;
|
|
51
|
+
/**
|
|
52
|
+
* Sends a PATCH request with response verification.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
55
|
+
* @param {apiMethodType} method - The HTTP method for the request.
|
|
56
|
+
* @param {BodyType<string | number | object>} body - The body of the request.
|
|
57
|
+
* @param {number} [status=200] - The expected status code of the response.
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
export declare const requestWithResponsePatch: (apiUrl: string, method: apiMethodType, body: BodyType<string | number | object>, status?: number) => void;
|
|
61
|
+
/**
|
|
62
|
+
* Sends a HTTP request, verifies the response status, and returns the ID field.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
65
|
+
* @param {apiMethodType} method - The HTTP method for the request.
|
|
66
|
+
* @param {object} body - The body of the request.
|
|
67
|
+
* @param {string} idField - The ID field to be returned from the response.
|
|
68
|
+
* @returns {Promise<string>} The ID field from the response.
|
|
69
|
+
*/
|
|
70
|
+
export declare const requestWithResponseAndReturnId: (apiUrl: string, method: apiMethodType, body: object, idField: string) => Promise<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Sends a GET request, verifies the response status, and returns the specified field.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
75
|
+
* @param {string} nrField - The field to be returned from the response.
|
|
76
|
+
* @returns {Promise<string>} The specified field from the response.
|
|
77
|
+
*/
|
|
78
|
+
export declare const getRequestAndReturnNr: (apiUrl: string, nrField: string) => Promise<string>;
|
|
79
|
+
/**
|
|
80
|
+
* Sends a GET request, verifies the response status, and returns the response body.
|
|
81
|
+
*
|
|
82
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
83
|
+
* @returns {Promise<object>} The response body.
|
|
84
|
+
*/
|
|
85
|
+
export declare const getRequestAndReturnBody: (apiUrl: string) => Promise<object>;
|
|
86
|
+
/**
|
|
87
|
+
* Sends an HTTP request with custom headers and returns the response body.
|
|
88
|
+
* This is a universal function that supports any HTTP method (GET, POST, PUT, PATCH, DELETE, etc.)
|
|
89
|
+
*
|
|
90
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
91
|
+
* @param {apiMethodType} method - The HTTP method for the request (GET, POST, PUT, PATCH, DELETE, etc.).
|
|
92
|
+
* @param {object} [body] - The body of the request (optional, not used for GET requests).
|
|
93
|
+
* @param {number} [status=200] - The expected status code of the response.
|
|
94
|
+
* @param {string} [api_key_overide] - An api key to use instead of the `api_key` environment variable.
|
|
95
|
+
* @returns {Promise<object>} The response body.
|
|
96
|
+
*/
|
|
97
|
+
export declare const requestAndReturnBody: (apiUrl: string, method: apiMethodType, body?: object, status?: number, api_key_overide?: string) => Promise<object>;
|
|
98
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates request variables object for HTTP request.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
5
|
+
* @param {apiMethodType} method - The HTTP method for the request.
|
|
6
|
+
* @param {object} [body] - The body of the request.
|
|
7
|
+
* @param {number} [timeout] - A custom timeout to override the default
|
|
8
|
+
* @param {string} [api_key_overide] - An api key to use instead of the `api_key` environment variable.
|
|
9
|
+
* @returns {object} The request variables object.
|
|
10
|
+
*/
|
|
11
|
+
export const createRequestVariables = (apiUrl, method, body, timeout, api_key_overide) => {
|
|
12
|
+
return cy.env(['api_key']).then(({ api_key }) => {
|
|
13
|
+
const url = new URL(apiUrl);
|
|
14
|
+
const executionToken = url.searchParams.get('X-Execution-Token');
|
|
15
|
+
if (executionToken) {
|
|
16
|
+
url.searchParams.delete('X-Execution-Token');
|
|
17
|
+
}
|
|
18
|
+
const headers = {
|
|
19
|
+
authorization: (api_key_overide ?? api_key),
|
|
20
|
+
'Content-Type': 'application/json',
|
|
21
|
+
...(executionToken && { 'X-Execution-Token': executionToken })
|
|
22
|
+
};
|
|
23
|
+
const requestOptions = {
|
|
24
|
+
url: url.toString(),
|
|
25
|
+
method: method,
|
|
26
|
+
headers: headers,
|
|
27
|
+
body: body
|
|
28
|
+
};
|
|
29
|
+
if (timeout !== undefined) {
|
|
30
|
+
requestOptions.timeout = timeout;
|
|
31
|
+
}
|
|
32
|
+
return requestOptions;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Sends a HTTP request and verifies the response status.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
39
|
+
* @param {apiMethodType} method - The HTTP method for the request.
|
|
40
|
+
* @param {object} [body] - The body of the request.
|
|
41
|
+
* @param {number} [status=200] - The expected status code of the response.
|
|
42
|
+
* @param {number} [timeout] - A custom timeout, overriding the default.
|
|
43
|
+
* @param
|
|
44
|
+
* @returns {void}
|
|
45
|
+
*/
|
|
46
|
+
export const requestWithResponse = (apiUrl, method, body, status = 200, timeout) => {
|
|
47
|
+
createRequestVariables(apiUrl, method, body, timeout).then((opts) => {
|
|
48
|
+
cy.request(opts).then((response) => {
|
|
49
|
+
expect(response.status).to.eq(status);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Represents the primary key object.
|
|
55
|
+
* @type {primaryKeyType}
|
|
56
|
+
*/
|
|
57
|
+
export const primaryKeyObject = {
|
|
58
|
+
pkName: 'somePK',
|
|
59
|
+
value: 'SomeValue'
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Sends a PATCH request with response verification.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
65
|
+
* @param {apiMethodType} method - The HTTP method for the request.
|
|
66
|
+
* @param {BodyType<string | number | object>} body - The body of the request.
|
|
67
|
+
* @param {number} [status=200] - The expected status code of the response.
|
|
68
|
+
* @returns {void}
|
|
69
|
+
*/
|
|
70
|
+
export const requestWithResponsePatch = (apiUrl, method, body, status = 200) => {
|
|
71
|
+
// Add primary key to the body
|
|
72
|
+
body[primaryKeyObject.pkName] = primaryKeyObject.value;
|
|
73
|
+
cy.GLO_log(`method: ${method} -- body: ${JSON.stringify(body)}`);
|
|
74
|
+
// Send the request with response verification
|
|
75
|
+
requestWithResponse(apiUrl, method, body, status);
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Sends a HTTP request, verifies the response status, and returns the ID field.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
81
|
+
* @param {apiMethodType} method - The HTTP method for the request.
|
|
82
|
+
* @param {object} body - The body of the request.
|
|
83
|
+
* @param {string} idField - The ID field to be returned from the response.
|
|
84
|
+
* @returns {Promise<string>} The ID field from the response.
|
|
85
|
+
*/
|
|
86
|
+
export const requestWithResponseAndReturnId = (apiUrl, method, body, idField) => {
|
|
87
|
+
cy.GLO_log(`method: ${method} -- body: ${JSON.stringify(body)}`);
|
|
88
|
+
return new Cypress.Promise((resolve) => {
|
|
89
|
+
createRequestVariables(apiUrl, method, body).then((opts) => {
|
|
90
|
+
cy.request(opts).then((response) => {
|
|
91
|
+
expect(response.status).to.eq(200);
|
|
92
|
+
const responsePost = response.body;
|
|
93
|
+
const responsePostBodyCreate = responsePost.create;
|
|
94
|
+
resolve(responsePostBodyCreate[0][idField]);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Sends a GET request, verifies the response status, and returns the specified field.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
103
|
+
* @param {string} nrField - The field to be returned from the response.
|
|
104
|
+
* @returns {Promise<string>} The specified field from the response.
|
|
105
|
+
*/
|
|
106
|
+
export const getRequestAndReturnNr = (apiUrl, nrField) => {
|
|
107
|
+
cy.GLO_log(`method: GET -- requested field: ${nrField}`);
|
|
108
|
+
return new Cypress.Promise((resolve) => {
|
|
109
|
+
createRequestVariables(apiUrl, 'GET').then((opts) => {
|
|
110
|
+
cy.request(opts).then((response) => {
|
|
111
|
+
expect(response.status).to.eq(200);
|
|
112
|
+
const responseBody = response.body;
|
|
113
|
+
const responseElement = responseBody[0];
|
|
114
|
+
expect(responseElement).to.have.property(nrField);
|
|
115
|
+
resolve(responseElement[nrField]);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Sends a GET request, verifies the response status, and returns the response body.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
124
|
+
* @returns {Promise<object>} The response body.
|
|
125
|
+
*/
|
|
126
|
+
export const getRequestAndReturnBody = (apiUrl) => {
|
|
127
|
+
cy.GLO_log('method: GET');
|
|
128
|
+
return new Cypress.Promise((resolve) => {
|
|
129
|
+
createRequestVariables(apiUrl, 'GET').then((opts) => {
|
|
130
|
+
cy.request(opts).then((response) => {
|
|
131
|
+
expect(response.status).to.eq(200);
|
|
132
|
+
const responseBody = response.body;
|
|
133
|
+
const responseElement = responseBody[0];
|
|
134
|
+
resolve(responseElement);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Sends an HTTP request with custom headers and returns the response body.
|
|
141
|
+
* This is a universal function that supports any HTTP method (GET, POST, PUT, PATCH, DELETE, etc.)
|
|
142
|
+
*
|
|
143
|
+
* @param {string} apiUrl - The URL of the API endpoint.
|
|
144
|
+
* @param {apiMethodType} method - The HTTP method for the request (GET, POST, PUT, PATCH, DELETE, etc.).
|
|
145
|
+
* @param {object} [body] - The body of the request (optional, not used for GET requests).
|
|
146
|
+
* @param {number} [status=200] - The expected status code of the response.
|
|
147
|
+
* @param {string} [api_key_overide] - An api key to use instead of the `api_key` environment variable.
|
|
148
|
+
* @returns {Promise<object>} The response body.
|
|
149
|
+
*/
|
|
150
|
+
export const requestAndReturnBody = (apiUrl, method, body, status = 200, api_key_overide) => {
|
|
151
|
+
const bodyLog = body ? ` -- body: ${JSON.stringify(body)}` : '';
|
|
152
|
+
cy.GLO_log(`method: ${method}${bodyLog}`);
|
|
153
|
+
return new Cypress.Promise((resolve) => {
|
|
154
|
+
createRequestVariables(apiUrl, method, body, undefined, api_key_overide).then((opts) => {
|
|
155
|
+
cy.request(opts).then((response) => {
|
|
156
|
+
expect(response.status).to.eq(status);
|
|
157
|
+
resolve(response.body);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
};
|