Skip to content

Commit 8a344f4

Browse files
committed
chore: fix tests
1 parent 0b013c3 commit 8a344f4

File tree

2 files changed

+674
-66
lines changed

2 files changed

+674
-66
lines changed

cypress/e2e/repo.cy.js

Lines changed: 17 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,17 @@
11
describe('Repo', () => {
2+
let cookies;
3+
let repoName;
4+
25
describe('Anonymous users', () => {
6+
beforeEach(() => {
7+
cy.visit('/dashboard/repo');
8+
});
9+
310
it('Prevents anonymous users from adding repos', () => {
411
cy.get('[data-testid="repo-list-view"]')
512
.find('[data-testid="add-repo-button"]')
613
.should('not.exist');
714
});
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/git-proxy.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/git-proxy
21-
.get('a[href="/dashboard/repo/git-proxy"]')
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-
});
5515
});
5616

5717
describe('Regular users', () => {
@@ -80,18 +40,22 @@ describe('Repo', () => {
8040
});
8141

8242
it('Admin users can add repos', () => {
43+
repoName = `${Date.now()}`;
44+
8345
cy.get('[data-testid="repo-list-view"]').find('[data-testid="add-repo-button"]').click();
8446

8547
cy.get('[data-testid="add-repo-dialog"]').within(() => {
86-
cy.get('[data-testid="repo-project-input"]').type('uuidjs');
87-
cy.get('[data-testid="repo-name-input"]').type('uuidjs');
88-
cy.get('[data-testid="repo-url-input"]').type('https://github.com/uuidjs/uuid.git');
48+
cy.get('[data-testid="repo-project-input"]').type('cypress-test');
49+
cy.get('[data-testid="repo-name-input"]').type(repoName);
50+
cy.get('[data-testid="repo-url-input"]').type(
51+
`https://github.com/cypress-test/${repoName}.git`,
52+
);
8953
cy.get('[data-testid="add-repo-button"]').click();
9054
});
9155

92-
cy.get('a[href="/dashboard/repo/uuidjs"]', { timeout: 10000 }).click();
56+
cy.contains('a', `cypress-test/${repoName}`, { timeout: 10000 }).click();
9357

94-
cy.get('[data-testid="delete-repo-button"]').click();
58+
// cy.get('[data-testid="delete-repo-button"]').click();
9559
});
9660

9761
it('Prevents adding an existing repo', () => {
@@ -106,14 +70,12 @@ describe('Repo', () => {
10670

10771
cy.get('[data-testid="repo-error"]')
10872
.should('be.visible')
109-
.and('contain.text', 'Repository already exists!');
73+
.and('contain.text', 'Repository https://github.com/finos/git-proxy.git already exists!');
11074
});
11175
});
11276

11377
describe('Existing repo', () => {
114-
let repoName;
11578
let cloneURL;
116-
let cookies;
11779
let repoId;
11880

11981
before(() => {

0 commit comments

Comments
 (0)