Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4: Test Comments and cleanup #3001

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions test/graph/calendars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ describe("Calendar", function () {
return expect(passed).is.true;
});

// This logs to the console when it passes, ignore those messages
it("Delete Calendar Group", async function () {
let deletedCalendarGroupFound = false;
const group = await this.pnp.graph.users.getById(testUserName).calendarGroups.add({
Expand All @@ -521,7 +522,7 @@ describe("Calendar", function () {
} catch (e) {
if (e?.isHttpRequestError) {
if ((<HttpRequestError>e).status === 404) {
console.error((<HttpRequestError>e).statusText);
// do nothing
}
} else {
console.log(e.message);
Expand Down Expand Up @@ -617,6 +618,7 @@ describe("Calendar", function () {
return expect(passed).is.true;
});

// This logs to the console when it passes, ignore those messages
it("Delete Calendar Permissions", async function () {
let deletePermissionFound = false;
const permission = await this.pnp.graph.users.getById(testUserName).calendars.getById(defaultCalID).calendarPermissions.add(
Expand All @@ -636,7 +638,7 @@ describe("Calendar", function () {
} catch (e) {
if (e?.isHttpRequestError) {
if ((<HttpRequestError>e).status === 404) {
console.error((<HttpRequestError>e).statusText);
// do nothing
}
} else {
console.log(e.message);
Expand Down
3 changes: 3 additions & 0 deletions test/graph/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ describe("Columns", function () {
return expect((updateColumn.displayName === newColumnName)).to.be.true;
}));

// This logs to the console when it passes, ignore those messages
it("delete", pnpTest("bcb9bafc-4d9c-40d3-a335-b6ff9650e25c", async function () {

const props = await this.props({
Expand Down Expand Up @@ -215,6 +216,7 @@ describe("Columns", function () {
return expect((updateColumnResults.propagateChanges)).to.be.true;
}));

// This logs to the console when it passes, ignore those messages
it("delete", pnpTest("4d6e18c1-abe7-4cd4-a90e-1c1715d5e1ce", async function () {
const c = await contentType.columns.addRef(siteColumn);
await contentType.columns.getById(c.id).delete();
Expand Down Expand Up @@ -276,6 +278,7 @@ describe("Columns", function () {
return expect((updateColumn.displayName === newColumnName)).to.be.true;
}));

// This logs to the console when it passes, ignore those messages
it("delete", pnpTest("16650b92-045a-4bfe-8f37-a8a8856385f2", async function () {

const props = await this.props({
Expand Down
2 changes: 2 additions & 0 deletions test/graph/content-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ describe("ContentTypes", function () {
return expect((updateContentType.name === newContentTypeName)).to.be.true;
}));

// This logs to the console when it passes, ignore those messages
it("delete", pnpTest("50a499b1-b6b9-47f7-b14e-567c03ac77a2", async function () {

const props = await this.props({
Expand Down Expand Up @@ -233,6 +234,7 @@ describe("ContentTypes", function () {
return expect((updateContentType.name === newContentTypeName)).to.be.true;
}));

// This logs to the console when it passes, ignore those messages
it("delete", pnpTest("5d8dc8f0-5220-400b-b990-0bcdfcd08594", async function () {

const props = await this.props({
Expand Down
1 change: 1 addition & 0 deletions test/graph/list-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe("List-Items", function () {
return expect(itemUpdated.fields.Title).is.eq(newTitle);
}));

// This logs to the console when it passes, ignore those messages
it("delete", pnpTest("e55bf53f-1316-4e47-97c1-b0c0cdd860ef", async function () {
await itemDelete.delete();
let passed = false;
Expand Down
1 change: 1 addition & 0 deletions test/graph/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe("Lists", function () {
return expect((updateList.displayName === newListName)).to.be.true;
}));

// This logs to the console when it passes, ignore those messages
it("delete", pnpTest("3d070839-0713-4a3e-a718-f89bb378cbe1", async function () {

const props = await this.props({
Expand Down
4 changes: 4 additions & 0 deletions test/graph/planner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ describe("Planner", function () {
return expect(planUpdate.title).is.equal(newPlanName);
});

// This logs to the console when it passes, ignore those messages
it("Delete", async function () {
const planName = `TestPlan_${getRandomString(4)}`;
const newPlan = JSON.parse(JSON.stringify(planTemplate));
Expand Down Expand Up @@ -174,6 +175,7 @@ describe("Planner", function () {
return expect(bucket.name).is.equal(newBucketName);
});

// This logs to the console when it passes, ignore those messages
it("Delete", async function () {
const bucketName = `TestBucket_${getRandomString(4)}`;
const newBucket = JSON.parse(JSON.stringify(bucketTemplate));
Expand Down Expand Up @@ -260,6 +262,7 @@ describe("Planner", function () {
return expect(task.title).is.equal(newTaskName);
});

// This logs to the console when it passes, ignore those messages
it("Delete", async function () {
const taskName = `TestTask_${getRandomString(4)}`;
const newTask = JSON.parse(JSON.stringify(taskTemplate));
Expand Down Expand Up @@ -441,6 +444,7 @@ describe("Planner", function () {
});
});

// This logs to the console when it passes, ignore those messages
after(async function () {
if (PlanIds.length > 0) {
PlanIds.forEach(async (id) => {
Expand Down
37 changes: 21 additions & 16 deletions test/sp/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,50 +41,55 @@ describe("Security", function () {
after(async function () {
if (this.pnp.settings.enableWebTests) {
// reset the list incase we use it again it will be ready
return list.resetRoleInheritance();
if (list != null) {
return list.resetRoleInheritance();
}
}
return;
});

it("roleAssignments", function () {

return expect(list.roleAssignments()).to.eventually.be.fulfilled;
it("roleAssignments", async function () {
const ra = await list.roleAssignments();
return expect(ra).to.not.be.null;
});

it("firstUniqueAncestorSecurableObject", function () {
it("firstUniqueAncestorSecurableObject", async function () {

return expect(list.firstUniqueAncestorSecurableObject()).to.eventually.be.fulfilled;
const a = await list.firstUniqueAncestorSecurableObject();
return expect(a).to.not.be.null;
});

it("getUserEffectivePermissions", async function () {

const users = await this.pnp.sp.web.siteUsers.top(1).select("LoginName")();
return expect(list.getUserEffectivePermissions(users[0].LoginName)).to.eventually.be.fulfilled;
const bp = await list.getUserEffectivePermissions(users[0].LoginName);
return expect(bp).to.not.be.null;
});

it("getCurrentUserEffectivePermissions", async function () {

return expect(list.getCurrentUserEffectivePermissions()).to.eventually.be.fulfilled;
const ep = await list.getCurrentUserEffectivePermissions();
return expect(ep).to.not.be.null;
});

it("userHasPermissions", async function () {

const users = await this.pnp.sp.web.siteUsers.top(1).select("LoginName")();
return expect(list.userHasPermissions(users[0].LoginName, PermissionKind.AddListItems)).to.eventually.be.fulfilled;
const hp = await list.userHasPermissions(users[0].LoginName, PermissionKind.AddListItems);
return expect(hp).to.not.be.null;
});

it("currentUserHasPermissions", async function () {

return expect(list.currentUserHasPermissions(PermissionKind.AddListItems)).to.eventually.be.fulfilled;
const hp = await list.currentUserHasPermissions(PermissionKind.AddListItems);
return expect(hp).to.not.be.null;
});

it("breakRoleInheritance", async function () {

return expect(list.breakRoleInheritance(true, true)).to.eventually.be.fulfilled;
const br = await list.breakRoleInheritance(true, true);
return expect(br).to.not.be.null;
});

it("updateRoleDef", async function () {
// We cannot alter Role Definitions on a subsite, we therefore test updating Role Definitions against the parent site.
return expect(parentWeb.roleDefinitions.getByName(testRoleDefName).update({ BasePermissions: { Low: 3, High: 0 } })).to.eventually.be.fulfilled;
const rd = await parentWeb.roleDefinitions.getByName(testRoleDefName).update({ BasePermissions: { Low: 3, High: 0 } });
return expect(rd).to.not.be.null;
});
});