Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor toast message by test subj #176889

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,6 @@ export class ToastsService extends FtrService {
return { title, message };
}

public async toastMessageByTestSubj(testSubj = 'csp:toast-success') {
const testSubjSvc = this.testSubjects;
return {
async getElement(): Promise<WebElementWrapper> {
return await testSubjSvc.find(testSubj);
},
async clickToastMessageLink(linkTestSubj = 'csp:toast-success-link') {
const element = await this.getElement();
const link = await element.findByTestSubject(linkTestSubj);
await link.click();
},
};
}

/**
* Dismiss a specific toast from the toast list. Since toasts usually should time out themselves,
* you only need to call this for permanent toasts (e.g. error toasts).
Expand Down Expand Up @@ -123,7 +109,7 @@ export class ToastsService extends FtrService {
});
}

public async getElementByIndex(index: number): Promise<WebElementWrapper> {
public async getElementByIndex(index: number = 1): Promise<WebElementWrapper> {
return await (await this.getGlobalList()).findByCssSelector(`.euiToast:nth-child(${index})`);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await misconfigurationsFlyout.getVisibleText('csp:findings-flyout-detection-rule-count')
).to.be('1 detection rule');

const toastMessage = await (await toasts.toastMessageByTestSubj()).getElement();
expect(toastMessage).to.be.ok();
const toastMessageElement = await toasts.getElementByIndex();
expect(toastMessageElement).to.be.ok();

const toastMessageTitle = await toastMessage.findByTestSubject('csp:toast-success-title');
const toastMessageTitle = await toastMessageElement.findByTestSubject(
'csp:toast-success-title'
);
expect(await toastMessageTitle.getVisibleText()).to.be(ruleName1);

await (await toasts.toastMessageByTestSubj()).clickToastMessageLink();
await testSubjects.click('csp:toast-success-link');

const rulePageTitle = await testSubjects.find('header-page-title');
expect(await rulePageTitle.getVisibleText()).to.be(ruleName1);
Expand All @@ -183,13 +185,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await misconfigurationsFlyout.getVisibleText('csp:findings-flyout-detection-rule-count')
).to.be('1 detection rule');

const toastMessage = await (await toasts.toastMessageByTestSubj()).getElement();
const toastMessage = await toasts.getElementByIndex();
expect(toastMessage).to.be.ok();

const toastMessageTitle = await toastMessage.findByTestSubject('csp:toast-success-title');
expect(await toastMessageTitle.getVisibleText()).to.be(ruleName1);

await (await toasts.toastMessageByTestSubj()).clickToastMessageLink();
await testSubjects.click('csp:toast-success-link');

const rulePageTitle = await testSubjects.find('header-page-title');
expect(await rulePageTitle.getVisibleText()).to.be(ruleName1);
Expand All @@ -200,7 +202,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await latestFindingsTable.openFlyoutAt(0);
await misconfigurationsFlyout.clickTakeActionCreateRuleButton();

await (await toasts.toastMessageByTestSubj()).clickToastMessageLink();
await testSubjects.click('csp:toast-success-link');

const rulePageDescription = await testSubjects.find(
'stepAboutRuleDetailsToggleDescriptionText'
Expand Down