How to use octokit.issues.createComment method in qawolf

Best JavaScript code snippet using qawolf

index.ts

Source:index.ts Github

copy

Full Screen

...94 context.issue({95 labels: ["drill:bounty:failed"],96 })97 ),98 context.octokit.issues.createComment(99 context.issue({100 body: getErrorCommentBody(101 "# ⚠️ Bounty Failed",102 (error as any).simulationResponse === null103 ? getErrorMessage(error)104 : (error as any).simulationResponse.logs?.join("\n") ?? ""105 ),106 contentType: "text/x-markdown",107 })108 ),109 ]);110 }111 try {112 const signature = await program.methods113 .initializeBounty(repository.id, issue.number)114 .accounts({115 acceptedMint: ACCEPTED_MINT,116 authority: provider.wallet.publicKey,117 })118 .rpc();119 return Promise.all([120 context.octokit.issues.removeLabel(121 context.issue({122 name: "drill:bounty:processing",123 })124 ),125 context.octokit.issues.addLabels(126 context.issue({127 labels: ["drill:bounty:enabled"],128 })129 ),130 context.octokit.issues.createComment(131 context.issue({132 body: getBountyEnabledCommentBody(133 getExplorerUrl(134 signature,135 CLUSTER,136 provider.connection.rpcEndpoint137 )138 ),139 contentType: "text/x-markdown",140 })141 ),142 ]);143 } catch (error) {144 return Promise.all([145 context.octokit.issues.removeLabel(146 context.issue({147 name: "drill:bounty:processing",148 })149 ),150 context.octokit.issues.addLabels(151 context.issue({152 labels: ["drill:bounty:failed"],153 })154 ),155 context.octokit.issues.createComment(156 context.issue({157 body: getErrorCommentBody(158 "# ⚠️ Bounty Failed",159 getErrorMessage(error)160 ),161 contentType: "text/x-markdown",162 })163 ),164 ]);165 }166 });167 // Handle manual close of bounty168 app.on("issues.labeled", async (context) => {169 if (context.payload.label?.name !== "drill:bounty:manual-close") {170 return;171 }172 const {173 payload: { repository, issue },174 } = context;175 const config = await getSolanaConfig();176 const provider = await getProvider(config);177 const program = getProgram(provider);178 const [boardPublicKey] = await PublicKey.findProgramAddress(179 [180 Buffer.from("board", "utf8"),181 new BN(repository.id).toArrayLike(Buffer, "le", 4),182 ],183 program.programId184 );185 const [bountyPublicKey] = await PublicKey.findProgramAddress(186 [187 Buffer.from("bounty", "utf8"),188 boardPublicKey.toBuffer(),189 new BN(issue.number).toArrayLike(Buffer, "le", 4),190 ],191 program.programId192 );193 const bountyAccount = await program.account.bounty.fetchNullable(194 bountyPublicKey195 );196 await Promise.all(197 issue.labels198 .filter((label) => label.name.includes("drill:bounty"))199 .map(({ name }) =>200 context.octokit.issues.removeLabel(201 context.issue({202 name,203 })204 )205 )206 );207 if (bountyAccount === null) {208 return Promise.all([209 context.octokit.issues.addLabels(210 context.issue({211 labels: ["drill:bounty:close-failed"],212 })213 ),214 context.octokit.issues.createComment(215 context.issue({216 body: getErrorCommentBody(217 "# ⚠️ Failed to close bounty",218 "Bounty is not initialized"219 ),220 contentType: "text/x-markdown",221 })222 ),223 ]);224 }225 if (bountyAccount.isClosed) {226 return context.octokit.issues.addLabels(227 context.issue({228 labels: ["drill:bounty:closed"],229 })230 );231 }232 await context.octokit.issues.addLabels(233 context.issue({234 labels: ["drill:bounty:closing"],235 })236 );237 try {238 await program.methods239 .closeBounty(repository.id, issue.number, issue.assignee?.login ?? null)240 .accounts({241 authority: provider.wallet.publicKey,242 })243 .simulate();244 } catch (error) {245 return Promise.all([246 context.octokit.issues.removeLabel(247 context.issue({248 name: "drill:bounty:closing",249 })250 ),251 context.octokit.issues.addLabels(252 context.issue({253 labels: ["drill:bounty:close-failed"],254 })255 ),256 context.octokit.issues.createComment(257 context.issue({258 body: getErrorCommentBody(259 "# ⚠️ Failed to close bounty",260 (error as any).simulationResponse === null261 ? getErrorMessage(error)262 : (error as any).simulationResponse.logs?.join("\n") ?? ""263 ),264 contentType: "text/x-markdown",265 })266 ),267 ]);268 }269 try {270 const signature = await program.methods271 .closeBounty(repository.id, issue.number, issue.assignee?.login ?? null)272 .accounts({273 authority: provider.wallet.publicKey,274 })275 .rpc();276 return Promise.all([277 context.octokit.issues.removeLabel(278 context.issue({279 name: "drill:bounty:closing",280 })281 ),282 context.octokit.issues.addLabels(283 context.issue({284 labels: ["drill:bounty:closed"],285 })286 ),287 context.octokit.issues.createComment(288 context.issue({289 body: getBountyClosedCommentBody(290 getExplorerUrl(291 signature,292 CLUSTER,293 provider.connection.rpcEndpoint294 ),295 issue.assignee?.login296 ),297 contentType: "text/x-markdown",298 })299 ),300 ]);301 } catch (error) {302 return Promise.all([303 context.octokit.issues.removeLabel(304 context.issue({305 name: "drill:bounty:closing",306 })307 ),308 context.octokit.issues.addLabels(309 context.issue({310 labels: ["drill:bounty:close-failed"],311 })312 ),313 context.octokit.issues.createComment(314 context.issue({315 body: getErrorCommentBody(316 "# ⚠️ Failed to close bounty",317 getErrorMessage(error)318 ),319 contentType: "text/x-markdown",320 })321 ),322 ]);323 }324 });325 // Handle issue closed326 app.on("issues.closed", async (context) => {327 const {328 payload: { issue, repository },329 } = context;330 const config = await getSolanaConfig();331 const provider = await getProvider(config);332 const program = getProgram(provider);333 const [boardPublicKey] = await PublicKey.findProgramAddress(334 [335 Buffer.from("board", "utf8"),336 new BN(repository.id).toArrayLike(Buffer, "le", 4),337 ],338 program.programId339 );340 const [bountyPublicKey] = await PublicKey.findProgramAddress(341 [342 Buffer.from("bounty", "utf8"),343 boardPublicKey.toBuffer(),344 new BN(issue.number).toArrayLike(Buffer, "le", 4),345 ],346 program.programId347 );348 const bountyAccount = await program.account.bounty.fetchNullable(349 bountyPublicKey350 );351 await Promise.all(352 issue.labels353 .filter((label) => label.name.includes("drill:bounty"))354 .map(({ name }) =>355 context.octokit.issues.removeLabel(356 context.issue({357 name,358 })359 )360 )361 );362 if (bountyAccount === null) {363 return Promise.all([364 context.octokit.issues.addLabels(365 context.issue({366 labels: ["drill:bounty:close-failed"],367 })368 ),369 context.octokit.issues.createComment(370 context.issue({371 body: getErrorCommentBody(372 "# ⚠️ Failed to close bounty",373 "Bounty is not initialized"374 ),375 contentType: "text/x-markdown",376 })377 ),378 ]);379 }380 if (bountyAccount.isClosed) {381 return context.octokit.issues.addLabels(382 context.issue({383 labels: ["drill:bounty:closed"],384 })385 );386 }387 await context.octokit.issues.addLabels(388 context.issue({389 labels: ["drill:bounty:closing"],390 })391 );392 try {393 await program.methods394 .closeBounty(repository.id, issue.number, issue.assignee?.login ?? null)395 .accounts({396 authority: provider.wallet.publicKey,397 })398 .simulate();399 } catch (error) {400 return Promise.all([401 context.octokit.issues.removeLabel(402 context.issue({403 name: "drill:bounty:closing",404 })405 ),406 context.octokit.issues.addLabels(407 context.issue({408 labels: ["drill:bounty:close-failed"],409 })410 ),411 context.octokit.issues.createComment(412 context.issue({413 body: getErrorCommentBody(414 "# ⚠️ Failed to close bounty",415 (error as any).simulationResponse === null416 ? getErrorMessage(error)417 : (error as any).simulationResponse.logs?.join("\n") ?? ""418 ),419 contentType: "text/x-markdown",420 })421 ),422 ]);423 }424 try {425 const signature = await program.methods426 .closeBounty(repository.id, issue.number, issue.assignee?.login ?? null)427 .accounts({428 authority: provider.wallet.publicKey,429 })430 .rpc();431 return Promise.all([432 context.octokit.issues.removeLabel(433 context.issue({434 name: "drill:bounty:closing",435 })436 ),437 context.octokit.issues.addLabels(438 context.issue({439 labels: ["drill:bounty:closed"],440 })441 ),442 context.octokit.issues.createComment(443 context.issue({444 body: getBountyClosedCommentBody(445 getExplorerUrl(446 signature,447 CLUSTER,448 provider.connection.rpcEndpoint449 ),450 issue.assignee?.login451 ),452 contentType: "text/x-markdown",453 })454 ),455 ]);456 } catch (error) {457 return await Promise.all([458 context.octokit.issues.removeLabel(459 context.issue({460 name: "drill:bounty:closing",461 })462 ),463 context.octokit.issues.addLabels(464 context.issue({465 labels: ["drill:bounty:close-failed"],466 })467 ),468 context.octokit.issues.createComment(469 context.issue({470 body: getErrorCommentBody(471 "# ⚠️ Failed to close bounty",472 getErrorMessage(error)473 ),474 contentType: "text/x-markdown",475 })476 ),477 ]);478 }479 });480 // Handle issue assigned481 app.on("issues.assigned", async (context) => {482 const {483 payload: { issue, repository, assignee },484 } = context;485 const config = await getSolanaConfig();486 const provider = await getProvider(config);487 const program = getProgram(provider);488 const [boardPublicKey] = await PublicKey.findProgramAddress(489 [490 Buffer.from("board", "utf8"),491 new BN(repository.id).toArrayLike(Buffer, "le", 4),492 ],493 program.programId494 );495 const [bountyPublicKey] = await PublicKey.findProgramAddress(496 [497 Buffer.from("bounty", "utf8"),498 boardPublicKey.toBuffer(),499 new BN(issue.number).toArrayLike(Buffer, "le", 4),500 ],501 program.programId502 );503 const bountyAccount = await program.account.bounty.fetchNullable(504 bountyPublicKey505 );506 if (507 assignee === undefined ||508 bountyAccount === null ||509 !bountyAccount.isClosed510 ) {511 return;512 }513 await context.octokit.issues.addLabels(514 context.issue({515 labels: ["drill:bounty:changing-bounty-hunter"],516 })517 );518 try {519 await program.methods520 .setBountyHunter(repository.id, issue.number, assignee.login)521 .accounts({522 authority: provider.wallet.publicKey,523 })524 .simulate();525 } catch (error) {526 return Promise.all([527 context.octokit.issues.removeLabel(528 context.issue({529 name: "drill:bounty:changing-bounty-hunter",530 })531 ),532 context.octokit.issues.addLabels(533 context.issue({534 labels: ["drill:bounty:change-bounty-hunter-failed"],535 })536 ),537 context.octokit.issues.createComment(538 context.issue({539 body: getErrorCommentBody(540 "# ⚠️ Failed to change bounty hunter",541 (error as any).simulationResponse === null542 ? getErrorMessage(error)543 : (error as any).simulationResponse.logs?.join("\n") ?? ""544 ),545 contentType: "text/x-markdown",546 })547 ),548 ]);549 }550 try {551 const signature = await program.methods552 .setBountyHunter(repository.id, issue.number, assignee.login)553 .accounts({554 authority: provider.wallet.publicKey,555 })556 .rpc();557 return Promise.all([558 context.octokit.issues.removeLabel(559 context.issue({560 name: "drill:bounty:changing-bounty-hunter",561 })562 ),563 context.octokit.issues.createComment(564 context.issue({565 body: getBountyHunterChangedCommentBody(566 getExplorerUrl(567 signature,568 CLUSTER,569 provider.connection.rpcEndpoint570 ),571 assignee.login572 ),573 contentType: "text/x-markdown",574 })575 ),576 ]);577 } catch (error) {578 return await Promise.all([579 context.octokit.issues.removeLabel(580 context.issue({581 name: "drill:bounty:changing-bounty-hunter",582 })583 ),584 context.octokit.issues.addLabels(585 context.issue({586 labels: ["drill:bounty:change-bounty-hunter-failed"],587 })588 ),589 context.octokit.issues.createComment(590 context.issue({591 body: getErrorCommentBody(592 "# ⚠️ Failed to change bounty hunter",593 getErrorMessage(error)594 ),595 contentType: "text/x-markdown",596 })597 ),598 ]);599 }600 });...

