Skip to content

Commit 8f23f04

Browse files
committed
test: add e2e test for clone button on repo page
1 parent 34b08a2 commit 8f23f04

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

cypress/e2e/repo.cy.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
describe('Repo', () => {
2+
beforeEach(() => {
3+
cy.visit('/admin/repo');
4+
5+
// prevent failures on 404 request and uncaught promises
6+
cy.on('uncaught:exception', () => false);
7+
});
8+
9+
describe('Code button for repo row', () => {
10+
it('Opens tooltip with correct content and can copy', () => {
11+
const cloneURL = 'http://localhost:8000/finos/test-repo.git';
12+
const tooltipQuery = 'div[role="tooltip"]';
13+
14+
cy
15+
// tooltip isn't open to start with
16+
.get(tooltipQuery)
17+
.should('not.exist');
18+
19+
cy
20+
// find the entry for finos/test-repo
21+
.get('a[href="/admin/repo/test-repo"]')
22+
// take it's parent row
23+
.closest('tr')
24+
// find the nearby span containing Code we can click to open the tooltip
25+
.find('span')
26+
.contains('Code')
27+
.should('exist')
28+
.click();
29+
30+
cy
31+
// find the newly opened tooltip
32+
.get(tooltipQuery)
33+
.should('exist')
34+
.find('span')
35+
// check it contains the url we expect
36+
.contains(cloneURL)
37+
.should('exist')
38+
.parent()
39+
// find the adjacent span that contains the svg
40+
.find('span')
41+
.next()
42+
// check it has the copy icon first and click it
43+
.get('svg.octicon-copy')
44+
.should('exist')
45+
.click()
46+
// check the icon has changed to the check icon
47+
.get('svg.octicon-copy')
48+
.should('not.exist')
49+
.get('svg.octicon-check')
50+
.should('exist');
51+
52+
// failed to successfully check the clipboard
53+
});
54+
});
55+
});

0 commit comments

Comments
 (0)