blob: 652b0da2ab312a6c154c29def2b3fc2050862e2b [file] [log] [blame]
import { PageObject } from '../../../infra-sk/modules/page_object/page_object';
/** A page object for the CorpusSelectorSkPO component. */
export class CorpusSelectorSkPO extends PageObject {
async isLoadingMessageVisible() {
return (await this.selectOnePOE('p')) !== null;
}
async getCorpora() {
return this.selectAllPOEThenMap('li', (li) => li.innerText);
}
/** Returns the selected corpus, or null if none is selected. */
async getSelectedCorpus() {
const selectedCorpora = await this.selectAllPOEThenMap('li.selected', (li) => li.innerText);
// There can be at most one selected corpora.
if (selectedCorpora.length > 1) {
throw new Error('there are more than one selected corpora');
}
if (selectedCorpora.length) {
return selectedCorpora[0];
}
return null;
}
async clickCorpus(corpus: string) {
const li = await this.selectAllPOEThenFind('li', async (li) => (await li.innerText) === corpus);
await li!.click();
}
}