Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit956a341

Browse files
committed
Update org member tests
- Was not using the right layout.- Add feature and permissions responses.- Must use beforeEach, I guess routes get reset somewhere.- A bit unrelated, but change the useQuery to match the format of the others (avoiding the spread).
1 parentc8fbc4f commit956a341

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

‎site/src/pages/ManagementSettingsPage/ManagementSettingsLayout.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ export const ManagementSettingsLayout: FC = () => {
3737
const{ permissions}=useAuthenticated();
3838
const{ experiments}=useDashboard();
3939
constfeats=useFeatureVisibility();
40-
constdeploymentConfigQuery=useQuery({
41-
...deploymentConfig(),
40+
constdeploymentConfigQuery=useQuery(
4241
// TODO: This is probably normally fine because we will not show links to
4342
// pages that need this data, but if you manually visit the page you
4443
// will see an endless loader when maybe we should show a "permission
4544
// denied" error or at least a 404 instead.
46-
enabled:permissions.viewDeploymentValues,
47-
});
45+
permissions.viewDeploymentValues ?deploymentConfig() :{enabled:false},
46+
);
4847
constorganizationsQuery=useQuery(organizations());
4948

5049
constcanViewOrganizations=

‎site/src/pages/ManagementSettingsPage/OrganizationMembersPage.test.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,42 @@ import { fireEvent, screen, within } from "@testing-library/react";
22
importuserEventfrom"@testing-library/user-event";
33
import{HttpResponse,http}from"msw";
44
importtype{SlimRole}from"api/typesGenerated";
5-
import{MockUser,MockOrganizationAuditorRole}from"testHelpers/entities";
65
import{
7-
renderWithTemplateSettingsLayout,
6+
MockEntitlementsWithMultiOrg,
7+
MockUser,
8+
MockOrganization,
9+
MockOrganizationAuditorRole,
10+
}from"testHelpers/entities";
11+
import{
12+
renderWithManagementSettingsLayout,
813
waitForLoaderToBeRemoved,
914
}from"testHelpers/renderHelpers";
1015
import{server}from"testHelpers/server";
1116
importOrganizationMembersPagefrom"./OrganizationMembersPage";
1217

1318
jest.spyOn(console,"error").mockImplementation(()=>{});
1419

15-
beforeAll(()=>{
20+
beforeEach(()=>{
1621
server.use(
1722
http.get("/api/v2/experiments",()=>{
1823
returnHttpResponse.json(["multi-organization"]);
1924
}),
25+
http.get("/api/v2/entitlements",()=>{
26+
returnHttpResponse.json(MockEntitlementsWithMultiOrg);
27+
}),
28+
http.post("/api/v2/authcheck",async()=>{
29+
returnHttpResponse.json({
30+
editMembers:true,
31+
viewMembers:true,
32+
viewDeploymentValues:true,
33+
});
34+
}),
2035
);
2136
});
2237

2338
constrenderPage=async()=>{
24-
renderWithTemplateSettingsLayout(<OrganizationMembersPage/>,{
25-
route:`/organizations/my-organization/members`,
39+
renderWithManagementSettingsLayout(<OrganizationMembersPage/>,{
40+
route:`/organizations/${MockOrganization.name}/members`,
2641
path:`/organizations/:organization/members`,
2742
});
2843
awaitwaitForLoaderToBeRemoved();
@@ -69,7 +84,7 @@ describe("OrganizationMembersPage", () => {
6984
it("shows a success message",async()=>{
7085
awaitrenderPage();
7186
awaitremoveMember();
72-
awaitscreen.findByText("Member removed.");
87+
awaitscreen.findByText("Member removed successfully.");
7388
});
7489
});
7590
});

‎site/src/testHelpers/entities.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,6 +2209,17 @@ export const MockEntitlementsWithUserLimit: TypesGen.Entitlements = {
22092209
}),
22102210
};
22112211

2212+
exportconstMockEntitlementsWithMultiOrg:TypesGen.Entitlements={
2213+
...MockEntitlements,
2214+
has_license:true,
2215+
features:withDefaultFeatures({
2216+
multiple_organizations:{
2217+
enabled:true,
2218+
entitlement:"entitled",
2219+
},
2220+
}),
2221+
};
2222+
22122223
exportconstMockExperiments:TypesGen.Experiment[]=[];
22132224

22142225
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp