2022-12-15 07:39:59 -08:00
|
|
|
import { BasePage } from './base';
|
2022-11-22 01:37:26 -08:00
|
|
|
|
|
|
|
export class CredentialsPage extends BasePage {
|
2024-05-17 01:53:15 -07:00
|
|
|
url = '/home/credentials';
|
2024-06-10 06:49:50 -07:00
|
|
|
|
2022-11-22 01:37:26 -08:00
|
|
|
getters = {
|
|
|
|
emptyListCreateCredentialButton: () => cy.getByTestId('empty-resources-list').find('button'),
|
2024-11-19 06:47:10 -08:00
|
|
|
createCredentialButton: () => {
|
2024-12-11 06:23:55 -08:00
|
|
|
cy.getByTestId('add-resource').should('be.visible').click();
|
|
|
|
cy.getByTestId('add-resource').getByTestId('action-credential').should('be.visible');
|
|
|
|
return cy.getByTestId('add-resource').getByTestId('action-credential');
|
2024-11-19 06:47:10 -08:00
|
|
|
},
|
2023-07-28 00:51:07 -07:00
|
|
|
searchInput: () => cy.getByTestId('resources-list-search'),
|
2022-11-28 02:11:39 -08:00
|
|
|
emptyList: () => cy.getByTestId('resources-list-empty'),
|
|
|
|
credentialCards: () => cy.getByTestId('resources-list-item'),
|
2022-12-15 07:39:59 -08:00
|
|
|
credentialCard: (credentialName: string) =>
|
|
|
|
this.getters
|
|
|
|
.credentialCards()
|
|
|
|
.contains(credentialName)
|
|
|
|
.parents('[data-test-id="resources-list-item"]'),
|
|
|
|
credentialCardActions: (credentialName: string) =>
|
|
|
|
this.getters.credentialCard(credentialName).findChildByTestId('credential-card-actions'),
|
|
|
|
credentialDeleteButton: () =>
|
|
|
|
cy.getByTestId('action-toggle-dropdown').filter(':visible').contains('Delete'),
|
2024-06-11 05:21:16 -07:00
|
|
|
credentialMoveButton: () =>
|
|
|
|
cy.getByTestId('action-toggle-dropdown').filter(':visible').contains('Move'),
|
2023-07-28 00:51:07 -07:00
|
|
|
sort: () => cy.getByTestId('resources-list-sort').first(),
|
2023-08-16 08:13:57 -07:00
|
|
|
sortOption: (label: string) =>
|
|
|
|
cy.getByTestId('resources-list-sort-item').contains(label).first(),
|
2022-11-28 02:11:39 -08:00
|
|
|
filtersTrigger: () => cy.getByTestId('resources-list-filters-trigger'),
|
|
|
|
filtersDropdown: () => cy.getByTestId('resources-list-filters-dropdown'),
|
|
|
|
};
|
2024-06-10 06:49:50 -07:00
|
|
|
|
2022-11-28 02:11:39 -08:00
|
|
|
actions = {
|
|
|
|
search: (searchString: string) => {
|
|
|
|
const searchInput = this.getters.searchInput();
|
|
|
|
searchInput.clear();
|
|
|
|
|
|
|
|
if (searchString) {
|
|
|
|
searchInput.type(searchString);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
sortBy: (type: 'nameAsc' | 'nameDesc' | 'lastUpdated' | 'lastCreated') => {
|
|
|
|
const sortTypes = {
|
|
|
|
nameAsc: 'Sort by name (A-Z)',
|
|
|
|
nameDesc: 'Sort by name (Z-A)',
|
|
|
|
lastUpdated: 'Sort by last updated',
|
|
|
|
lastCreated: 'Sort by last created',
|
|
|
|
};
|
|
|
|
|
|
|
|
this.getters.sort().click();
|
|
|
|
this.getters.sortOption(sortTypes[type]).click();
|
|
|
|
},
|
2022-11-22 01:37:26 -08:00
|
|
|
};
|
|
|
|
}
|