2023-06-15 13:21:11 +00:00
|
|
|
import { ObjectsRegistry } from "../Objects/Registry";
|
|
|
|
|
|
2023-02-10 06:11:35 +00:00
|
|
|
// Edit mode modal
|
|
|
|
|
export class Templates {
|
2023-06-15 13:21:11 +00:00
|
|
|
private agHelper = ObjectsRegistry.AggregateHelper;
|
|
|
|
|
private homePage = ObjectsRegistry.HomePage;
|
2023-02-10 06:11:35 +00:00
|
|
|
public locators = {
|
2023-06-15 13:21:11 +00:00
|
|
|
_templatesTab: ".t--templates-tab",
|
2023-02-10 06:11:35 +00:00
|
|
|
_forkApp: ".t--fork-template",
|
2023-05-19 18:37:06 +00:00
|
|
|
_templateCard: "[data-testid='template-card']",
|
2024-02-28 09:12:35 +00:00
|
|
|
_templateViewForkButton: "[data-testid='template-fork-button']",
|
2024-01-17 13:09:52 +00:00
|
|
|
_buildingBlockCardOnCanvas: "[data-testid='t--canvas-building-block-item']",
|
|
|
|
|
_datasourceConnectPromptSubmitBtn:
|
|
|
|
|
"[data-testid='t--datasource-connect-prompt-submit-btn']",
|
2023-06-29 06:22:05 +00:00
|
|
|
_templatesSearchInput: "[data-testid='t--application-search-input']",
|
|
|
|
|
_resultsHeader: "[data-testid='t--application-templates-results-header']",
|
|
|
|
|
_templateViewGoBack: "[data-testid='t--template-view-goback']",
|
2023-08-08 09:14:46 +00:00
|
|
|
_templateDialogBox: "[data-testid=t--templates-dialog-component]",
|
2023-06-08 12:58:49 +00:00
|
|
|
_closeTemplateDialogBoxBtn: ".ads-v2-modal__content-header-close-button",
|
2023-06-15 13:21:11 +00:00
|
|
|
_requestForTemplateBtn: "span:contains('Request for a template')",
|
2023-12-22 08:11:35 +00:00
|
|
|
_tempaltesFilterItem: "[data-testid='t--templates-filter-item']",
|
2024-01-16 09:08:02 +00:00
|
|
|
_templateFilterItemSelectedIcon: `[data-testid="t--templates-filter-item-selected-icon"]`,
|
2024-02-28 09:12:35 +00:00
|
|
|
_templatesCardForkButton: "[data-testid='t--fork-template-button']",
|
2023-02-10 06:11:35 +00:00
|
|
|
};
|
|
|
|
|
|
2023-06-29 06:22:05 +00:00
|
|
|
FilterTemplatesByName(query: string) {
|
2023-10-04 08:07:03 +00:00
|
|
|
ObjectsRegistry.AggregateHelper.TypeText(
|
2023-06-29 06:22:05 +00:00
|
|
|
this.locators._templatesSearchInput,
|
|
|
|
|
query,
|
|
|
|
|
);
|
2023-10-04 08:07:03 +00:00
|
|
|
this.agHelper.Sleep();
|
2023-06-29 06:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-08 12:58:49 +00:00
|
|
|
GetTemplatesCardsList() {
|
|
|
|
|
return cy.get(this.locators._templateCard);
|
|
|
|
|
}
|
2023-06-15 13:21:11 +00:00
|
|
|
|
|
|
|
|
public SwitchToTemplatesTab() {
|
2023-06-29 06:22:05 +00:00
|
|
|
cy.url().then((url) => {
|
|
|
|
|
if (!url.endsWith("applications")) {
|
|
|
|
|
this.homePage.NavigateToHome();
|
|
|
|
|
}
|
|
|
|
|
this.agHelper.GetNClick(this.locators._templatesTab);
|
2023-08-10 07:06:03 +00:00
|
|
|
this.agHelper.AssertElementVisibility(
|
2023-06-29 06:22:05 +00:00
|
|
|
this.locators._requestForTemplateBtn,
|
2023-08-10 07:06:03 +00:00
|
|
|
true,
|
2023-06-29 06:22:05 +00:00
|
|
|
0,
|
2023-07-31 14:12:42 +00:00
|
|
|
60000,
|
2023-06-29 06:22:05 +00:00
|
|
|
); //giving more time here for templates page to fully load, since there is no intercept validation for same
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RefreshTemplatesPage(
|
|
|
|
|
withDummyData: boolean,
|
|
|
|
|
templateFixture = "Templates/AllowPageImportTemplates.json",
|
|
|
|
|
) {
|
|
|
|
|
if (withDummyData) {
|
|
|
|
|
cy.fixture(templateFixture).then((templatesData) => {
|
|
|
|
|
cy.intercept(
|
|
|
|
|
{
|
|
|
|
|
method: "GET",
|
|
|
|
|
url: "/api/v1/app-templates",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
statusCode: 200,
|
|
|
|
|
body: templatesData,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
cy.intercept("GET", "/api/v1/app-templates/filters").as("fetchFilters");
|
2023-07-20 13:15:27 +00:00
|
|
|
this.agHelper.RefreshPage("fetchFilters");
|
2023-08-10 07:06:03 +00:00
|
|
|
this.agHelper.AssertElementVisibility(this.locators._templateCard);
|
2023-06-15 13:21:11 +00:00
|
|
|
}
|
2023-12-22 08:11:35 +00:00
|
|
|
|
|
|
|
|
FilterByFirst2Categories() {
|
|
|
|
|
return this.agHelper
|
|
|
|
|
.GetElement(this.locators._tempaltesFilterItem)
|
|
|
|
|
.then((categories) => {
|
|
|
|
|
const first2Categories = categories.slice(1, 3);
|
|
|
|
|
first2Categories.map((_, category) => {
|
|
|
|
|
cy.wrap(category).click();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-02-10 06:11:35 +00:00
|
|
|
}
|