test: Finish Sub-Workflow Inputs Testing (no-changelog) (#12460)

This commit is contained in:
Charlie Kolb
2025-01-09 11:36:00 +01:00
committed by GitHub
parent 88c0838dd7
commit a9077bb6f1
5 changed files with 348 additions and 252 deletions

View File

@@ -2,7 +2,7 @@
* Getters
*/
import { getVisibleSelect } from '../utils/popper';
import { getVisiblePopper, getVisibleSelect } from '../utils/popper';
export function getCredentialSelect(eq = 0) {
return cy.getByTestId('node-credentials-select').eq(eq);
@@ -36,6 +36,18 @@ export function getOutputPanel() {
return cy.getByTestId('output-panel');
}
export function getFixedCollection(collectionName: string) {
return cy.getByTestId(`fixed-collection-${collectionName}`);
}
export function getResourceLocator(paramName: string) {
return cy.getByTestId(`resource-locator-${paramName}`);
}
export function getResourceLocatorInput(paramName: string) {
return getResourceLocator(paramName).find('[data-test-id="rlc-input-container"]');
}
export function getOutputPanelDataContainer() {
return getOutputPanel().getByTestId('ndv-data-container');
}
@@ -84,6 +96,30 @@ export function getOutputPanelRelatedExecutionLink() {
return getOutputPanel().getByTestId('related-execution-link');
}
export function getNodeOutputHint() {
return cy.getByTestId('ndv-output-run-node-hint');
}
export function getWorkflowCards() {
return cy.getByTestId('resources-list-item');
}
export function getWorkflowCard(workflowName: string) {
return getWorkflowCards().contains(workflowName).parents('[data-test-id="resources-list-item"]');
}
export function getWorkflowCardContent(workflowName: string) {
return getWorkflowCard(workflowName).findChildByTestId('card-content');
}
export function getNodeRunInfoStale() {
return cy.getByTestId('node-run-info-stale');
}
export function getNodeOutputErrorMessage() {
return getOutputPanel().findChildByTestId('node-error-message');
}
/**
* Actions
*/
@@ -110,12 +146,20 @@ export function clickExecuteNode() {
getExecuteNodeButton().click();
}
export function clickResourceLocatorInput(paramName: string) {
getResourceLocatorInput(paramName).click();
}
export function setParameterInputByName(name: string, value: string) {
getParameterInputByName(name).clear().type(value);
}
export function toggleParameterCheckboxInputByName(name: string) {
getParameterInputByName(name).find('input[type="checkbox"]').realClick();
export function checkParameterCheckboxInputByName(name: string) {
getParameterInputByName(name).find('input[type="checkbox"]').check({ force: true });
}
export function uncheckParameterCheckboxInputByName(name: string) {
getParameterInputByName(name).find('input[type="checkbox"]').uncheck({ force: true });
}
export function setParameterSelectByContent(name: string, content: string) {
@@ -127,3 +171,86 @@ export function changeOutputRunSelector(runName: string) {
getOutputRunSelector().click();
getVisibleSelect().find('.el-select-dropdown__item').contains(runName).click();
}
export function addItemToFixedCollection(collectionName: string) {
getFixedCollection(collectionName).getByTestId('fixed-collection-add').click();
}
export function typeIntoFixedCollectionItem(collectionName: string, index: number, value: string) {
getFixedCollection(collectionName).within(() =>
cy.getByTestId('parameter-input').eq(index).type(value),
);
}
export function selectResourceLocatorItem(
resourceLocator: string,
index: number,
expectedText: string,
) {
clickResourceLocatorInput(resourceLocator);
getVisiblePopper().findChildByTestId('rlc-item').eq(0).should('exist');
getVisiblePopper()
.findChildByTestId('rlc-item')
.eq(index)
.find('span')
.should('contain.text', expectedText)
.click();
}
export function clickWorkflowCardContent(workflowName: string) {
getWorkflowCardContent(workflowName).click();
}
export function assertNodeOutputHintExists() {
getNodeOutputHint().should('exist');
}
export function assertNodeOutputErrorMessageExists() {
return getNodeOutputErrorMessage().should('exist');
}
// Note that this only validates the expectedContent is *included* in the output table
export function assertOutputTableContent(expectedContent: unknown[][]) {
for (const [i, row] of expectedContent.entries()) {
for (const [j, value] of row.entries()) {
// + 1 to skip header
getOutputTbodyCell(1 + i, j).should('have.text', value);
}
}
}
export function populateMapperFields(fields: ReadonlyArray<[string, string]>) {
for (const [name, value] of fields) {
getParameterInputByName(name).type(value);
// Click on a parent to dismiss the pop up which hides the field below.
getParameterInputByName(name).parent().parent().parent().click('topLeft');
}
}
/**
* Populate multiValue fixedCollections. Only supports fixedCollections for which all fields can be defined via keyboard typing
*
* @param items - 2D array of items to populate, i.e. [["myField1", "String"], ["myField2", "Number"]]
* @param collectionName - name of the fixedCollection to populate
* @param offset - amount of 'parameter-input's before start, e.g. from a controlling dropdown that makes the fields appear
* @returns
*/
export function populateFixedCollection<T extends readonly string[]>(
items: readonly T[],
collectionName: string,
offset: number = 0,
) {
if (items.length === 0) return;
const n = items[0].length;
for (const [i, params] of items.entries()) {
addItemToFixedCollection(collectionName);
for (const [j, param] of params.entries()) {
getFixedCollection(collectionName)
.getByTestId('parameter-input')
.eq(offset + i * n + j)
.type(`${param}{downArrow}{enter}`);
}
}
}

View File

@@ -0,0 +1,15 @@
/**
* Getters
*/
export function getWorkflowsPageUrl() {
return '/home/workflows';
}
/**
* Actions
*/
export function visitWorkflowsPage() {
cy.visit(getWorkflowsPageUrl());
}