fix delete template when trash is not in page
This commit is contained in:
parent
7224b9a0d5
commit
d1998547c0
|
@ -145,7 +145,7 @@ export class TemplatesPage {
|
|||
}
|
||||
|
||||
async gotoViewSchemaPage(template: String) {
|
||||
|
||||
|
||||
try {
|
||||
const row = this.page.locator(`tr:has-text('${template}')`);
|
||||
await row.locator('i.bi.bi-eye').click();
|
||||
|
@ -162,24 +162,32 @@ export class TemplatesPage {
|
|||
console.error("Failed to add the template: ", error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
async gotoDeleteAndConfirmInModal(template: String) {
|
||||
async gotoDeleteAndConfirmInModal(template: String): Promise <boolean>{
|
||||
try {
|
||||
const row = this.page.locator(`tr:has-text('${template}')`);
|
||||
await row.locator('i.bi.bi-trash').click();
|
||||
const trashLocator = row.locator('i.bi.bi-trash');
|
||||
|
||||
//Find the modal that corresponds to the specific template (see html)
|
||||
const modal = this.page.locator(`div.modal:has-text("${template}")`)
|
||||
.first();
|
||||
// Check if the trash icon exists
|
||||
if (await trashLocator.count() > 0) {
|
||||
await trashLocator.click();
|
||||
//Find the modal that corresponds to the specific template (see html)
|
||||
const modal = this.page.locator(`div.modal:has-text("${template}")`)
|
||||
.first();
|
||||
|
||||
// Ensure the modal is visible before trying to interact with it
|
||||
await expect(modal).toBeVisible();
|
||||
// Ensure the modal is visible before trying to interact with it
|
||||
await expect(modal).toBeVisible();
|
||||
|
||||
// Click the delete button within the modal
|
||||
await modal.locator('.btn.btn-danger').click();
|
||||
// Click the delete button within the modal
|
||||
await modal.locator('.btn.btn-danger').click();
|
||||
return true;
|
||||
} else {
|
||||
console.log(`The schema ${template} can not be deleted`)
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error("A problem while trying to delete the template.", error);
|
||||
|
@ -187,20 +195,28 @@ export class TemplatesPage {
|
|||
}
|
||||
}
|
||||
|
||||
async gotoDeleteAndCancelInModal(template: String) {
|
||||
async gotoDeleteAndCancelInModal(template: String): Promise <boolean>{
|
||||
try {
|
||||
const row = this.page.locator(`tr:has-text('${template}')`);
|
||||
await row.locator('i.bi.bi-trash').click();
|
||||
const trashLocator = row.locator('i.bi.bi-trash');
|
||||
|
||||
//Find the modal that corresponds to the specific template (see html)
|
||||
const modal = this.page.locator(`div.modal:has-text("${template}")`)
|
||||
.first();
|
||||
// Check if the trash icon exists
|
||||
if (await trashLocator.count() > 0) {
|
||||
await trashLocator.click();
|
||||
//Find the modal that corresponds to the specific template (see html)
|
||||
const modal = this.page.locator(`div.modal:has-text("${template}")`)
|
||||
.first();
|
||||
|
||||
// Ensure the modal is visible before trying to interact with it
|
||||
await expect(modal).toBeVisible();
|
||||
// Ensure the modal is visible before trying to interact with it
|
||||
await expect(modal).toBeVisible();
|
||||
|
||||
// Click the delete button within the modal
|
||||
await modal.locator('.btn.btn-secondary').click();
|
||||
// Click the delete button within the modal
|
||||
await modal.locator('.btn.btn-secondary').click();
|
||||
return true;
|
||||
} else {
|
||||
console.log(`The schema ${template} can not be deleted`)
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("A problem while trying to delete the template.", error);
|
||||
throw error;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { test, expect} from '@playwright/test'
|
||||
import { test, expect } from '@playwright/test'
|
||||
import { TemplatesPage } from '../src/page-objects/AD_TemplatesPage'
|
||||
import { ViewImportedDataPage } from '../src/page-objects/AD_ViewImportedDataPage'
|
||||
import { ImportDataPage } from '../src/page-objects/AD_ImportDataPage'
|
||||
|
@ -66,11 +66,13 @@ test.describe('TEMPLATES Section Tests ', () => {
|
|||
/*Verify the schema was imported*/
|
||||
expect(await templatesPage.schemaIsAvailableInView(JSON_SCHEMA_FVC)).toBeTruthy();
|
||||
|
||||
/*Try to delete the schema and thenn confirm the operation*/
|
||||
await templatesPage.gotoDeleteAndConfirmInModal(JSON_SCHEMA_FVC);
|
||||
/*Verify the schema was deleted*/
|
||||
expect(await templatesPage.schemaIsAvailableInView(JSON_SCHEMA_FVC)).toBeFalsy();
|
||||
/*Try to delete the schema and then confirm the operation*/
|
||||
let wasDeleted = await templatesPage.gotoDeleteAndConfirmInModal(JSON_SCHEMA_FVC);
|
||||
|
||||
/*Verify the schema was deleted*/
|
||||
if (wasDeleted) {
|
||||
expect(await templatesPage.schemaIsAvailableInView(JSON_SCHEMA_FVC)).toBeFalsy();
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Reference in a new issue