Full Screen

Full Screen

checkWipDraftPRSpec.js

Source:checkWipDraftPRSpec.js Github

copy

Full Screen

1// Copyright 2020 The Oppia Authors. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS-IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14require('dotenv').config();15const github = require('@actions/github');16const core = require('@actions/core');17const checkWipDraftPRModule = require(18 '../actions/src/pull_requests/checkWipDraftPR');19const pullRequestEditedPayload = require('../fixtures/pullRequest.edited.json');20const dispatcher = require('../actions/src/dispatcher');21describe("Oppiabot's", () => {22 /**23 * @type {import('@actions/github').GitHub} octokit24 */25 let octokit;26 beforeEach(async () => {27 github.context.eventName = 'pull_request';28 github.context.payload = pullRequestEditedPayload;29 github.context.pull_request = pullRequestEditedPayload.pull_request;30 octokit = {31 issues: {32 createComment: jasmine.createSpy('createComment').and.resolveTo({}),33 addAssignees: jasmine.createSpy('addAssignees').and.resolveTo({}),34 },35 };36 spyOn(core, 'getInput').and.returnValue('sample-token');37 spyOnProperty(github.context, 'repo').and.returnValue({38 owner: pullRequestEditedPayload.repository.owner.login,39 repo: pullRequestEditedPayload.repository.name,40 });41 // Mock GitHub API.42 Object.setPrototypeOf(github.GitHub, function () {43 return octokit;44 });45 spyOn(checkWipDraftPRModule, 'checkWIP').and.callThrough();46 });47 describe('WIP PRs without skip prefix', () => {48 beforeEach(async () => {49 octokit.git = {50 getCommit: jasmine.createSpy('getCommit').and.resolveTo({51 data: {52 message: 'commit without skip prefix',53 },54 }),55 };56 await dispatcher.dispatch('pull_request', 'edited');57 });58 it('calls checkWIP function', () => {59 expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalled();60 });61 it('calls checkWIP once', () => {62 expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalledTimes(1);63 });64 it('calls get commit', () => {65 expect(octokit.git.getCommit).toHaveBeenCalled();66 expect(octokit.git.getCommit).toHaveBeenCalledTimes(1);67 expect(octokit.git.getCommit).toHaveBeenCalledWith({68 owner: pullRequestEditedPayload.repository.owner.login,69 repo: pullRequestEditedPayload.repository.name,70 commit_sha: pullRequestEditedPayload.pull_request.head.sha,71 });72 });73 it('assigns PR author', () => {74 expect(octokit.issues.addAssignees).toHaveBeenCalled();75 const params = {76 repo: pullRequestEditedPayload.repository.name,77 owner: pullRequestEditedPayload.repository.owner.login,78 issue_number: pullRequestEditedPayload.pull_request.number,79 assignees: ['testuser7777'],80 };81 expect(octokit.issues.addAssignees).toHaveBeenCalledWith(params);82 });83 it('creates comment for WIP PRs', () => {84 expect(octokit.issues.createComment).toHaveBeenCalled();85 expect(octokit.issues.createComment).toHaveBeenCalledTimes(1);86 // Comment on Pull Request.87 const link = 'here'.link(88 'https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia' +89 '#wip--draft-pull-requests'90 );91 const author = pullRequestEditedPayload.pull_request.user.login;92 const commentBody =93 'Hi @' +94 author +95 ', when creating WIP/Draft PRs, ensure that ' +96 'your commit messages are prefixed with **[ci skip]** or ' +97 '**[skip ci]** to prevent CI checks from running. ' +98 'You can learn more about it ' +99 link +100 '.';101 expect(octokit.issues.createComment).toHaveBeenCalledWith({102 issue_number: pullRequestEditedPayload.pull_request.number,103 owner: pullRequestEditedPayload.repository.owner.login,104 repo: pullRequestEditedPayload.repository.name,105 body: commentBody,106 });107 });108 });109 describe('WIP PRs with skip prefix', () => {110 beforeEach(async () => {111 octokit.git = {112 getCommit: jasmine.createSpy('getCommit').and.resolveTo({113 data: {114 message: '[ci skip] commit with skip prefix',115 },116 }),117 };118 await dispatcher.dispatch('pull_request_target', 'edited');119 });120 it('calls checkWIP function', () => {121 expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalled();122 });123 it('calls checkWIP once', () => {124 expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalledTimes(1);125 });126 it('calls get commit', () => {127 expect(octokit.git.getCommit).toHaveBeenCalled();128 expect(octokit.git.getCommit).toHaveBeenCalledTimes(1);129 expect(octokit.git.getCommit).toHaveBeenCalledWith({130 owner: pullRequestEditedPayload.repository.owner.login,131 repo: pullRequestEditedPayload.repository.name,132 commit_sha: pullRequestEditedPayload.pull_request.head.sha,133 });134 });135 it('does not assign PR author', () => {136 expect(octokit.issues.addAssignees).not.toHaveBeenCalled();137 });138 it('does not create comment for WIP PRs', () => {139 expect(octokit.issues.createComment).not.toHaveBeenCalled();140 });141 });142 describe('Checks when PR is opened or reopened', () => {143 it('should check when PR is opened', async () => {144 octokit.git = {145 getCommit: jasmine.createSpy('getCommit').and.resolveTo({146 data: {147 message: 'changes',148 },149 }),150 };151 // Trigger pull_request.opened event.152 pullRequestEditedPayload.action = 'opened';153 await dispatcher.dispatch('pull_request_target', 'opened');154 expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalled();155 expect(octokit.git.getCommit).toHaveBeenCalled();156 expect(octokit.issues.addAssignees).toHaveBeenCalled();157 expect(octokit.issues.addAssignees).toHaveBeenCalledTimes(1);158 expect(octokit.issues.createComment).toHaveBeenCalled();159 expect(octokit.issues.createComment).toHaveBeenCalledTimes(1);160 });161 it('should check when PR is reopened', async () => {162 octokit.git = {163 getCommit: jasmine.createSpy('getCommit').and.resolveTo({164 data: {165 message: 'commit without skip prefix',166 },167 }),168 };169 // Trigger pull_request.opened event.170 pullRequestEditedPayload.action = 'reopened';171 await dispatcher.dispatch('pull_request_target', 'reopened');172 expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalled();173 expect(octokit.git.getCommit).toHaveBeenCalled();174 expect(octokit.issues.addAssignees).toHaveBeenCalled();175 expect(octokit.issues.addAssignees).toHaveBeenCalledTimes(1);176 expect(octokit.issues.createComment).toHaveBeenCalled();177 expect(octokit.issues.createComment).toHaveBeenCalledTimes(1);178 });179 });180 describe('Draft PRs', () => {181 beforeEach(async () => {182 octokit.git = {183 getCommit: jasmine.createSpy('getCommit').and.resolveTo({184 data: {185 message: 'commit without skip prefix',186 },187 }),188 };189 // Receive a draft payload and remove WIP from title.190 pullRequestEditedPayload.pull_request.draft = true;191 pullRequestEditedPayload.pull_request.title = 'Testing Draft';192 await dispatcher.dispatch('pull_request_target', 'opened');193 });194 it('calls checkWIP function', () => {195 expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalled();196 });197 it('calls get commit', () => {198 expect(octokit.git.getCommit).toHaveBeenCalled();199 expect(octokit.git.getCommit).toHaveBeenCalledTimes(1);200 expect(octokit.git.getCommit).toHaveBeenCalledWith({201 owner: pullRequestEditedPayload.repository.owner.login,202 repo: pullRequestEditedPayload.repository.name,203 commit_sha: pullRequestEditedPayload.pull_request.head.sha,204 });205 });206 it('calls checkWIP once', () => {207 expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalledTimes(1);208 });209 it('assigns PR author', () => {210 expect(octokit.issues.addAssignees).toHaveBeenCalled();211 const params = {212 repo: pullRequestEditedPayload.repository.name,213 owner: pullRequestEditedPayload.repository.owner.login,214 issue_number: pullRequestEditedPayload.pull_request.number,215 assignees: ['testuser7777'],216 };217 expect(octokit.issues.addAssignees).toHaveBeenCalledWith(params);218 });219 it('creates comment for draft PRs', () => {220 expect(octokit.issues.createComment).toHaveBeenCalled();221 expect(octokit.issues.createComment).toHaveBeenCalledTimes(1);222 const link = 'here'.link(223 'https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia' +224 '#wip--draft-pull-requests'225 );226 const author = pullRequestEditedPayload.pull_request.user.login;227 const commentBody =228 'Hi @' +229 author +230 ', when creating WIP/Draft PRs, ensure that ' +231 'your commit messages are prefixed with **[ci skip]** or ' +232 '**[skip ci]** to prevent CI checks from running. ' +233 'You can learn more about it ' +234 link +235 '.';236 expect(octokit.issues.createComment).toHaveBeenCalledWith({237 issue_number: pullRequestEditedPayload.pull_request.number,238 owner: pullRequestEditedPayload.repository.owner.login,239 repo: pullRequestEditedPayload.repository.name,240 body: commentBody,241 });242 });243 });244 describe('Draft PRs with skip prefix', () => {245 beforeEach(async () => {246 octokit.git = {247 getCommit: jasmine.createSpy('getCommit').and.resolveTo({248 data: {249 message: '[skip ci] commit with skip prefix',250 },251 }),252 };253 // Receive a draft payload and remove WIP from title.254 pullRequestEditedPayload.pull_request.draft = true;255 pullRequestEditedPayload.pull_request.title = 'Testing Draft';256 await dispatcher.dispatch('pull_request_target', 'opened');257 });258 it('calls checkWIP function', () => {259 expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalled();260 });261 it('calls checkWIP once', () => {262 expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalledTimes(1);263 });264 it('calls get commit', () => {265 expect(octokit.git.getCommit).toHaveBeenCalled();266 expect(octokit.git.getCommit).toHaveBeenCalledTimes(1);267 expect(octokit.git.getCommit).toHaveBeenCalledWith({268 owner: pullRequestEditedPayload.repository.owner.login,269 repo: pullRequestEditedPayload.repository.name,270 commit_sha: pullRequestEditedPayload.pull_request.head.sha,271 });272 });273 it('does not assign PR author', () => {274 expect(octokit.issues.addAssignees).not.toHaveBeenCalled();275 });276 it('does not create comment for draft PRs', () => {277 expect(octokit.issues.createComment).not.toHaveBeenCalled();278 });279 });280 describe('Neither Draft nor WIP PRs', () => {281 beforeEach(async () => {282 octokit.git = {283 getCommit: jasmine.createSpy('getCommit').and.resolveTo({284 data: {285 message: '[skip ci] commit with skip prefix',286 },287 }),288 };289 // Receive a neither draft nor WIP payload.290 pullRequestEditedPayload.pull_request.draft = false;291 pullRequestEditedPayload.pull_request.title = 'Testing';292 await dispatcher.dispatch('pull_request_target', 'opened');293 });294 it('calls checkWIP function', () => {295 expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalled();296 });297 it('does not call get commit', () => {298 expect(octokit.git.getCommit).not.toHaveBeenCalled();299 });300 it('does not assign PR author', () => {301 expect(octokit.issues.addAssignees).not.toHaveBeenCalled();302 });303 it('does not create a comment', () => {304 expect(octokit.issues.createComment).not.toHaveBeenCalled();305 });306 });...

