Skip to content

Commit 95f346e

Browse files
committed
fix(cypress): stabilize profile and auto-approved checks
1 parent 848401e commit 95f346e

2 files changed

Lines changed: 38 additions & 49 deletions

File tree

cypress/e2e/profile.cy.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,32 +103,8 @@ describe('Profile Page', () => {
103103
// --- 5.3 Admin can edit another user's GitHub username ---
104104
it("5.3 — Admin can edit another user's GitHub username", () => {
105105
cy.login('admin', 'admin');
106-
// Stub both the auth profile call (so AuthProvider/RouteGuard resolve quickly)
107-
// and the target user API call to avoid UserProfile throwing on a real API error.
108-
cy.intercept('GET', '**/api/auth/profile', {
109-
statusCode: 200,
110-
body: {
111-
username: 'admin',
112-
displayName: 'admin',
113-
email: 'admin@place.com',
114-
title: '',
115-
gitAccount: 'none',
116-
admin: true,
117-
},
118-
}).as('getAuthUser');
119-
cy.intercept('GET', `**/api/v1/user/${testUser.username}`, {
120-
statusCode: 200,
121-
body: {
122-
username: testUser.username,
123-
displayName: 'Profile Test User',
124-
email: testUser.email,
125-
title: 'QA Tester',
126-
gitAccount: testUser.gitAccount,
127-
admin: false,
128-
},
129-
}).as('getUser');
106+
cy.intercept('GET', `**/api/v1/user/${testUser.username}`).as('getUser');
130107
cy.visit(`/dashboard/user/${testUser.username}`);
131-
cy.wait('@getAuthUser');
132108
cy.wait('@getUser');
133109

134110
// Wait for profile to render

src/ui/views/PushDetails/components/AttestationInfo.tsx

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ const AttestationInfo: React.FC<AttestationInfoProps> = ({
4040
return null;
4141
}
4242

43-
const reviewerGitAccount =
44-
push.attestation.reviewer.gitAccount || push.attestation.reviewer.username;
45-
4643
return (
4744
<div
4845
style={{
@@ -79,27 +76,7 @@ const AttestationInfo: React.FC<AttestationInfoProps> = ({
7976
</p>
8077
</div>
8178
) : (
82-
<>
83-
{isGitHub && (
84-
<UserLink username={push.attestation.reviewer.username}>
85-
<img
86-
style={{ width: '45px', borderRadius: '20px' }}
87-
src={`https://github.com/${reviewerGitAccount}.png`}
88-
/>
89-
</UserLink>
90-
)}
91-
<div>
92-
<p>
93-
{isGitHub && (
94-
<UserLink username={push.attestation.reviewer.username}>
95-
{reviewerGitAccount}
96-
</UserLink>
97-
)}
98-
{!isGitHub && <UserLink username={push.attestation.reviewer.username} />} approved
99-
this contribution
100-
</p>
101-
</div>
102-
</>
79+
<ReviewerInfo push={push} isGitHub={isGitHub} />
10380
)}
10481

10582
<Tooltip
@@ -122,4 +99,40 @@ const AttestationInfo: React.FC<AttestationInfoProps> = ({
12299
);
123100
};
124101

102+
interface ReviewerInfoProps {
103+
push: PushActionView;
104+
isGitHub: boolean;
105+
}
106+
107+
const ReviewerInfo: React.FC<ReviewerInfoProps> = ({ push, isGitHub }) => {
108+
if (!push.attestation?.reviewer) {
109+
return null;
110+
}
111+
112+
const reviewerGitAccount =
113+
push.attestation.reviewer.gitAccount || push.attestation.reviewer.username;
114+
115+
return (
116+
<>
117+
{isGitHub && (
118+
<UserLink username={push.attestation.reviewer.username}>
119+
<img
120+
style={{ width: '45px', borderRadius: '20px' }}
121+
src={`https://github.com/${reviewerGitAccount}.png`}
122+
/>
123+
</UserLink>
124+
)}
125+
<div>
126+
<p>
127+
{isGitHub && (
128+
<UserLink username={push.attestation.reviewer.username}>{reviewerGitAccount}</UserLink>
129+
)}
130+
{!isGitHub && <UserLink username={push.attestation.reviewer.username} />} approved this
131+
contribution
132+
</p>
133+
</div>
134+
</>
135+
);
136+
};
137+
125138
export default AttestationInfo;

0 commit comments

Comments
 (0)