import { Then, When } from '@cucumber/cucumber'; import { ContourAlert } from '../../elements/contourAlert'; import TemplateList from '../../pages/template/templateList.page'; import { getTimestampInPlainString } from '../../util/dateUtil'; import scenarioContext from '../../util/scenarioContext'; import * as glue from './glue'; Then(/^I save template "([^"]+)?" (with|without) priority$/, async function (name, priority) { const template = `AutoTest-${getTimestampInPlainString()}`; scenarioContext().dataStore.set(name, template); const templateList = new TemplateList(template); const prioritize = priority === 'with' ? true : false; await templateList.saveTemplate(template, prioritize); }); When('I open recent DC from Recents section', async () => { const templateList = new TemplateList(); await templateList.openRecentDC(); }); Then(/^I star the templates "([^"]+)?"$/, async (templates: string) => { templates.split(',').forEach(async (template) => { const templateListingPage = new TemplateList(template); await templateListingPage.starTemplate(); }); }); Then('I search for template {string}', async (templateName: string) => { const tempName = scenarioContext().dataStore.get(templateName) || templateName; const templateListingPage = new TemplateList(tempName); await templateListingPage.searchTemplate(); }); Then( /^I (search and open|open) (managed template|template) "([^"]+)?"$/, async (option: string, templateType: string, tempName: string) => { const templateList = new TemplateList(scenarioContext().dataStore.get(tempName)); const managedTempl: boolean = String(templateType).includes('managed'); const search: boolean = String(templateType).includes('search'); search && (await templateList.searchTemplate()); managedTempl ? await templateList.openManagedTemplate() : await templateList.openTemplate(); } ); Then(/^template "([^"]+)?" is (listed|not listed) in page$/, async (templateName: string, assertCase: string) => { const tempName = scenarioContext().dataStore.get(templateName); const falseCase: boolean = String(assertCase).includes('not'); const templateListingPage = new TemplateList(tempName); await templateListingPage.isTemplateDisplayed(falseCase); }); Then( /^template "([^"]+)?" (is|are) (starred|not starred)$/, async (template: string, _option: string, assertCase: string) => { const tempName = scenarioContext().dataStore.get(template); const falseCase: boolean = String(assertCase).includes('not'); const templateListingPage = new TemplateList(tempName); await templateListingPage.isTemplateStarred(falseCase); } ); Then('template {string} is listed in order {int}', async (template: string, order: any) => { const tempName = scenarioContext().dataStore.get(template); const templateListingPage = new TemplateList(tempName); await templateListingPage.checkTemplateOrder(template, order); }); Then(/^template is prioritized by recent creation date$/, glue.getMostRecentTemplateCreationDate); Then(/^DC template is pre-filled with the following data$/, async (dataTable) => { await glue.checkPreFilledTemplateData(dataTable); }); Then('I delete the template {string}', async (templateName: string) => { const templateList = new TemplateList(scenarioContext().dataStore.get(templateName)); await templateList.deleteTemplate(); await new ContourAlert().clickButtonByLabelTxt('Yes, delete'); await browser.pause(2000); });