Skip to content

Commit ea1c0c6

Browse files
grzegorz-bielskiromanowski
authored andcommitted
Set up e2e tests for scala3doc
1 parent 1d3e4f1 commit ea1c0c6

File tree

12 files changed

+2189
-8
lines changed

12 files changed

+2189
-8
lines changed

scala3doc/e2e/.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true,
6+
"trailingComma": "all",
7+
"bracketSpacing": true,
8+
"arrowParens": "avoid"
9+
}

scala3doc/e2e/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## scala3doc e2e test suite
2+
3+
### Prerequisites
4+
5+
- install Node.js
6+
- run `npm i`
7+
8+
### Running tests
9+
10+
- generate the test docs: `sbt scala3doc/generateTestcasesDocumentation`
11+
- run the web server in the `output` directory: `python3 -m http.server 8080`
12+
- run `npm run cypress:open` to see the cypress UI or `npm run cypress:run` to run tests heedlessly

scala3doc/e2e/cypress.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "@testing-library/cypress/add-commands";
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import './commands';
2+
import { configure } from '@testing-library/cypress';
3+
4+
configure({ testIdAttribute: 'data-test-id' });

0 commit comments

Comments
 (0)