n8n/cypress/pages/variables.ts
Csaba Tuncsik 596c472ecc
feat: RBAC (#8922)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Co-authored-by: Val <68596159+valya@users.noreply.github.com>
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
Co-authored-by: Valya Bullions <valya@n8n.io>
Co-authored-by: Danny Martini <danny@n8n.io>
Co-authored-by: Danny Martini <despair.blue@gmail.com>
Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
Co-authored-by: Omar Ajoue <krynble@gmail.com>
Co-authored-by: oleg <me@olegivaniv.com>
Co-authored-by: Michael Kret <michael.k@radency.com>
Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com>
Co-authored-by: Elias Meire <elias@meire.dev>
Co-authored-by: Giulio Andreini <andreini@netseven.it>
Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
Co-authored-by: Ayato Hayashi <go12limchangyong@gmail.com>
2024-05-17 10:53:15 +02:00

72 lines
2.8 KiB
TypeScript

import { BasePage } from './base';
import Chainable = Cypress.Chainable;
export class VariablesPage extends BasePage {
url = '/variables';
getters = {
unavailableResourcesList: () => cy.getByTestId('unavailable-resources-list'),
emptyResourcesList: () => cy.getByTestId('empty-resources-list'),
resourcesList: () => cy.getByTestId('resources-list'),
goToUpgrade: () => cy.getByTestId('go-to-upgrade'),
actionBox: () => cy.getByTestId('action-box'),
emptyResourcesListNewVariableButton: () => this.getters.emptyResourcesList().find('button'),
searchBar: () => cy.getByTestId('resources-list-search'),
createVariableButton: () => cy.getByTestId('resources-list-add'),
variablesRows: () => cy.getByTestId('variables-row'),
variablesEditableRows: () =>
cy.getByTestId('variables-row').filter((index, row) => !!row.querySelector('input')),
variableRow: (key: string) =>
this.getters.variablesRows().contains(key).parents('[data-test-id="variables-row"]'),
editableRowCancelButton: (row: Chainable<JQuery<HTMLElement>>) =>
row.getByTestId('variable-row-cancel-button'),
editableRowSaveButton: (row: Chainable<JQuery<HTMLElement>>) =>
row.getByTestId('variable-row-save-button'),
};
actions = {
createVariable: (key: string, value: string) => {
this.getters.createVariableButton().click();
const editingRow = this.getters.variablesEditableRows().eq(0);
this.actions.setRowValue(editingRow, 'key', key);
this.actions.setRowValue(editingRow, 'value', value);
this.actions.saveRowEditing(editingRow);
},
deleteVariable: (key: string) => {
const row = this.getters.variableRow(key);
row.within(() => {
cy.getByTestId('variable-row-delete-button').should('not.be.disabled').click();
});
const modal = cy.get('[role="dialog"]');
modal.should('be.visible');
modal.get('.btn--confirm').click();
},
createVariableFromEmptyState: (key: string, value: string) => {
this.getters.emptyResourcesListNewVariableButton().click();
const editingRow = this.getters.variablesEditableRows().eq(0);
this.actions.setRowValue(editingRow, 'key', key);
this.actions.setRowValue(editingRow, 'value', value);
this.actions.saveRowEditing(editingRow);
},
editRow: (key: string) => {
const row = this.getters.variableRow(key);
row.within(() => {
cy.getByTestId('variable-row-edit-button').should('not.be.disabled').click();
});
},
setRowValue: (row: Chainable<JQuery<HTMLElement>>, field: 'key' | 'value', value: string) => {
row.within(() => {
cy.getByTestId(`variable-row-${field}-input`).type('{selectAll}{del}').type(value);
});
},
cancelRowEditing: (row: Chainable<JQuery<HTMLElement>>) => {
this.getters.editableRowCancelButton(row).click();
},
saveRowEditing: (row: Chainable<JQuery<HTMLElement>>) => {
this.getters.editableRowSaveButton(row).click();
},
};
}