@globisnv/cypress-core 1.1.4 → 1.2.0
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/dist/commands/GLO_commands.d.ts +30 -0
- package/dist/commands/GLO_commands.js +106 -1
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
|
@@ -605,6 +605,36 @@ declare global {
|
|
|
605
605
|
* @param {number} [interval] - use this TOGETHER with timeOut for slow-running updates (e.g. batch process) (default: 15s)
|
|
606
606
|
*/
|
|
607
607
|
GLO_validateGridOrFail(waitValue: string, failValue: string, rowNumber?: number, columnId?: string, timeOut?: number, interval?: number): void;
|
|
608
|
+
/**
|
|
609
|
+
* Command to wait until a field shows a value, and to fail instantly when it shows a fail value.
|
|
610
|
+
* The field counterpart of GLO_validateGridOrFail, e.g. for a status that is updated by a running process.
|
|
611
|
+
* The displayed value is checked, as in GLO_checkField (the text of a valuelist, not its stored code).
|
|
612
|
+
*
|
|
613
|
+
* @param {selectorType} selector - [formName, elementName] of the field.
|
|
614
|
+
* @param {string} waitValue - The value to wait for.
|
|
615
|
+
* @param {string | string[]} failValue - The value(s) that stop the waiting and fail instantly.
|
|
616
|
+
* @param {number} [timeOut] - how long it should wait for the field to update, default: 10m
|
|
617
|
+
* @param {number} [interval] - how often the field is checked, default: 15s
|
|
618
|
+
* @example - cy.GLO_validateFieldOrFail(['ng$billing_task_dtl', 'status'], 'Finished', ['Error', 'Finished with error'], 300000, 2000);
|
|
619
|
+
*/
|
|
620
|
+
GLO_validateFieldOrFail(selector: selectorType, waitValue: string, failValue: string | string[], timeOut?: number, interval?: number): void;
|
|
621
|
+
/**
|
|
622
|
+
* Executes a batch processing type and waits until the run it started has finished.
|
|
623
|
+
* The last run of the type is remembered before Execute, so a run that finished earlier is never taken for
|
|
624
|
+
* the new one (row 0 of the 'Batch processing' tab is still the previous run right after Execute).
|
|
625
|
+
* The command opens 'Batch processing type' itself and closes it again when the run has finished.
|
|
626
|
+
*
|
|
627
|
+
* @param {string} batchType - The value to filter the batch processing type list on.
|
|
628
|
+
* @param {string} [columnId='description'] - The column of the batch processing type list to filter on (e.g. 'description', 'transaction_type_text', 'batch_module').
|
|
629
|
+
* @param {string | null} [waitValue='Completed'] - The status the new run must end with. Use null to only wait until the run has finished, whatever its status,
|
|
630
|
+
* e.g. for a batch that processes the records of the whole environment, where one record of a parallel test can turn the run into Error.
|
|
631
|
+
* @param {string} [failValue='Error'] - The status that stops the waiting and fails instantly (not used when waitValue is null).
|
|
632
|
+
* @param {number} [timeOut] - how long it should wait for the run to finish, default: 20m
|
|
633
|
+
* @param {number} [interval] - how often the 'Batch processing' tab is checked, default: 15s
|
|
634
|
+
* @returns {Chainable<batchRunType>} - Yields the new run (submitted, completed, status, error message).
|
|
635
|
+
* @example - cy.GLO_executeBatchProcess('Batch processor accountancy SALES', 'batch_module', null);
|
|
636
|
+
*/
|
|
637
|
+
GLO_executeBatchProcess(batchType: string, columnId?: string, waitValue?: string | null, failValue?: string, timeOut?: number, interval?: number): Chainable<batchRunType>;
|
|
608
638
|
/**
|
|
609
639
|
* Store the value(s) of one or more fields into the nested '@saveData' alias:
|
|
610
640
|
* saveData[formName][elementName] = value
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bottom, buttonSearch, check, contains, cypressWebsocketLoader, defaultTimeout, enabled, equal, greaterEqual, gridDropDown, gridInput, gridInputWithoutEnter, gridSelect, hideInCommandLog, input, isInvalid, noEqualBool, noSkipCheck, notEqual, parseLocalizedNumber, row, select, skipCheck, span, top, unCheck } from '../tsHelper.js';
|
|
1
|
+
import { bottom, buttonSearch, check, contains, cypressWebsocketLoader, defaultTimeout, enabled, equal, greaterEqual, gridDropDown, gridInput, gridInputWithoutEnter, gridSelect, hideInCommandLog, input, isInvalid, noEqualBool, noSkipCheck, notEqual, open, parseLocalizedNumber, row, select, skipCheck, span, top, unCheck } from '../tsHelper.js';
|
|
2
2
|
import { attachWebSocketSpy } from '../websocketDetector.js';
|
|
3
3
|
//! File-specific helpers
|
|
4
4
|
const monthNames = ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'];
|
|
@@ -2008,6 +2008,111 @@ Cypress.Commands.add('GLO_getAllRowsInGrid', (selector, timeOut = defaultTimeout
|
|
|
2008
2008
|
Cypress.Commands.add('GLO_validateGridOrFail', (waitValue, failValue, rowNumber, columnId, timeOut = 600000, interval = 15000) => {
|
|
2009
2009
|
validateGridValue(waitValue, failValue, rowNumber, columnId, timeOut, interval);
|
|
2010
2010
|
});
|
|
2011
|
+
Cypress.Commands.add('GLO_validateFieldOrFail', (selector, waitValue, failValue, timeOut = 600000, interval = 15000) => {
|
|
2012
|
+
const failValues = Array.isArray(failValue) ? failValue : [failValue];
|
|
2013
|
+
const maxAttempts = Math.max(1, Math.ceil(timeOut / interval));
|
|
2014
|
+
const fieldName = selector.join('.');
|
|
2015
|
+
const checkField = (attempt = 1) => {
|
|
2016
|
+
// Same value as GLO_checkField reads: the displayed text, with html and other unicode spaces normalized
|
|
2017
|
+
cy.GLO_getElement(selector).then(($field) => {
|
|
2018
|
+
const fieldValue = String($field.find('.dx-texteditor-input').val()).replace(/\s+/g, ' ').trim();
|
|
2019
|
+
if (fieldValue === waitValue) {
|
|
2020
|
+
cy.log(`${fieldName} is "${waitValue}"`);
|
|
2021
|
+
return;
|
|
2022
|
+
}
|
|
2023
|
+
if (failValues.includes(fieldValue)) {
|
|
2024
|
+
throw new Error(`${fieldName} is "${fieldValue}" (waited for "${waitValue}")`);
|
|
2025
|
+
}
|
|
2026
|
+
if (attempt >= maxAttempts) {
|
|
2027
|
+
throw new Error(`${fieldName} is still "${fieldValue}" after ${timeOut / 1000}s (waited for "${waitValue}")`);
|
|
2028
|
+
}
|
|
2029
|
+
// biome-ignore lint/plugin/noUnnecessaryWaiting: wait for next poll interval before checking again
|
|
2030
|
+
cy.wait(interval, { log: false }).then(() => {
|
|
2031
|
+
checkField(attempt + 1);
|
|
2032
|
+
});
|
|
2033
|
+
});
|
|
2034
|
+
};
|
|
2035
|
+
checkField();
|
|
2036
|
+
});
|
|
2037
|
+
Cypress.Commands.add('GLO_executeBatchProcess', (batchType, columnId = 'description', waitValue = 'Completed', failValue = 'Error', timeOut = 1200000, interval = 15000) => {
|
|
2038
|
+
const formNameTypeList = 'ng$batch_execution_type_lst';
|
|
2039
|
+
const formNameTypeTab = 'ng$batch_execution_type_tab';
|
|
2040
|
+
const formNameRunList = 'ng$batch_execution_lst';
|
|
2041
|
+
const maxAttempts = Math.max(1, Math.ceil(timeOut / interval));
|
|
2042
|
+
// Row 0 of the run list is the most recent run (sorted on process_submitted desc); an empty list has no run yet.
|
|
2043
|
+
// Without these columns (hidden in a custom view) a new run can never be recognised, so that fails at once.
|
|
2044
|
+
const requiredColumns = ['process_submitted', 'process_completed', 'process_status'];
|
|
2045
|
+
const readLastRun = () => {
|
|
2046
|
+
const noRun = { submitted: '', completed: '', status: '', errorMessage: '' };
|
|
2047
|
+
return cy.GLO_getElement([formNameRunList, 'grid']).then(($grid) => {
|
|
2048
|
+
if ($grid.find('.ag-center-cols-container [row-index]').length === 0) {
|
|
2049
|
+
return cy.wrap(noRun, { log: false });
|
|
2050
|
+
}
|
|
2051
|
+
return cy
|
|
2052
|
+
.wrap($grid, { log: false })
|
|
2053
|
+
.within(() => {
|
|
2054
|
+
cy.GLO_getRowInGrid(0).then(($row) => {
|
|
2055
|
+
const missingColumns = requiredColumns.filter((requiredColumnId) => $row.find(`[col-id="${requiredColumnId}"]`).length === 0);
|
|
2056
|
+
if (missingColumns.length) {
|
|
2057
|
+
throw new Error(`The 'Batch processing' tab of ${batchType} does not show the column(s) ${missingColumns.join(', ')}`);
|
|
2058
|
+
}
|
|
2059
|
+
const cellText = (cellColumnId) => $row.find(`[col-id="${cellColumnId}"]`).text().trim();
|
|
2060
|
+
cy.wrap({
|
|
2061
|
+
submitted: cellText('process_submitted'),
|
|
2062
|
+
completed: cellText('process_completed'),
|
|
2063
|
+
status: cellText('process_status'),
|
|
2064
|
+
errorMessage: cellText('last_error_message')
|
|
2065
|
+
}, { log: false }).as('COM_batchRun');
|
|
2066
|
+
});
|
|
2067
|
+
})
|
|
2068
|
+
.then(() => cy.get('@COM_batchRun', { log: false }));
|
|
2069
|
+
});
|
|
2070
|
+
};
|
|
2071
|
+
// The completion time (process_completed) is stamped for every final status, Completed as well as Error
|
|
2072
|
+
const waitForNewRun = (previousSubmitted, attempt = 1) => {
|
|
2073
|
+
cy.GLO_checkAGLoader();
|
|
2074
|
+
return readLastRun().then((run) => {
|
|
2075
|
+
const isNewRun = run.submitted !== '' && run.submitted !== previousSubmitted;
|
|
2076
|
+
const hasFailed = waitValue !== null && run.status === failValue;
|
|
2077
|
+
if (isNewRun && (run.completed !== '' || hasFailed)) {
|
|
2078
|
+
cy.GLO_log(`Batch run of ${run.submitted} (${batchType}) finished with status "${run.status}" ${run.errorMessage}`);
|
|
2079
|
+
if (hasFailed) {
|
|
2080
|
+
throw new Error(`Batch run of ${run.submitted} (${batchType}) ended with status "${run.status}": ${run.errorMessage}`);
|
|
2081
|
+
}
|
|
2082
|
+
if (waitValue !== null) {
|
|
2083
|
+
expect(run.status, `status of the batch run of ${run.submitted} (${batchType})`).to.equal(waitValue);
|
|
2084
|
+
}
|
|
2085
|
+
return cy.wrap(run, { log: false });
|
|
2086
|
+
}
|
|
2087
|
+
if (attempt >= maxAttempts) {
|
|
2088
|
+
throw new Error(`No finished run of ${batchType} after ${timeOut / 1000}s (last run submitted: ${run.submitted})`);
|
|
2089
|
+
}
|
|
2090
|
+
// biome-ignore lint/plugin/noUnnecessaryWaiting: wait for next poll interval before checking again
|
|
2091
|
+
return cy.wait(interval, { log: false }).then(() => waitForNewRun(previousSubmitted, attempt + 1));
|
|
2092
|
+
});
|
|
2093
|
+
};
|
|
2094
|
+
cy.GLO_searchHeader('Batch processes', 'Batch processes', 'Batch processing type');
|
|
2095
|
+
cy.GLO_clickDatacontrolBrowserButton('btnAll');
|
|
2096
|
+
// A filter typed while the list is still loading is lost
|
|
2097
|
+
cy.GLO_checkAGLoader();
|
|
2098
|
+
// Equals, not contains: 'CALCULATE INVOICE' must not select 'CALCULATE INVOICE RETOUR'
|
|
2099
|
+
cy.GLO_filterGrid(columnId, [formNameTypeList, 'grid'], batchType, undefined, 'Equals');
|
|
2100
|
+
cy.GLO_getElement([formNameTypeList, 'grid']).within(() => {
|
|
2101
|
+
cy.GLO_checkValueGrid(batchType, 0, columnId, undefined, undefined, equal);
|
|
2102
|
+
});
|
|
2103
|
+
cy.GLO_selectTab([formNameTypeTab, 'tabs'], 'Batch processing', open);
|
|
2104
|
+
cy.GLO_checkAGLoader();
|
|
2105
|
+
return readLastRun().then((previousRun) => {
|
|
2106
|
+
cy.GLO_selectMenuButton('Execute');
|
|
2107
|
+
cy.GLO_log(`Executed batch processing type ${batchType}`);
|
|
2108
|
+
return waitForNewRun(previousRun.submitted).then((run) => {
|
|
2109
|
+
// Every call opens the program, so it is closed again: a second instance would keep a hidden run list in
|
|
2110
|
+
// the page, and the caller gets back the programs it had open
|
|
2111
|
+
cy.GLO_closeProgram(top, 'Batch processing type');
|
|
2112
|
+
return cy.wrap(run, { log: false });
|
|
2113
|
+
});
|
|
2114
|
+
});
|
|
2115
|
+
});
|
|
2011
2116
|
const validateGridValue = (value, failValue, rowFilter, columnId, timeOut = 10000, interval, operator = contains) => {
|
|
2012
2117
|
const assertOrCheckCellValue = ($cells, toCheck, doAssert) => {
|
|
2013
2118
|
const compare = (cellText) => {
|
package/dist/types.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ type deleteRecordsType = 'DELETE_CYPRESS_RECORDS' | 'DELETE_LEAPWORK_RECORDS';
|
|
|
12
12
|
type viewModeButtonType = 'btnList' | 'btnDetail';
|
|
13
13
|
type datacontrolbuttonType = baseDatacontrolViewerButtonType | viewModeButtonType | 'btnPrev' | 'btnNext' | 'btnAll' | 'btnPivot' | 'btnAttachment' | 'btnAddMode' | 'btnEditMode' | 'btnDeleteMode' | 'btnDeeplink' | 'btnExtendedSearch' | 'btnCustomViews' | 'btnFilter' | 'btnClearAllFilters';
|
|
14
14
|
type checkValueInGridType = string | string[] | number;
|
|
15
|
+
type batchRunType = {
|
|
16
|
+
submitted: string;
|
|
17
|
+
completed: string;
|
|
18
|
+
status: string;
|
|
19
|
+
errorMessage: string;
|
|
20
|
+
};
|
|
15
21
|
type selectMenuButtonLeftType = 'home' | 'settings' | 'help' | 'support' | 'excel' | 'info' | 'refresh' | 'query' | 'clients' | 'users' | 'theme';
|
|
16
22
|
type urlTypeType = 'online' | 'pos' | 'globgate' | 'globjob' | 'globscan' | 'portal' | 'carrier' | 'globtrace' | 'external_portal' | 'globtake' | 'globis_external_portal';
|
|
17
23
|
type customValueType = JQuery | string | number;
|