Full Screen

Full Screen

thens.js

Source:thens.js Github

copy

Full Screen

1module.exports = {2 async addLabel({octokit, octokitParams, iffft}) {3 try {4 await octokit.issues.addLabels(Object.assign({labels: [iffft.With]}, octokitParams))5 octokit.issues.createComment(Object.assign({6 body: `Hey @${iffft.user}, Iffftbot added the ${iffft.With} label to this issue because If ${iffft.If} Where ${iffft.Where} happened.`7 }, octokitParams))8 } catch (e) {9 console.log('catching failed Then addLabel', e)10 octokit.issues.createComment(Object.assign({11 body: `Hey @${iffft.user}, Iffftbot couldn't add the ${iffft.With} label to this issue even though If ${iffft.If} Where ${iffft.Where} happened. Does this need your attention?`12 }, octokitParams))13 }14 },15 async assign({octokit, octokitParams, iffft}) {16 try {17 await octokit.issues.addAssignees(Object.assign({assignees: [iffft.With]}, octokitParams))18 octokit.issues.createComment(Object.assign({19 body: `Hey @${iffft.With}, Iffftbot assigned you this issue because If ${iffft.If} Where ${iffft.Where} happened.`20 }, octokitParams))21 } catch (e) {22 console.log('catching failed Then assign', e)23 octokit.issues.createComment(Object.assign({24 body: `Hey @${iffft.user}, Iffftbot couldn't assign @${iffft.With} to this issue even though If ${iffft.If} Where ${iffft.Where} happened. Does this need your attention?`25 }, octokitParams))26 }27 },28 async close({octokit, octokitParams, iffft}) {29 try {30 await octokit.issues.update(Object.assign({state: 'closed'}, octokitParams))31 octokit.issues.createComment(Object.assign({32 body: `Hey @${iffft.user}, Iffftbot closed this issue because If ${iffft.If} Where ${iffft.Where} happened.`33 }, octokitParams))34 } catch (e) {35 console.log('catching failed Then close', e)36 octokit.issues.createComment(Object.assign({37 body: `Hey @${iffft.user}, Iffftbot couldn't close this issue even though If ${iffft.If} Where ${iffft.Where} happened. Does this need your attention?`38 }, octokitParams))39 }40 },41 async removeLabel({octokit, octokitParams, iffft}) {42 try {43 await octokit.issues.removeLabel(Object.assign({name: iffft.With}, octokitParams))44 octokit.issues.createComment(Object.assign({45 body: `Hey @${iffft.user}, Iffftbot removed the ${iffft.With} label from this issue because If ${iffft.If} Where ${iffft.Where} happened.`46 }, octokitParams))47 } catch (e) {48 console.log('catching failed Then removeLabel', e)49 octokit.issues.createComment(Object.assign({50 body: `Hey @${iffft.user}, Iffftbot couldn't remove the ${iffft.With} label from this issue even though If ${iffft.If} Where ${iffft.Where} happened. Does this need your attention?`51 }, octokitParams))52 }53 }...

Full Screen

Full Screen

app.test.js

Source:app.test.js Github

copy

Full Screen

...16 }17 }18 19 await app.commentOnNewIssue()20 await octokit.issues.createComment()21 expect(helpers.readFilePromise).toHaveBeenCalledTimes(1)22 expect(octokit.issues.createComment).toHaveBeenCalledTimes(1)23 //expect(octokit.issues.createComment.mock.calls[0][0].body).toMatch(/thanks for opening a new issue/)24 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Octokit } = require("@octokit/rest");2const octokit = new Octokit({3});4octokit.issues.createComment({5});6at processTicksAndRejections (internal/process/task_queues.js:97:5)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Octokit } = require("@octokit/rest");2const octokit = new Octokit({3});4octokit.issues.createComment({5});6 token: ${{ secrets.GITHUB_TOKEN }}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createComment } = require("qawolf");2const { context } = require("@actions/github");3const octokit = require("@actions/github").getOctokit(process.env.GITHUB_TOKEN);4async function run() {5 const issueNumber = context.payload.issue.number;6 const { data: issue } = await octokit.issues.get({7 });8 const body = issue.body;9 await createComment(body);10}11run();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful