Skip to content

Commit 5979c32

Browse files
authored
chore: skip flakey e2e tests (#17235)
1 parent ac7ea08 commit 5979c32

File tree

2 files changed

+145
-141
lines changed

2 files changed

+145
-141
lines changed

site/e2e/tests/externalAuth.spec.ts

+144-140
Original file line numberDiff line numberDiff line change
@@ -12,158 +12,162 @@ import {
1212
} from "../helpers";
1313
import { beforeCoderTest, resetExternalAuthKey } from "../hooks";
1414

15-
test.beforeAll(async ({ baseURL }) => {
16-
const srv = await createServer(gitAuth.webPort);
15+
test.describe.skip("externalAuth", () => {
16+
test.beforeAll(async ({ baseURL }) => {
17+
const srv = await createServer(gitAuth.webPort);
1718

18-
// The GitHub validate endpoint returns the currently authenticated user!
19-
srv.use(gitAuth.validatePath, (req, res) => {
20-
res.write(JSON.stringify(ghUser));
21-
res.end();
19+
// The GitHub validate endpoint returns the currently authenticated user!
20+
srv.use(gitAuth.validatePath, (req, res) => {
21+
res.write(JSON.stringify(ghUser));
22+
res.end();
23+
});
24+
srv.use(gitAuth.tokenPath, (req, res) => {
25+
const r = (Math.random() + 1).toString(36).substring(7);
26+
res.write(JSON.stringify({ access_token: r }));
27+
res.end();
28+
});
29+
srv.use(gitAuth.authPath, (req, res) => {
30+
res.redirect(
31+
`${baseURL}/external-auth/${gitAuth.webProvider}/callback?code=1234&state=${req.query.state}`,
32+
);
33+
});
2234
});
23-
srv.use(gitAuth.tokenPath, (req, res) => {
24-
const r = (Math.random() + 1).toString(36).substring(7);
25-
res.write(JSON.stringify({ access_token: r }));
26-
res.end();
27-
});
28-
srv.use(gitAuth.authPath, (req, res) => {
29-
res.redirect(
30-
`${baseURL}/external-auth/${gitAuth.webProvider}/callback?code=1234&state=${req.query.state}`,
31-
);
35+
36+
test.beforeEach(async ({ context, page }) => {
37+
beforeCoderTest(page);
38+
await login(page);
39+
await resetExternalAuthKey(context);
3240
});
33-
});
3441

35-
test.beforeEach(async ({ context, page }) => {
36-
beforeCoderTest(page);
37-
await login(page);
38-
await resetExternalAuthKey(context);
39-
});
42+
// Ensures that a Git auth provider with the device flow functions and completes!
43+
test("external auth device", async ({ page }) => {
44+
const device: ExternalAuthDevice = {
45+
device_code: "1234",
46+
user_code: "1234-5678",
47+
expires_in: 900,
48+
interval: 1,
49+
verification_uri: "",
50+
};
4051

41-
// Ensures that a Git auth provider with the device flow functions and completes!
42-
test("external auth device", async ({ page }) => {
43-
const device: ExternalAuthDevice = {
44-
device_code: "1234",
45-
user_code: "1234-5678",
46-
expires_in: 900,
47-
interval: 1,
48-
verification_uri: "",
49-
};
52+
// Start a server to mock the GitHub API.
53+
const srv = await createServer(gitAuth.devicePort);
54+
srv.use(gitAuth.validatePath, (req, res) => {
55+
res.write(JSON.stringify(ghUser));
56+
res.end();
57+
});
58+
srv.use(gitAuth.codePath, (req, res) => {
59+
res.write(JSON.stringify(device));
60+
res.end();
61+
});
62+
srv.use(gitAuth.installationsPath, (req, res) => {
63+
res.write(JSON.stringify(ghInstall));
64+
res.end();
65+
});
5066

51-
// Start a server to mock the GitHub API.
52-
const srv = await createServer(gitAuth.devicePort);
53-
srv.use(gitAuth.validatePath, (req, res) => {
54-
res.write(JSON.stringify(ghUser));
55-
res.end();
56-
});
57-
srv.use(gitAuth.codePath, (req, res) => {
58-
res.write(JSON.stringify(device));
59-
res.end();
60-
});
61-
srv.use(gitAuth.installationsPath, (req, res) => {
62-
res.write(JSON.stringify(ghInstall));
63-
res.end();
64-
});
67+
const token = {
68+
access_token: "",
69+
error: "authorization_pending",
70+
error_description: "",
71+
};
72+
// First we send a result from the API that the token hasn't been
73+
// authorized yet to ensure the UI reacts properly.
74+
const sentPending = new Awaiter();
75+
srv.use(gitAuth.tokenPath, (req, res) => {
76+
res.write(JSON.stringify(token));
77+
res.end();
78+
sentPending.done();
79+
});
6580

66-
const token = {
67-
access_token: "",
68-
error: "authorization_pending",
69-
error_description: "",
70-
};
71-
// First we send a result from the API that the token hasn't been
72-
// authorized yet to ensure the UI reacts properly.
73-
const sentPending = new Awaiter();
74-
srv.use(gitAuth.tokenPath, (req, res) => {
75-
res.write(JSON.stringify(token));
76-
res.end();
77-
sentPending.done();
81+
await page.goto(`/external-auth/${gitAuth.deviceProvider}`, {
82+
waitUntil: "domcontentloaded",
83+
});
84+
await page.getByText(device.user_code).isVisible();
85+
await sentPending.wait();
86+
// Update the token to be valid and ensure the UI updates!
87+
token.error = "";
88+
token.access_token = "hello-world";
89+
await page.waitForSelector("text=1 organization authorized");
7890
});
7991

80-
await page.goto(`/external-auth/${gitAuth.deviceProvider}`, {
81-
waitUntil: "domcontentloaded",
92+
test("external auth web", async ({ page }) => {
93+
await page.goto(`/external-auth/${gitAuth.webProvider}`, {
94+
waitUntil: "domcontentloaded",
95+
});
96+
// This endpoint doesn't have the installations URL set intentionally!
97+
await page.waitForSelector("text=You've authenticated with GitHub!");
8298
});
83-
await page.getByText(device.user_code).isVisible();
84-
await sentPending.wait();
85-
// Update the token to be valid and ensure the UI updates!
86-
token.error = "";
87-
token.access_token = "hello-world";
88-
await page.waitForSelector("text=1 organization authorized");
89-
});
9099

91-
test("external auth web", async ({ page }) => {
92-
await page.goto(`/external-auth/${gitAuth.webProvider}`, {
93-
waitUntil: "domcontentloaded",
100+
test("successful external auth from workspace", async ({ page }) => {
101+
const templateName = await createTemplate(
102+
page,
103+
echoResponsesWithExternalAuth([
104+
{ id: gitAuth.webProvider, optional: false },
105+
]),
106+
);
107+
108+
await createWorkspace(page, templateName, { useExternalAuth: true });
94109
});
95-
// This endpoint doesn't have the installations URL set intentionally!
96-
await page.waitForSelector("text=You've authenticated with GitHub!");
97-
});
98110

99-
test("successful external auth from workspace", async ({ page }) => {
100-
const templateName = await createTemplate(
101-
page,
102-
echoResponsesWithExternalAuth([
103-
{ id: gitAuth.webProvider, optional: false },
104-
]),
105-
);
111+
const ghUser: Endpoints["GET /user"]["response"]["data"] = {
112+
login: "kylecarbs",
113+
id: 7122116,
114+
node_id: "MDQ6VXNlcjcxMjIxMTY=",
115+
avatar_url: "https://avatars.githubusercontent.com/u/7122116?v=4",
116+
gravatar_id: "",
117+
url: "https://api.github.com/users/kylecarbs",
118+
html_url: "https://github.com/kylecarbs",
119+
followers_url: "https://api.github.com/users/kylecarbs/followers",
120+
following_url:
121+
"https://api.github.com/users/kylecarbs/following{/other_user}",
122+
gists_url: "https://api.github.com/users/kylecarbs/gists{/gist_id}",
123+
starred_url:
124+
"https://api.github.com/users/kylecarbs/starred{/owner}{/repo}",
125+
subscriptions_url: "https://api.github.com/users/kylecarbs/subscriptions",
126+
organizations_url: "https://api.github.com/users/kylecarbs/orgs",
127+
repos_url: "https://api.github.com/users/kylecarbs/repos",
128+
events_url: "https://api.github.com/users/kylecarbs/events{/privacy}",
129+
received_events_url:
130+
"https://api.github.com/users/kylecarbs/received_events",
131+
type: "User",
132+
site_admin: false,
133+
name: "Kyle Carberry",
134+
company: "@coder",
135+
blog: "https://carberry.com",
136+
location: "Austin, TX",
137+
email: "kyle@carberry.com",
138+
hireable: null,
139+
bio: "hey there",
140+
twitter_username: "kylecarbs",
141+
public_repos: 52,
142+
public_gists: 9,
143+
followers: 208,
144+
following: 31,
145+
created_at: "2014-04-01T02:24:41Z",
146+
updated_at: "2023-06-26T13:03:09Z",
147+
};
106148

107-
await createWorkspace(page, templateName, { useExternalAuth: true });
149+
const ghInstall: Endpoints["GET /user/installations"]["response"]["data"] = {
150+
installations: [
151+
{
152+
id: 1,
153+
access_tokens_url: "",
154+
account: ghUser,
155+
app_id: 1,
156+
app_slug: "coder",
157+
created_at: "2014-04-01T02:24:41Z",
158+
events: [],
159+
html_url: "",
160+
permissions: {},
161+
repositories_url: "",
162+
repository_selection: "all",
163+
single_file_name: "",
164+
suspended_at: null,
165+
suspended_by: null,
166+
target_id: 1,
167+
target_type: "",
168+
updated_at: "2023-06-26T13:03:09Z",
169+
},
170+
],
171+
total_count: 1,
172+
};
108173
});
109-
110-
const ghUser: Endpoints["GET /user"]["response"]["data"] = {
111-
login: "kylecarbs",
112-
id: 7122116,
113-
node_id: "MDQ6VXNlcjcxMjIxMTY=",
114-
avatar_url: "https://avatars.githubusercontent.com/u/7122116?v=4",
115-
gravatar_id: "",
116-
url: "https://api.github.com/users/kylecarbs",
117-
html_url: "https://github.com/kylecarbs",
118-
followers_url: "https://api.github.com/users/kylecarbs/followers",
119-
following_url:
120-
"https://api.github.com/users/kylecarbs/following{/other_user}",
121-
gists_url: "https://api.github.com/users/kylecarbs/gists{/gist_id}",
122-
starred_url: "https://api.github.com/users/kylecarbs/starred{/owner}{/repo}",
123-
subscriptions_url: "https://api.github.com/users/kylecarbs/subscriptions",
124-
organizations_url: "https://api.github.com/users/kylecarbs/orgs",
125-
repos_url: "https://api.github.com/users/kylecarbs/repos",
126-
events_url: "https://api.github.com/users/kylecarbs/events{/privacy}",
127-
received_events_url: "https://api.github.com/users/kylecarbs/received_events",
128-
type: "User",
129-
site_admin: false,
130-
name: "Kyle Carberry",
131-
company: "@coder",
132-
blog: "https://carberry.com",
133-
location: "Austin, TX",
134-
email: "kyle@carberry.com",
135-
hireable: null,
136-
bio: "hey there",
137-
twitter_username: "kylecarbs",
138-
public_repos: 52,
139-
public_gists: 9,
140-
followers: 208,
141-
following: 31,
142-
created_at: "2014-04-01T02:24:41Z",
143-
updated_at: "2023-06-26T13:03:09Z",
144-
};
145-
146-
const ghInstall: Endpoints["GET /user/installations"]["response"]["data"] = {
147-
installations: [
148-
{
149-
id: 1,
150-
access_tokens_url: "",
151-
account: ghUser,
152-
app_id: 1,
153-
app_slug: "coder",
154-
created_at: "2014-04-01T02:24:41Z",
155-
events: [],
156-
html_url: "",
157-
permissions: {},
158-
repositories_url: "",
159-
repository_selection: "all",
160-
single_file_name: "",
161-
suspended_at: null,
162-
suspended_by: null,
163-
target_id: 1,
164-
target_type: "",
165-
updated_at: "2023-06-26T13:03:09Z",
166-
},
167-
],
168-
total_count: 1,
169-
};

site/e2e/tests/outdatedAgent.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test.beforeEach(async ({ page }) => {
2020
await login(page);
2121
});
2222

23-
test(`ssh with agent ${agentVersion}`, async ({ page }) => {
23+
test.skip(`ssh with agent ${agentVersion}`, async ({ page }) => {
2424
test.setTimeout(60_000);
2525

2626
const token = randomUUID();

0 commit comments

Comments
 (0)