test(docs-infra): add end to end tests for api reference (#37612)
Api search functionality only had unit tests @gkalpak suggested we should have some e2e tests too. Added some end to end tests. Fixes #35170 PR Close #37612
This commit is contained in:
parent
4481bebb38
commit
8924ec1474
|
@ -0,0 +1,52 @@
|
|||
import { by, element } from 'protractor';
|
||||
import { SitePage } from './app.po';
|
||||
|
||||
describe('api-list', () => {
|
||||
const apiSearchInput = element(by.css('aio-api-list .form-search input'));
|
||||
const apiStatusDropdown = element(by.css('aio-api-list aio-select[label="Status:"]'));
|
||||
const apiTypeDropdown = element(by.css('aio-api-list aio-select[label="Type:"]'));
|
||||
let page: SitePage;
|
||||
|
||||
beforeEach(() => {
|
||||
page = new SitePage();
|
||||
page.navigateTo('api');
|
||||
});
|
||||
|
||||
it('should find AnimationSequenceMetadata when searching by partial word anima', () => {
|
||||
expect(page.getApiSearchResults()).toContain('HttpEventType');
|
||||
|
||||
apiSearchInput.clear();
|
||||
apiSearchInput.sendKeys('anima');
|
||||
|
||||
expect(page.getApiSearchResults()).not.toContain('HttpEventType');
|
||||
expect(page.getApiSearchResults()).toContain('AnimationSequenceMetadata');
|
||||
});
|
||||
|
||||
it('should find getLocaleDateTimeFormat when searching by partial word date', () => {
|
||||
expect(page.getApiSearchResults()).toContain('formatCurrency');
|
||||
|
||||
apiSearchInput.clear();
|
||||
apiSearchInput.sendKeys('date');
|
||||
|
||||
expect(page.getApiSearchResults()).not.toContain('formatCurrency');
|
||||
expect(page.getApiSearchResults()).toContain('getLocaleDateTimeFormat');
|
||||
});
|
||||
|
||||
it('should find LowerCasePipe when searching for type pipe', () => {
|
||||
expect(page.getApiSearchResults()).toContain('getLocaleDateTimeFormat');
|
||||
|
||||
page.clickDropdownItem(apiTypeDropdown, 'Pipe');
|
||||
|
||||
expect(page.getApiSearchResults()).not.toContain('getLocaleDateTimeFormat');
|
||||
expect(page.getApiSearchResults()).toContain('LowerCasePipe');
|
||||
});
|
||||
|
||||
it('should find ElementRef when searching for status Security Risk', () => {
|
||||
expect(page.getApiSearchResults()).toContain('getLocaleDateTimeFormat');
|
||||
|
||||
page.clickDropdownItem(apiStatusDropdown, 'Security Risk');
|
||||
|
||||
expect(page.getApiSearchResults()).not.toContain('getLocaleDateTimeFormat');
|
||||
expect(page.getApiSearchResults()).toContain('ElementRef');
|
||||
});
|
||||
});
|
|
@ -83,4 +83,16 @@ export class SitePage {
|
|||
browser.wait(ExpectedConditions.presenceOf(results.first()), 8000);
|
||||
return results.map(link => link && link.getText());
|
||||
}
|
||||
|
||||
getApiSearchResults() {
|
||||
const results = element.all(by.css('aio-api-list .api-item'));
|
||||
browser.wait(ExpectedConditions.presenceOf(results.first()), 2000);
|
||||
return results.map(elem => elem && elem.getText());
|
||||
}
|
||||
|
||||
clickDropdownItem(dropdown: ElementFinder, itemName: string){
|
||||
dropdown.element(by.css('.form-select-button')).click();
|
||||
const menuItem = dropdown.element(by.cssContainingText('.form-select-dropdown li', itemName));
|
||||
menuItem.click();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue