Skip to content

Commit 48d7652

Browse files
committed
Fix e2e tests
1 parent ebf2f77 commit 48d7652

File tree

6 files changed

+40
-4
lines changed

6 files changed

+40
-4
lines changed

.github/workflows/coder.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ jobs:
157157
GOMAXPROCS: ${{ runner.os == 'Windows' && 1 || 2 }}
158158
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
159159
-covermode=atomic -coverprofile="gotests.coverage"
160+
-coverpkg=./.,github.com/coder/coder/codersdk
160161
-timeout=3m -count=$GOCOUNT -race -short -failfast
161162

162163
- name: Upload DataDog Trace
@@ -172,6 +173,7 @@ jobs:
172173
if: runner.os == 'Linux'
173174
run: DB=true gotestsum --junitfile="gotests.xml" --packages="./..." --
174175
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
176+
-coverpkg=./.,github.com/coder/coder/codersdk
175177
-count=1 -race -parallel=2 -failfast
176178

177179
- name: Upload DataDog Trace

coderd/provisionerjobs_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,38 @@ func TestProvisionerJobLogs(t *testing.T) {
9797
_, ok := <-logs
9898
require.False(t, ok)
9999
})
100+
101+
t.Run("List", func(t *testing.T) {
102+
t.Parallel()
103+
client := coderdtest.New(t, nil)
104+
user := coderdtest.CreateFirstUser(t, client)
105+
coderdtest.NewProvisionerDaemon(t, client)
106+
version := coderdtest.CreateProjectVersion(t, client, user.OrganizationID, &echo.Responses{
107+
Parse: echo.ParseComplete,
108+
Provision: []*proto.Provision_Response{{
109+
Type: &proto.Provision_Response_Log{
110+
Log: &proto.Log{
111+
Level: proto.LogLevel_INFO,
112+
Output: "log-output",
113+
},
114+
},
115+
}, {
116+
Type: &proto.Provision_Response_Complete{
117+
Complete: &proto.Provision_Complete{},
118+
},
119+
}},
120+
})
121+
project := coderdtest.CreateProject(t, client, user.OrganizationID, version.ID)
122+
coderdtest.AwaitProjectVersionJob(t, client, version.ID)
123+
workspace := coderdtest.CreateWorkspace(t, client, "me", project.ID)
124+
build, err := client.CreateWorkspaceBuild(context.Background(), workspace.ID, coderd.CreateWorkspaceBuildRequest{
125+
ProjectVersionID: project.ActiveVersionID,
126+
Transition: database.WorkspaceTransitionStart,
127+
})
128+
require.NoError(t, err)
129+
coderdtest.AwaitWorkspaceBuildJob(t, client, build.ID)
130+
logs, err := client.WorkspaceBuildLogsBefore(context.Background(), build.ID, time.Now())
131+
require.NoError(t, err)
132+
require.Len(t, logs, 1)
133+
})
100134
}

develop.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function create_initial_user() {
1818
curl -X POST \
1919
-d "{\"email\": \"$EMAIL\", \"username\": \"$USERNAME\", \"organization\": \"$ORGANIZATION\", \"password\": \"$PASSWORD\"}" \
2020
-H 'Content-Type:application/json' \
21-
http://localhost:3000/api/v2/user
21+
http://localhost:3000/api/v2/users/first
2222
}
2323

2424
# Run yarn install, to make sure node_modules are ready to go

images/coder/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function create_initial_user() {
1717
curl -X POST \
1818
-d '{"email": "'"$EMAIL"'", "username": "'"$USERNAME"'", "organization": "'"$ORGANIZATION"'", "password": "'"$PASSWORD"'"}' \
1919
-H 'Content-Type:application/json' \
20-
"http://localhost:$PORT/api/v2/user"
20+
"http://localhost:$PORT/api/v2/users/first"
2121
}
2222

2323
# This is a way to run multiple processes in parallel, and have Ctrl-C work correctly

site/e2e/globalSetup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const globalSetup = async (config: FullConfig): Promise<void> => {
1111
})
1212

1313
// Create initial user
14-
await context.post("/api/v2/user", {
14+
await context.post("/api/v2/users/first", {
1515
data: {
1616
email,
1717
username,

site/pages/projects/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { CodeExample } from "../../components/CodeExample/CodeExample"
1818
const ProjectsPage: React.FC = () => {
1919
const styles = useStyles()
2020
const { me, signOut } = useUser(true)
21-
const { data: projects, error } = useSWR<Project[] | null, Error>("/api/v2/projects")
2221
const { data: orgs, error: orgsError } = useSWR<Organization[], Error>("/api/v2/users/me/organizations")
22+
const { data: projects, error } = useSWR<Project[] | null, Error>(orgs ? `/api/v2/organizations/${orgs[0].id}/projects` : null)
2323

2424
if (error) {
2525
return <ErrorSummary error={error} />

0 commit comments

Comments
 (0)