Best JavaScript code snippet using playwright-internal
router.js
Source:router.js
...33 const path = app.getState('cognitoLoginUrl');34 externalRoute(path);35 };36 const goto404 = () => {37 app.getSequence('navigateToPathSequence')({38 path: '404',39 });40 };41 if (!app.getState('user')) {42 gotoLoginPage();43 } else {44 if (45 permissionToCheck &&46 !app.getState('permissions')[permissionToCheck]47 ) {48 goto404();49 } else {50 app.getSequence('clearAlertSequence')();51 cb.apply(null, arguments);52 }53 }54 };55 };56 route(57 '/',58 ifHasAccess(() => {59 setPageTitle('Dashboard');60 app.getSequence('gotoDashboardSequence')();61 }),62 );63 route(64 '/case-detail/*',65 ifHasAccess(docketNumber => {66 setPageTitle(`Docket ${docketNumber}`);67 app.getSequence('gotoCaseDetailSequence')({68 docketNumber,69 });70 }),71 );72 route(73 '/case-detail/*?openModal=*',74 ifHasAccess((docketNumber, openModal) => {75 setPageTitle(`Docket ${docketNumber}`);76 app.getSequence('gotoCaseDetailSequence')({77 docketNumber,78 openModal,79 });80 }),81 );82 route(83 '/case-detail/*/case-information',84 ifHasAccess(docketNumber => {85 window.history.replaceState(null, null, `/case-detail/${docketNumber}`);86 setPageTitle(`Docket ${docketNumber}`);87 app.getSequence('gotoCaseDetailSequence')({88 docketNumber,89 primaryTab: 'caseInformation',90 });91 }),92 );93 route(94 '/case-detail/*/edit-petitioner-information',95 ifHasAccess(docketNumber => {96 setPageTitle(`Docket ${docketNumber}`);97 app.getSequence('gotoEditPetitionerInformationSequence')({98 docketNumber,99 });100 }),101 );102 route(103 '/case-detail/*/edit-details',104 ifHasAccess(docketNumber => {105 setPageTitle(`Docket ${docketNumber}`);106 app.getSequence('gotoEditPetitionDetailsSequence')({107 docketNumber,108 });109 }),110 );111 route(112 '/case-detail/*/documents/*',113 ifHasAccess((docketNumber, documentId) => {114 setPageTitle(115 `${getPageTitleDocketPrefix(docketNumber)} Document details`,116 );117 app.getSequence('gotoDocumentDetailSequence')({118 docketNumber,119 documentId,120 });121 }, ROLE_PERMISSIONS.UPDATE_CASE),122 );123 route(124 '/case-detail/*/documents/*/edit-saved..',125 ifHasAccess((docketNumber, documentId) => {126 setPageTitle(127 `${getPageTitleDocketPrefix(128 docketNumber,129 )} Edit saved document details`,130 );131 if (!isEmpty(app.getState('form'))) {132 const { tab } = route.query();133 app.getSequence('gotoEditSavedDocumentDetailSequence')({134 docketNumber,135 documentId,136 tab,137 });138 } else {139 app.getSequence('gotoDocumentDetailSequence')({140 docketNumber,141 documentId,142 });143 }144 }, ROLE_PERMISSIONS.UPDATE_CASE),145 );146 route(147 '/case-detail/*/documents/*/review',148 ifHasAccess((docketNumber, documentId) => {149 setPageTitle(150 `${getPageTitleDocketPrefix(docketNumber)} Document detail review`,151 );152 app.getSequence('gotoReviewSavedPetitionSequence')({153 caseId: docketNumber,154 docketNumber,155 documentId,156 });157 }, ROLE_PERMISSIONS.UPDATE_CASE),158 );159 route(160 '/case-detail/*/documents/*/complete',161 ifHasAccess((docketNumber, documentId) => {162 setPageTitle(163 `${getPageTitleDocketPrefix(docketNumber)} Edit docket record`,164 );165 app.getSequence('gotoCompleteDocketEntrySequence')({166 docketNumber,167 documentId,168 });169 }),170 );171 route(172 '/case-detail/*/documents/*/edit',173 ifHasAccess((docketNumber, documentId) => {174 setPageTitle(175 `${getPageTitleDocketPrefix(docketNumber)} Edit docket record`,176 );177 app.getSequence('gotoEditDocketEntrySequence')({178 docketNumber,179 documentId,180 });181 }),182 );183 route(184 '/case-detail/*/docket-entry/*/edit-meta',185 ifHasAccess((docketNumber, docketRecordIndex) => {186 setPageTitle(187 `${getPageTitleDocketPrefix(docketNumber)} Edit Docket Entry Meta`,188 );189 app.getSequence('gotoEditDocketEntryMetaSequence')({190 docketNumber,191 docketRecordIndex: +docketRecordIndex,192 });193 }),194 );195 route(196 '/case-detail/*/documents/*/edit-court-issued',197 ifHasAccess((docketNumber, documentId) => {198 setPageTitle(199 `${getPageTitleDocketPrefix(docketNumber)} Edit docket entry`,200 );201 app.getSequence('gotoEditCourtIssuedDocketEntrySequence')({202 docketNumber,203 documentId,204 });205 }),206 );207 route(208 '/case-detail/*/documents/*/sign',209 ifHasAccess((docketNumber, documentId) => {210 app.getSequence('gotoSignPDFDocumentSequence')({211 docketNumber,212 documentId,213 pageNumber: 1,214 });215 }),216 );217 route(218 '/case-detail/*/documents/*/messages/*/sign',219 ifHasAccess((docketNumber, documentId, messageId) => {220 app.getSequence('gotoSignPDFDocumentSequence')({221 docketNumber,222 documentId,223 messageId,224 pageNumber: 1,225 });226 }),227 );228 route(229 '/case-detail/*/documents/*/mark/*',230 ifHasAccess((docketNumber, documentId, workItemIdToMarkAsRead) => {231 setPageTitle(232 `${getPageTitleDocketPrefix(docketNumber)} Document details`,233 );234 app.getSequence('gotoDocumentDetailSequence')({235 docketNumber,236 documentId,237 workItemIdToMarkAsRead,238 });239 }),240 );241 route(242 '/case-detail/*/documents/*/messages/*',243 ifHasAccess((docketNumber, documentId, messageId) => {244 setPageTitle(245 `${getPageTitleDocketPrefix(docketNumber)} Document details`,246 );247 app.getSequence('gotoDocumentDetailSequence')({248 docketNumber,249 documentId,250 messageId,251 });252 }),253 );254 route(255 '/case-detail/*/documents/*/messages/*/mark/*',256 ifHasAccess(257 (docketNumber, documentId, messageId, workItemIdToMarkAsRead) => {258 setPageTitle(259 `${getPageTitleDocketPrefix(docketNumber)} Document details`,260 );261 app.getSequence('gotoDocumentDetailSequence')({262 docketNumber,263 documentId,264 messageId,265 workItemIdToMarkAsRead,266 });267 },268 ),269 );270 route(271 '/case-detail/*/before-you-file-a-document',272 ifHasAccess(docketNumber => {273 setPageTitle(274 `${getPageTitleDocketPrefix(275 docketNumber,276 )} Before you file a document`,277 );278 app.getSequence('gotoBeforeYouFileDocumentSequence')({ docketNumber });279 }),280 );281 route(282 '/case-detail/*/file-a-document',283 ifHasAccess(docketNumber => {284 setPageTitle(285 `${getPageTitleDocketPrefix(docketNumber)} File a document`,286 );287 if (app.getState('currentPage') === 'FileDocumentWizard') {288 app.getSequence('chooseWizardStepSequence')({289 value: 'SelectDocumentType',290 });291 } else {292 app.getSequence('gotoFileDocumentSequence')({ docketNumber });293 }294 }),295 );296 route(297 '/case-detail/*/file-a-document/details',298 ifHasAccess(docketNumber => {299 setPageTitle(300 `${getPageTitleDocketPrefix(docketNumber)} File a document`,301 );302 if (app.getState('currentPage') === 'FileDocumentWizard') {303 app.getSequence('chooseWizardStepSequence')({304 value: 'FileDocument',305 });306 } else {307 app.getSequence('navigateToPathSequence')({308 path: `/case-detail/${docketNumber}/file-a-document`,309 });310 }311 }),312 );313 route(314 '/case-detail/*/file-a-document/review',315 ifHasAccess(docketNumber => {316 setPageTitle(317 `${getPageTitleDocketPrefix(docketNumber)} File a document`,318 );319 if (app.getState('currentPage') === 'FileDocumentWizard') {320 app.getSequence('chooseWizardStepSequence')({321 value: 'FileDocumentReview',322 });323 } else {324 app.getSequence('navigateToPathSequence')({325 path: `/case-detail/${docketNumber}/file-a-document`,326 });327 }328 }),329 );330 route(331 '/case-detail/*/file-a-document/all-document-categories',332 ifHasAccess(docketNumber => {333 setPageTitle(334 `${getPageTitleDocketPrefix(docketNumber)} File a document`,335 );336 if (app.getState('currentPage') === 'FileDocumentWizard') {337 app.getSequence('chooseWizardStepSequence')({338 value: 'ViewAllDocuments',339 });340 } else {341 app.getSequence('navigateToPathSequence')({342 path: `/case-detail/${docketNumber}/file-a-document`,343 });344 }345 }),346 );347 route(348 '/case-detail/*/contacts/primary/edit',349 ifHasAccess(docketNumber => {350 setPageTitle(351 `${getPageTitleDocketPrefix(docketNumber)} Primary contact`,352 );353 app.getSequence('gotoPrimaryContactEditSequence')({ docketNumber });354 }),355 );356 route(357 '/case-detail/*/contacts/secondary/edit',358 ifHasAccess(docketNumber => {359 setPageTitle(360 `${getPageTitleDocketPrefix(docketNumber)} Secondary contact`,361 );362 app.getSequence('gotoSecondaryContactEditSequence')({ docketNumber });363 }),364 );365 route(366 '/case-detail/*/create-order',367 ifHasAccess(docketNumber => {368 setPageTitle(369 `${getPageTitleDocketPrefix(docketNumber)} Create an order`,370 );371 app.getSequence('gotoCreateOrderSequence')({ docketNumber });372 }),373 );374 route(375 '/case-detail/*/upload-court-issued',376 ifHasAccess(docketNumber => {377 setPageTitle(378 `${getPageTitleDocketPrefix(docketNumber)} Upload a document`,379 );380 app.getSequence('gotoUploadCourtIssuedDocumentSequence')({381 docketNumber,382 });383 }),384 );385 route(386 '/case-detail/*/edit-upload-court-issued/*',387 ifHasAccess((docketNumber, documentId) => {388 setPageTitle(389 `${getPageTitleDocketPrefix(docketNumber)} Upload a document`,390 );391 app.getSequence('gotoEditUploadCourtIssuedDocumentSequence')({392 docketNumber,393 documentId,394 });395 }),396 );397 route(398 '/case-detail/*/edit-order/*',399 ifHasAccess((docketNumber, documentIdToEdit) => {400 setPageTitle(`${getPageTitleDocketPrefix(docketNumber)} Edit an order`);401 const sequence = app.getSequence('gotoEditOrderSequence');402 sequence({403 docketNumber,404 documentIdToEdit,405 });406 }),407 );408 route(409 '/case-detail/*/edit-order/*/sign',410 ifHasAccess((docketNumber, documentId) => {411 setPageTitle(`${getPageTitleDocketPrefix(docketNumber)} Edit an order`);412 const sequence = app.getSequence('gotoSignOrderSequence');413 sequence({414 docketNumber,415 documentId,416 });417 }),418 );419 route(420 '/case-detail/*/add-docket-entry',421 ifHasAccess(docketNumber => {422 setPageTitle(423 `${getPageTitleDocketPrefix(docketNumber)} Add docket entry`,424 );425 app.getSequence('gotoAddDocketEntrySequence')({ docketNumber });426 }),427 );428 route(429 '/case-detail/*/documents/*/add-court-issued-docket-entry',430 ifHasAccess((docketNumber, documentId) => {431 setPageTitle(432 `${getPageTitleDocketPrefix(docketNumber)} Add docket entry`,433 );434 app.getSequence('gotoAddCourtIssuedDocketEntrySequence')({435 docketNumber,436 documentId,437 });438 }),439 );440 route(441 '/case-detail/*/printable-docket-record',442 ifHasAccess(docketNumber => {443 setPageTitle(`${getPageTitleDocketPrefix(docketNumber)} Docket record`);444 app.getSequence('gotoPrintableDocketRecordSequence')({ docketNumber });445 }),446 );447 route(448 '/case-detail/*/confirmation',449 ifHasAccess(docketNumber => {450 setPageTitle(451 `${getPageTitleDocketPrefix(docketNumber)} Case Confirmation`,452 );453 app.getSequence('gotoPrintableCaseConfirmationSequence')({454 docketNumber,455 });456 }),457 );458 route(459 '/case-detail/*/pending-report',460 ifHasAccess(docketNumber => {461 setPageTitle(462 `${getPageTitleDocketPrefix(docketNumber)} Pending Report`,463 );464 app.getSequence('gotoPrintablePendingReportForCaseSequence')({465 caseIdFilter: true,466 docketNumber,467 });468 }),469 );470 route(471 '/case-detail/*/request-access',472 ifHasAccess(docketNumber => {473 setPageTitle(474 `${getPageTitleDocketPrefix(docketNumber)} Request access`,475 );476 if (app.getState('wizardStep') === 'RequestAccessReview') {477 app.getSequence('chooseWizardStepSequence')({478 value: 'RequestAccess',479 });480 } else {481 app.getSequence('gotoRequestAccessSequence')({ docketNumber });482 }483 }),484 );485 route(486 '/case-detail/*/request-access/review',487 ifHasAccess(docketNumber => {488 setPageTitle(489 `${getPageTitleDocketPrefix(docketNumber)} Request access review`,490 );491 if (!app.getState('wizardStep')) {492 app.getSequence('navigateToPathSequence')({493 path: `/case-detail/${docketNumber}/request-access`,494 });495 } else {496 app.getSequence('chooseWizardStepSequence')({497 value: 'RequestAccessReview',498 });499 }500 }),501 );502 route(503 '/users/create-attorney',504 ifHasAccess(() => {505 setPageTitle('EF-CMS User Management - Create Attorney User');506 app.getSequence('gotoCreateAttorneyUserSequence')();507 }),508 );509 route(510 '/users/edit-attorney/*',511 ifHasAccess(userId => {512 setPageTitle('EF-CMS User Management - Edit Attorney User');513 app.getSequence('gotoEditAttorneyUserSequence')({ userId });514 }),515 );516 route(517 '/document-qc..',518 ifHasAccess(() => {519 const path = route._.getPathFromBase();520 const validPaths = [521 'document-qc',522 'document-qc/my',523 'document-qc/my/inbox',524 'document-qc/my/inProgress',525 'document-qc/my/outbox',526 'document-qc/section',527 'document-qc/section/inbox',528 'document-qc/section/inProgress',529 'document-qc/section/outbox',530 ];531 if (path && !validPaths.includes(path)) {532 app.getSequence('notFoundErrorSequence')({533 error: {},534 });535 } else {536 const routeArgs = {537 workQueueIsInternal: false,538 };539 const pathParts = path.split('/');540 if (pathParts[1]) {541 routeArgs.queue = pathParts[1];542 }543 if (pathParts[2]) {544 routeArgs.box = pathParts[2];545 }546 app.getSequence('gotoMessagesSequence')(routeArgs);547 }548 setPageTitle('Document QC');549 }),550 );551 route(552 '/print-preview/*',553 ifHasAccess(docketNumber => {554 setPageTitle(`${getPageTitleDocketPrefix(docketNumber)} Print Service`);555 app.getSequence('gotoPrintPreviewSequence')({556 alertWarning: {557 message:558 'This case has parties receiving paper service. Print and mail all paper service documents below.',559 title: 'This document has been electronically served',560 },561 docketNumber,562 });563 }),564 );565 route(566 '/trial-session-detail/*',567 ifHasAccess(trialSessionId => {568 setPageTitle('Trial session information');569 app.getSequence('gotoTrialSessionDetailSequence')({ trialSessionId });570 }, ROLE_PERMISSIONS.TRIAL_SESSIONS),571 );572 route(573 '/trial-session-working-copy/*',574 ifHasAccess(trialSessionId => {575 setPageTitle('Trial session working copy');576 app.getSequence('gotoTrialSessionWorkingCopySequence')({577 trialSessionId,578 });579 }, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY),580 );581 route(582 '/trial-session-planning-report',583 ifHasAccess(() => {584 setPageTitle('Trial session planning report');585 app.getSequence('gotoTrialSessionPlanningReportSequence')();586 }),587 );588 route(589 '/trial-sessions..',590 ifHasAccess(() => {591 const trialSessionFilter = {};592 forEach(route.query(), (value, key) => {593 set(trialSessionFilter, key, value);594 });595 setPageTitle('Trial sessions');596 app.getSequence('gotoTrialSessionsSequence')({597 query: trialSessionFilter,598 });599 }, ROLE_PERMISSIONS.TRIAL_SESSIONS),600 );601 route('/idle-logout', () => {602 app.getSequence('gotoIdleLogoutSequence')();603 });604 route('/log-in...', () => {605 const { code, path, token } = queryStringDecoder();606 if (code) {607 app.getSequence('loginWithCodeSequence')({ code, path });608 } else {609 app.getSequence('loginWithTokenSequence')({ path, token });610 }611 });612 route(613 '/before-filing-a-petition',614 ifHasAccess(() => {615 setPageTitle('Before you file a petition');616 app.getSequence('gotoBeforeStartCaseSequence')();617 }),618 );619 route(620 '/file-a-petition/step-*',621 ifHasAccess(step => {622 setPageTitle('File a petition');623 if (app.getState('currentPage') === 'StartCaseWizard') {624 app.getSequence('chooseStartCaseWizardStepSequence')({625 step: `${step}`,626 value: `StartCaseStep${step}`,627 });628 } else {629 if (app.getState('currentPage') !== 'StartCaseInternal') {630 switch (step) {631 case '1':632 app.getSequence('gotoStartCaseWizardSequence')({633 step,634 wizardStep: `StartCaseStep${step}`,635 });636 break;637 default:638 app.getSequence('navigateToPathSequence')({639 path: '/file-a-petition/step-1',640 });641 }642 }643 }644 }),645 );646 route(647 'file-a-petition/review-petition',648 ifHasAccess(() => {649 setPageTitle('Review Petition');650 app.getSequence('gotoReviewPetitionFromPaperSequence')();651 }),652 );653 route(654 '/file-a-petition-pa11y/step-*',655 ifHasAccess(step => {656 setPageTitle('File a petition');657 app.getSequence('gotoStartCaseWizardSequence')({658 step,659 wizardStep: `StartCaseStep${step}`,660 });661 }),662 );663 route(664 '/add-a-trial-session',665 ifHasAccess(() => {666 setPageTitle('Add a trial session');667 app.getSequence('gotoAddTrialSessionSequence')();668 }, ROLE_PERMISSIONS.TRIAL_SESSIONS),669 );670 route(671 '/edit-trial-session/*',672 ifHasAccess(trialSessionId => {673 setPageTitle('Edit trial session');674 app.getSequence('gotoEditTrialSessionSequence')({ trialSessionId });675 }, ROLE_PERMISSIONS.TRIAL_SESSIONS),676 );677 route('/style-guide', () => {678 setPageTitle('Style guide');679 app.getSequence('gotoStyleGuideSequence')();680 });681 route('/accessibility-statement', () => {682 setPageTitle('Accessibility statement');683 app.getSequence('gotoAccessibilityStatementSequence')();684 });685 route(686 '/messages..',687 ifHasAccess(() => {688 const path = route._.getPathFromBase();689 const validPaths = [690 'messages',691 'messages/my',692 'messages/my/inbox',693 'messages/my/outbox',694 'messages/section',695 'messages/section/inbox',696 'messages/section/outbox',697 ];698 if (path && !validPaths.includes(path)) {699 app.getSequence('notFoundErrorSequence')({700 error: {},701 });702 } else {703 const routeArgs = {704 workQueueIsInternal: true,705 };706 const pathParts = path.split('/');707 if (pathParts[1]) {708 routeArgs.queue = pathParts[1];709 }710 if (pathParts[2]) {711 routeArgs.box = pathParts[2];712 }713 app.getSequence('gotoMessagesSequence')(routeArgs);714 }715 setPageTitle('Messages');716 }),717 );718 route(719 '/pdf-preview',720 ifHasAccess(() => {721 setPageTitle('PDF Preview');722 app.getSequence('gotoPdfPreviewSequence')();723 }),724 );725 route(726 '/reports/case-inventory-report',727 ifHasAccess(() => {728 setPageTitle('Case Inventory Report');729 app.getSequence('gotoCaseInventoryReportSequence')();730 }),731 );732 route(733 '/reports/case-deadlines',734 ifHasAccess(() => {735 setPageTitle('Case deadlines');736 app.getSequence('gotoAllCaseDeadlinesSequence')();737 }),738 );739 route(740 '/reports/blocked-cases',741 ifHasAccess(() => {742 setPageTitle('Blocked cases');743 app.getSequence('gotoBlockedCasesReportSequence')();744 }),745 );746 route(747 '/reports/pending-report',748 ifHasAccess(() => {749 setPageTitle('Pending report');750 app.getSequence('gotoPendingReportSequence')();751 }),752 );753 route(754 '/reports/pending-report/printable..',755 ifHasAccess(() => {756 const { judgeFilter } = route.query();757 setPageTitle('Pending report');758 app.getSequence('gotoPrintablePendingReportSequence')({759 judgeFilter,760 });761 }),762 );763 route(764 '/user/contact/edit',765 ifHasAccess(() => {766 setPageTitle('Edit user contact');767 app.getSequence('gotoUserContactEditSequence')();768 }),769 );770 route(771 '/search/no-matches',772 ifHasAccess(() => {773 setPageTitle('Search results');774 app.getSequence('gotoCaseSearchNoMatchesSequence')();775 }, ROLE_PERMISSIONS.ADVANCED_SEARCH),776 );777 route(778 '/search..',779 ifHasAccess(() => {780 const query = route.query();781 setPageTitle('Advanced search');782 app.getSequence('gotoAdvancedSearchSequence')(query);783 }, ROLE_PERMISSIONS.ADVANCED_SEARCH),784 );785 route('/mock-login...', () => {786 const { path, token } = queryStringDecoder();787 if (token) {788 setPageTitle('Mock login');789 app.getSequence('submitLoginSequence')({ path, token });790 return;791 }792 if (process.env.COGNITO) {793 setPageTitle('Dashboard');794 app.getSequence('gotoDashboardSequence')();795 } else {796 setPageTitle('Mock login');797 app.getSequence('gotoLoginSequence')();798 }799 });800 route(801 '..',802 () => {803 setPageTitle('Error');804 app.getSequence('notFoundErrorSequence')({805 error: {},806 });807 },808 true,809 );810 route.start(true);811 },812};813export {814 back,815 createObjectURL,816 externalRoute,817 openInNewTab,818 revokeObjectURL,...
utils.spec.js
Source:utils.spec.js
...30 } );31 describe( 'getSequence', () => {32 it( 'identifies backspaces', () => {33 expect.assertions( 1 );34 const result = getSequence( {35 name: 'backspace',36 sequence: ''37 } );38 expect( result ).toStrictEqual( 'backspace' );39 } );40 it( 'identifies sequence based CTRL-C', () => {41 expect.assertions( 1 );42 const result = getSequence( {43 name: '',44 sequence: '\u0003'45 } );46 expect( result ).toStrictEqual( 'ctrlc' );47 } );48 it( 'identifies natural CTRL-C', () => {49 expect.assertions( 1 );50 const result = getSequence( {51 ctrl: true,52 name: 'c'53 } );54 expect( result ).toStrictEqual( 'ctrlc' );55 } );56 it( 'identifies the return key', () => {57 expect.assertions( 1 );58 const result = getSequence( {59 name: 'return',60 sequence: '\r'61 } );62 expect( result ).toStrictEqual( 'return' );63 } );64 it( 'identifies letters', () => {65 expect.assertions( 1 );66 const result = getSequence( {67 name: 'c',68 sequence: 'c'69 } );70 expect( result ).toStrictEqual( 'c' );71 } );72 it( 'identifies numbers', () => {73 expect.assertions( 1 );74 const result = getSequence( {75 name: '2',76 sequence: '2'77 } );78 expect( result ).toStrictEqual( '2' );79 } );80 it( 'identifies other characters', () => {81 expect.assertions( 1 );82 const result = getSequence( {83 name: undefined,84 sequence: '-'85 } );86 expect( result ).toStrictEqual( '-' );87 } );88 } );...
socketRouter.js
Source:socketRouter.js
...4 const message = JSON.parse(event.data);5 const { action } = message;6 switch (action) {7 case 'notice_generation_complete':8 await app.getSequence('noticeGenerationCompleteSequence')({9 ...message,10 });11 break;12 case 'update_trial_session_complete':13 await app.getSequence('updateTrialSessionCompleteSequence')({14 ...message,15 });16 break;17 case 'batch_download_ready':18 await app.getSequence('batchDownloadReadySequence')({19 ...message,20 });21 break;22 case 'batch_download_docket_generated':23 case 'batch_download_upload_start':24 case 'batch_download_progress':25 await app.getSequence('updateBatchDownloadProgressSequence')({26 action,27 ...message,28 });29 break;30 case 'batch_download_error':31 await app.getSequence('batchDownloadErrorSequence')({32 ...message,33 });34 break;35 case 'user_contact_initial_update_complete':36 await app.getSequence('userContactUpdateInitialUpdateCompleteSequence')(37 { ...message },38 );39 break;40 case 'user_contact_full_update_complete':41 await app.getSequence('userContactUpdateCompleteSequence')({42 ...message,43 });44 break;45 case 'user_contact_update_progress':46 await app.getSequence('userContactUpdateProgressSequence')({47 ...message,48 });49 break;50 case 'user_contact_update_error':51 await app.getSequence('userContactUpdateErrorSequence')({52 ...message,53 });54 break;55 case 'admin_contact_initial_update_complete':56 await app.getSequence(57 'adminContactUpdateInitialUpdateCompleteSequence',58 )({ ...message });59 break;60 case 'admin_contact_full_update_complete':61 await app.getSequence('adminContactUpdateCompleteSequence')({62 ...message,63 });64 break;65 case 'admin_contact_update_progress':66 await app.getSequence('adminContactUpdateProgressSequence')({67 ...message,68 });69 break;70 case 'maintenance_mode_engaged':71 await app.getSequence('openAppMaintenanceModalSequence')({72 ...message,73 maintenanceMode: true,74 path: '/maintenance',75 });76 break;77 case 'maintenance_mode_disengaged':78 await app.getSequence('disengageAppMaintenanceSequence')({79 ...message,80 maintenanceMode: false,81 path: '/',82 });83 break;84 }85 (onMessageCallbackFn || noop)(message);86 };...
routerPublic.js
Source:routerPublic.js
...20 // eslint-disable-next-line no-underscore-dangle21 window.__cy_route = path => router.route(path || '/');22 route('/case-detail/*', docketNumber => {23 setPageTitle(`Docket ${docketNumber}`);24 app.getSequence('gotoPublicCaseDetailSequence')({ docketNumber });25 });26 route('/case-detail/*/printable-docket-record', docketNumber => {27 setPageTitle(`Docket ${docketNumber}`);28 app.getSequence('gotoPublicPrintableDocketRecordSequence')({29 docketNumber,30 });31 });32 route('/todays-opinions', () => {33 setPageTitle('Todayâs Opinions');34 app.getSequence('gotoTodaysOpinionsSequence')();35 });36 route('/todays-orders', () => {37 setPageTitle('Todayâs Orders');38 app.getSequence('gotoTodaysOrdersSequence')();39 });40 route('/health', () => {41 setPageTitle('Health Check');42 return app.getSequence('gotoHealthCheckSequence')();43 });44 route('/', () => {45 setPageTitle('Dashboard');46 app.getSequence('gotoPublicSearchSequence')();47 });48 route('/privacy', () => {49 setPageTitle('Privacy');50 return app.getSequence('gotoPrivacySequence')();51 });52 route('/contact', () => {53 setPageTitle('Contact');54 return app.getSequence('gotoContactSequence')();55 });56 route('/email-verification-success', () => {57 setPageTitle('Email Verification Success');58 return app.getSequence('gotoPublicEmailVerificationSuccessSequence')();59 });60 route('/email-verification-instructions', () => {61 setPageTitle('Email Verification Instructions');62 return app.getSequence(63 'gotoPublicEmailVerificationInstructionsSequence',64 )();65 });66 route('/maintenance', () => {67 setPageTitle('Maintenance');68 return app.getSequence('gotoMaintenanceSequence')();69 });70 route('..', () => {71 setPageTitle('Error');72 return app.getSequence('notFoundErrorSequence')({73 error: {},74 });75 });76 route.start(true);77 },78};...
getSequence.test.js
Source:getSequence.test.js
1const getSequence = require("./getSequence");2describe("An Array of Consecutive Numbers", () => {3 it("returns a correct array starting at 1", () => {4 expect(getSequence(1, 5)).toStrictEqual([1, 2, 3, 4, 5]);5 });67 it("returns a correct array starting at an arbitary number", () => {8 expect(getSequence(98, 100)).toStrictEqual([98, 99, 100]);9 });1011 it("returns a single array element if start and finish are the same", () => {12 expect(getSequence(1000, 1000)).toStrictEqual([1000]);13 });14});1516module.exports = getSequence;1718// describe("An Array of Consecutive Numbers", () => {19// it("returns a correct array starting at 1", () => {20// expect(getSequence(1, 5)).toBe([1, 2, 3, 4, 5]);21// });2223// it("returns a correct array starting at an arbitary number", () => {24// expect(getSequence(98, 100)).toBe([98, 99, 100]);25// });2627// it("returns a single array element if start and finish are the same", () => {28// expect(getSequence(1000, 1000)).toBe([1000]);29// });
...
CardPicker.js
Source:CardPicker.js
1export const getPickedCards = () => {2 return {3 mixed: getSequence("mixed"),4 glyphs: getSequence("glyphs"),5 numerals: getSequence("numerals"),6 lenses: getSequence("lenses"),7 };8};9const getSequence = (cardType) => {10 let range;11 switch (cardType) {12 case "glyphs":13 range = [1, 20];14 break;15 case "numerals":16 range = [21, 33];17 break;18 case "lenses":19 range = [34, 44];20 break;...
index.test.js
Source:index.test.js
1import getSequence from './index';2test('getSequence', () => {3 expect(getSequence(1000, 1000)).toEqual([1000]);4 expect(getSequence(0, 3)).toEqual([0, 1, 2, 3]);5 expect(getSequence(-100, -100)).toEqual([-100]);6 expect(getSequence(1, 5)).toEqual([1, 2, 3, 4, 5]);7 expect(getSequence(98, 100)).toEqual([98, 99, 100]);8 expect(getSequence(-10, 1)).toEqual([9 -10,10 -9,11 -8,12 -7,13 -6,14 -5,15 -4,16 -3,17 -2,18 -1,19 0,20 1,21 ]);22 expect(getSequence(1450, 1460)).toEqual([23 1450,24 1451,25 1452,26 1453,27 1454,28 1455,29 1456,30 1457,31 1458,32 1459,33 1460,34 ]);...
fibonacci.test.js
Source:fibonacci.test.js
1const { getSequence } = require("./fibonacci");2test("getSequence of 5 returns first 5 of fibonacci", () => {3 expect(getSequence(5)).toEqual([1, 1, 2, 3, 5]);4});5test("getSequence of 10 returns first 10 of fibonacci", () => {6 expect(getSequence(10)).toEqual([1, 1, 2, 3, 5, 8, 13, 21, 34, 55]);7});8test("getSequence of 20 returns first 20 of fibonacci", () => {9 const twentiethElement = getSequence(20)[19];10 expect(twentiethElement).toEqual(6765);...
Using AI Code Generation
1const { getSequence } = require('playwright-core/lib/server/frames');2const { chromium } = require('playwright-core');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const sequence = await getSequence(page.mainFrame());8 console.log(sequence);9})();10- [Playwright Internal API](
Using AI Code Generation
1const { getSequence } = require('playwright/lib/utils/sequence');2const sequence = getSequence();3console.log(sequence.next().value);4console.log(sequence.next().value);5console.log(sequence.next().value);6console.log(sequence.next().value);
Using AI Code Generation
1const { getSequence } = require('@playwright/test/lib/server/sequence');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: 'example.png' });8 await browser.close();9})();10const playwrightInternalApi = require('playwright-internal-api');11playwrightInternalApi.getSequence('test');12playwrightInternalApi.getSequence('test');13playwrightInternalApi.getSequenceNumber('test');14playwrightInternalApi.getSequenceNumberForTest('test');15playwrightInternalApi.getTestType('test');16playwrightInternalApi.getTestTypeForTest('test');
Using AI Code Generation
1const { getSequence } = require('playwright/lib/internal/recorder/recorderActions');2const { actionToProtocol } = require('playwright/lib/internal/recorder/protocol');3const { actions } = require('playwright/lib/internal/recorder/actions');4const { devices } = require('playwright/lib/server/deviceDescriptors');5const { chromium } = require('playwright');6(async () => {7 const browser = await chromium.launch();8 const context = await browser.newContext({9 });10 const page = await context.newPage();11 await page.click('#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input');12 await page.fill('#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input', 'playwright');13 await page.keyboard.press('Enter');14 await page.waitForSelector('text=Playwright');15 await page.click('text=Playwright');16 await page.waitForSelector('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast.');17 const sequence = getSequence(page, actions, actionToProtocol);18 console.log(JSON.stringify(sequence, null, 2));19 await browser.close();20})();21 {22 },23 {24 "selector": "#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input",25 },26 {27 "selector": "#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input",
Using AI Code Generation
1const { getSequence } = require('playwright/lib/server/sequenceNumberAllocator');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 console.log(getSequence());8 await browser.close();9})();
Using AI Code Generation
1const { getSequence } = require('@playwright/test/lib/utils/sequence');2const sequence = getSequence();3console.log(sequence);4Sequence {5}6- [Playwright GitHub](
Using AI Code Generation
1const { getSequence } = require('playwright/lib/utils/sequence');2const { sequence } = getSequence();3console.log(sequence);4const { getSequence } = require('playwright/lib/utils/sequence');5const { sequence } = getSequence();6const sequenceNumber = sequence();7console.log(sequenceNumber);8const { getSequenceNumber } = require('playwright/lib/utils/sequence');9const sequenceNumber = getSequenceNumber();10console.log(sequenceNumber);11const { setSequenceNumber } = require('playwright/lib/utils/sequence');12setSequenceNumber(5);13const { setTestType } = require('playwright/lib/utils/sequence');14setTestType('e2e');15const { getTestType } = require('playwright/lib/utils/sequence');16const testType = getTestType();17console.log(testType);
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!