Skip to content

Commit c930f11

Browse files
committed
test(cypress): add test for auto-pproved pushes
1 parent b72d5c9 commit c930f11

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

cypress/e2e/autoApproved.cy.js

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

0 commit comments

Comments
 (0)