Compare commits

...

4 Commits

Author SHA1 Message Date
bytedream d233a6ed7e
Merge c7a8412b3e into ecd1d96f49 2024-05-05 12:30:26 +08:00
yp05327 ecd1d96f49
Add result check in TestAPIEditUser (#29674)
Fix #29514
There are too many usage of `NewRequestWithValues`, so there's no need
to check all of them.
Just one is enough I think.
2024-05-05 02:10:20 +00:00
bytedream c7a8412b3e
Refactor `.length > 0` pattern
Co-authored-by: silverwind <me@silverwind.io>
2024-03-25 19:56:14 +01:00
bytedream 17f351b68e Add action auto-scrolling 2024-03-25 03:02:55 +01:00
2 changed files with 17 additions and 3 deletions

View File

@ -195,14 +195,17 @@ func TestAPIEditUser(t *testing.T) {
token := getUserToken(t, adminUsername, auth_model.AccessTokenScopeWriteAdmin)
urlStr := fmt.Sprintf("/api/v1/admin/users/%s", "user2")
fullNameToChange := "Full Name User 2"
req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{
// required
"login_name": "user2",
"source_id": "0",
// to change
"full_name": "Full Name User 2",
"full_name": fullNameToChange,
}).AddTokenAuth(token)
MakeRequest(t, req, http.StatusOK)
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"})
assert.Equal(t, fullNameToChange, user2.FullName)
empty := ""
req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{
@ -216,7 +219,7 @@ func TestAPIEditUser(t *testing.T) {
json.Unmarshal(resp.Body.Bytes(), &errMap)
assert.EqualValues(t, "e-mail invalid [email: ]", errMap["message"].(string))
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"})
user2 = unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"})
assert.False(t, user2.IsRestricted)
bTrue := true
req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{

View File

@ -191,11 +191,22 @@ const sfc = {
},
appendLogs(stepIndex, logLines, startTime) {
// position of the client view relative to the website top
const clientHeight = document.documentElement.clientHeight + window.scrollY;
// height of the logs container relative to the website top
const logsContainerHeight = this.$refs.stepsContainer.getBoundingClientRect().bottom + window.scrollY;
for (const line of logLines) {
// TODO: group support: ##[group]GroupTitle , ##[endgroup]
const el = this.getLogsContainer(stepIndex);
el.append(this.createLogLine(line, startTime, stepIndex));
}
// scrolls to the bottom if job is running and the bottom of the logs container is visible
if (!this.run.done && logLines.length && clientHeight >= logsContainerHeight) {
const newLogsContainerHeight = this.$refs.stepsContainer.getBoundingClientRect().bottom + window.scrollY;
window.scrollTo({top: clientHeight + (newLogsContainerHeight - logsContainerHeight), behavior: 'smooth'});
}
},
async fetchArtifacts() {
@ -436,7 +447,7 @@ export function initRepositoryActionView() {
</div>
</div>
<div class="action-view-right">
<div class="action-view-right" ref="stepsContainer">
<div class="job-info-header">
<div class="job-info-header-left gt-ellipsis">
<h3 class="job-info-header-title gt-ellipsis">