|
| 1 | +describe('filter-bar', () => { |
| 2 | + beforeEach(() => cy.visit('http://localhost:8080/testcases/api/tests/-filter-test/index.html')); |
| 3 | + |
| 4 | + it('properly renders filters extracted from the document', () => { |
| 5 | + const filterBar = new FilterBarFixture().toggle(); |
| 6 | + |
| 7 | + const testTable = [ |
| 8 | + ['Visibility', ['public', 'protected']], |
| 9 | + ['Keywords', ['no keywords', 'abstract', 'case', 'final', 'sealed']], |
| 10 | + ['Extension', ['Standard member', 'from tests']], |
| 11 | + ]; |
| 12 | + |
| 13 | + testTable.forEach(([title, filterOptions], index) => { |
| 14 | + const group = filterBar.group(index); |
| 15 | + |
| 16 | + group.title.should('have.text', title); |
| 17 | + group.filterOptions.should('deep.equal', filterOptions); |
| 18 | + }); |
| 19 | + }); |
| 20 | + |
| 21 | + it('filters by && across groups', () => {}); |
| 22 | +}); |
| 23 | + |
| 24 | +class FilterBarFixture { |
| 25 | + private get toggleButton() { |
| 26 | + return cy.findByTestId('filterToggleButton'); |
| 27 | + } |
| 28 | + |
| 29 | + group(at: number) { |
| 30 | + return new FilterBarGroupFixture(at); |
| 31 | + } |
| 32 | + |
| 33 | + toggle() { |
| 34 | + this.toggleButton.click(); |
| 35 | + |
| 36 | + return this; |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +class FilterBarGroupFixture { |
| 41 | + constructor(private readonly index: number) {} |
| 42 | + |
| 43 | + private get group() { |
| 44 | + return cy.findAllByTestId('filterGroup').eq(this.index); |
| 45 | + } |
| 46 | + |
| 47 | + private get filterList() { |
| 48 | + return this.group.findByTestId('filterGroupList'); |
| 49 | + } |
| 50 | + |
| 51 | + get title() { |
| 52 | + return this.group.findByTestId('filterGroupTitle'); |
| 53 | + } |
| 54 | + |
| 55 | + get filterOptions() { |
| 56 | + return this.filterList |
| 57 | + .findAllByTestId('filterGroupButton') |
| 58 | + .then($buttons => cy.wrap($buttons.toArray().map(i => i.innerText))); |
| 59 | + } |
| 60 | +} |
0 commit comments