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

Potential test fixes for tests failing in GitHub Action #3058

Merged
merged 2 commits into from
Jun 5, 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
25 changes: 15 additions & 10 deletions test/graph/calendars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "@pnp/graph/attachments";
import { HttpRequestError } from "@pnp/queryable";
import { getRandomString, stringIsNullOrEmpty } from "@pnp/core";
import getValidUser from "./utilities/getValidUser.js";
import { fail } from "assert";
// TODO:: test recording setup
describe("Calendar", function () {

Expand Down Expand Up @@ -460,8 +461,8 @@ describe("Calendar", function () {

// currently not working
it.skip("Get Event Attachments", async function () {
// const attachment = await this.pnp.graph.users.getById(testUserName).events.getById(testEventID).attachments.addFile(
// { name: "Test.txt" }, "base64bWFjIGFuZCBjaGVlc2UgdG9kYXk");
// const attachment = await this.pnp.graph.users.getById(testUserName).events.getById(testEventID).attachments.addFile(
// { name: "Test.txt" }, "base64bWFjIGFuZCBjaGVlc2UgdG9kYXk");

const attachments = await this.pnp.graph.users.getById(testUserName).events.getById(testEventID).attachments();
return expect(attachments.length).is.greaterThan(0);
Expand Down Expand Up @@ -606,16 +607,20 @@ describe("Calendar", function () {
allowedRoles: ["read", "write"],
});

await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).calendarPermissions.getById(permission.id).update({
role: "write",
});
if (permission.id) {
await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).calendarPermissions.getById(permission.id).update({
role: "write",
});

const updatedPermission = await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).calendarPermissions.getById(permission.id)();
if (updatedPermission.id && updatedPermission.role === "write") {
passed = true;
await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).delete();
const updatedPermission = await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).calendarPermissions.getById(permission.id)();
if (updatedPermission.id && updatedPermission.role === "write") {
passed = true;
await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).delete();
}
return expect(passed).is.true;
} else {
return fail("Permissions could not be created on the calendar object, test could not be completed.");
}
return expect(passed).is.true;
});

// This logs to the console when it passes, ignore those messages
Expand Down
5 changes: 2 additions & 3 deletions test/graph/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,8 @@ describe("Contacts", function () {
try {
// This passes the first time through, expecting it to fail on second pass.
// If we try to find a folder that doesn't exist this returns a 404
await this.pnp.graph.users.getById(testUserName).contactFolders.getById(folder.id)();
deletedFolderFound = true;

const deletedFolder = await this.pnp.graph.users.getById(testUserName).contactFolders.getById(folder.id)();
deletedFolderFound = (deletedFolder?.id.length> 0);
} catch (e) {
if (e?.isHttpRequestError) {
if ((<HttpRequestError>e).status === 404) {
Expand Down
4 changes: 2 additions & 2 deletions test/sp/clientside-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ describe("Clientside Pages", function () {
await page.save();

const page2 = await this.pnp.sp.web.loadClientsidePage(pageUrl);
expect(page2.authorByLine).to.eq(userPrincipalName);
expect(page2.authorByLine.toLowerCase()).to.eq(userPrincipalName.toLowerCase());
}));

it("setAuthorByLoginName()", pnpTest("8eb5897e-8b43-45ba-acbc-468495e189fe", async function () {
Expand All @@ -385,7 +385,7 @@ describe("Clientside Pages", function () {

const page2 = await this.pnp.sp.web.loadClientsidePage(pageUrl);

expect(page2.authorByLine).to.eq(userPrincipalName);
expect(page2.authorByLine.toLowerCase()).to.eq(userPrincipalName.toLowerCase());
}));
});

Expand Down