forked from G-Research/git-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoApproved.cy.js
More file actions
72 lines (62 loc) · 1.89 KB
/
autoApproved.cy.js
File metadata and controls
72 lines (62 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import moment from 'moment';
describe('Auto-Approved Push Test', () => {
beforeEach(() => {
cy.login('admin', 'admin');
cy.intercept('GET', '/api/v1/push/123', {
statusCode: 200,
body: {
steps: [
{
stepName: 'diff',
content: '',
},
],
error: false,
allowPush: true,
authorised: true,
canceled: false,
rejected: false,
autoApproved: true,
autoRejected: false,
commitFrom: 'commitFrom',
commitTo: 'commitTo',
branch: 'refs/heads/main',
user: 'testUser',
id: 'commitFrom__commitTo',
type: 'push',
method: 'POST',
timestamp: 1696161600000,
project: 'testUser',
repoName: 'test.git',
url: 'https://github.com/testUser/test.git',
repo: 'testUser/test.git',
commitData: [
{
tree: '1234',
parent: '12345',
},
],
attestation: {
timestamp: '2023-10-01T12:00:00Z',
autoApproved: true,
},
},
}).as('getPush');
});
it('should display auto-approved message and verify tooltip contains the expected timestamp', () => {
cy.visit('/dashboard/push/123');
cy.wait('@getPush');
cy.contains('Auto-approved by system').should('be.visible');
cy.get('svg.MuiSvgIcon-root')
.filter((_, el) => getComputedStyle(el).fill === 'rgb(0, 128, 0)')
.invoke('attr', 'style')
.should('include', 'cursor: default')
.and('include', 'opacity: 0.5');
const expectedTooltipTimestamp = moment('2023-10-01T12:00:00Z')
.local()
.format('dddd, MMMM Do YYYY, h:mm:ss a');
cy.get('kbd').trigger('mouseover');
cy.get('.MuiTooltip-tooltip').should('contain', expectedTooltipTimestamp);
cy.contains('approved this contribution').should('not.exist');
});
});