Best Python code snippet using playwright-python
LaunchPage.qunit.js
Source:LaunchPage.qunit.js  
1// Copyright (c) 2009-2017 SAP SE, All Rights Reserved2/**3 * @fileOverview QUnit tests for sap.ushell.services.LaunchPage4 */5sap.ui.require([6    "sap/ushell/services/LaunchPage",7    "sap/ushell/test/utils",8    "sap/ushell/adapters/local/LaunchPageAdapter",9    "sap/ushell/Config",10    "sap/ushell/services/_ContentExtensionAdapterFactory/ContentExtensionAdapterConfig",11    "sap/ushell/services/_ContentExtensionAdapterFactory/FeaturedGroupConfig",12    "sap/ushell/resources"13], function (LaunchPage, testUtils, LaunchPageAdapter, Config, AdapterFactoryConfig, FeaturedGroupMock) {14    "use strict";15    /*global asyncTest, deepEqual, module, throws ok, start, strictEqual, test, sinon */16    var sUshellTestRootPath = jQuery.sap.getResourcePath("sap/ushell").replace("resources", "test-resources"),17        oLastStub,18        oGetMockAdapterConfigStub,19        oGetConfigAdaptersStub,20        oLaunchPageConfig = {21            config: {22                pathToLocalizedContentResources: sUshellTestRootPath + "/test/services/resources/resources.properties",23                groups: [{24                    id: "group_0",25                    title: "test_group1",26                    isPreset: true,27                    isVisible: true,28                    isGroupLocked: false,29                    tiles: [{30                        id: "9a6eb46c-2d10-3a37-90d8-8f49f60cb111",31                        title: "test_tile_header",32                        size: "1x1",33                        tileType: "sap.ushell.ui.tile.TileBase",34                        keywords: ["test_keywords"],35                        properties: {36                            chipId: "catalogTile_1",37                            title: "test_tile_header",38                            subtitle: "test_sub_tile_header",39                            infoState: "Neutral",40                            info: "test_info",41                            icon: "sap-icon://travel-expense-report",42                            targetURL: "#Action-todefaultapp",43                            formFactor: "Desktop,Tablet,Phone"44                        }45                    },46                        {47                            id: "tile_001",48                            title: "test_tile_preview_api",49                            size: "1x1",50                            tileType: "sap.ushell.ui.tile.TileBase",51                            keywords: ["test_keywords"],52                            properties: {53                                chipId: "catalogTile_1",54                                infoState: "Neutral",55                                info: "test_info",56                                formFactor: "Desktop,Tablet,Phone"57                            }58                        },59                        {60                            id: "tile_787",61                            tileType: "sap.ushell.ui.tile.StaticTile",62                            isLink: true,63                            properties: {64                                text: "I am a link!",65                                href: "#Action-todefaultapp"66                            }67                        },68                        {69                            id: "tile_777",70                            tileType: "sap.ushell.ui.tile.StaticTile",71                            isLink: true,72                            properties: {73                                text: "I am an external link!",74                                href: "http://www.google.com"75                            }76                        },77                        {78                            id: "tile_797",79                            tileType: "sap.ushell.ui.tile.StaticTile",80                            mode: "HeaderMode",81                            properties: {82                                title: "test_tile_header",83                                subtitle: "test_sub_tile_header"84                            }85                        },86                        {87                            id: "tile_807",88                            tileType: "sap.ushell.ui.tile.StaticTile",89                            mode: "ContentMode",90                            properties: {91                                title: "test_tile_header",92                                subtitle: "test_sub_tile_header"93                            }94                        }95                    ]96                }, {97                    id: "group_1",98                    title: "test_group2",99                    isPreset: true,100                    isVisible: true,101                    isGroupLocked: false,102                    tiles: [{}]103                }, {104                    id: "group_2",105                    title: "test_group3",106                    isPreset: true,107                    isVisible: true,108                    isGroupLocked: false,109                    tiles: [110                        {111                            id: "tile_102",112                            title: "Test component tile",113                            size: "1x1",114                            tileType: "sap.ushell.ui.tile.StaticTile",115                            moduleName: "sap.ushell.demo.demoTiles",116                            moduleType: "UIComponent",117                            namespace: "sap.ushell.demo.demoTiles",118                            path: sUshellTestRootPath + "/demoapps/demoTiles/",119                            properties: {120                                chipId: "catalogTile_38",121                                title: "Test component tile",122                                subtitle: "A tile wrapped in a component",123                                infoState: "Neutral",124                                info: "0 days running without bugs",125                                icon: "sap-icon://flight",126                                targetURL: "#Action-todefaultapp",127                                formFactor: "Desktop,Tablet"128                            }129                        },130                        {131                            id: "tile_103",132                            title: "Test view tile",133                            size: "1x1",134                            tileType: "sap.ushell.ui.tile.StaticTile",135                            moduleName: "sap.ushell.demo.demoTiles.TestViewTile",136                            moduleType: "JS",137                            namespace: "sap.ushell.demo.demoTiles",138                            path: sUshellTestRootPath + "/demoapps/demoTiles/",139                            properties: {140                                chipId: "catalogTile_38",141                                title: "Test view tile",142                                subtitle: "A tile wrapped in a view",143                                infoState: "Neutral",144                                info: "0 days running without bugs",145                                icon: "sap-icon://flight",146                                targetURL: "#Action-todefaultapp",147                                formFactor: "Desktop,Tablet"148                            }149                        }150                    ]151                }, {152                    id: "group_3",153                    title: "test_group4",154                    isPreset: true,155                    isVisible: true,156                    isGroupLocked: true,157                    tiles: [{}]158                }, {159                    id: "group_4",160                    title: "test_group5",161                    isPreset: true,162                    isVisible: false,163                    isGroupLocked: true,164                    tiles: [{}]165                }],166                catalogs: [167                    {168                        id: "test_catalog_01",169                        title: "test_catalog1",170                        tiles: [{}]171                    }, {172                        id: "test_catalog_02",173                        title: "test_catalog2",174                        tiles: [{}]175                    }176                ]177            }178        },179        aAdditionalAdapterConfig = [{180            name: "feature",181            adapter: "sap.ushell.adapters.local.LaunchPageAdapter",182            config: "/core/home/featuredGroup/enable",183            system: {184                alias: "",185                platform: "local"186            },187            configHandler: function () {188                var bEnableFrequentCard = true,189                    bEnableRecentCard = true;190                return FeaturedGroupMock.getMockAdapterConfig(bEnableFrequentCard, bEnableRecentCard);191            }192        }],193        oFeatureGroupConfig = {194            groups: [{195                "id": "featuredArea",196                "contentProvider": "feature",197                "isPersonalizationLocked": function () {198                    return true;199                },200                "getTitle": function () {201                    return "Featured";202                },203                "title": "Featured",204                "isFeatured": true,205                "isPreset": true,206                "isVisible": true,207                "isDefaultGroup": false,208                "isGroupLocked": true,209                "tiles": [{210                    "id": "tile_00",211                    "contentProvider": "feature",212                    "type": "recent",213                    "title": "[FEATURED] Sales Performance",214                    "text": "[FEATURED] Sales Performance",215                    "size": "1x1",216                    "tileType": "sap.ushell.ui.tile.DynamicTile",217                    "isLinkPersonalizationSupported": false,218                    "keywords": ["sales", "performance"],219                    "formFactor": "Desktop,Tablet,Phone",220                    "serviceRefreshInterval": 10,221                    "actions": [{222                        "text": "Go To Sample App",223                        "icon": "sap-icon://action",224                        "targetURL": "#Action-toappnavsample"225                    }, {226                        "text": "Go to stackoverflow",227                        "icon": "sap-icon://action",228                        "targetURL": "http://stackoverflow.com/"229                    }, {230                        "text": "Illigal URL",231                        "icon": "sap-icon://action",232                        "targetURL": "stackoverflow.com/"233                    }, {234                        "text": "Callback action",235                        "icon": "sap-icon://action-settings"236                    }],237                    "chipId": "catalogTile_33",238                    "properties": {239                        "title": "[FEATURED] Sales Performance",240                        "numberValue": 3.75,241                        "info": "Change to Last Month in %",242                        "numberFactor": "%",243                        "numberDigits": 2,244                        "numberState": "Positive",245                        "stateArrow": "Up",246                        "icon": "sap-icon://Fiori2/F0002",247                        "targetURL": "#Action-toappnavsample"248                    }249                }, {250                    "id": "tile_shelluiservicesample",251                    "contentProvider": "feature",252                    "type": "frequent",253                    "title": "[FEATURED] ShellUIService Sample App",254                    "size": "1x1",255                    "tileType": "sap.ushell.ui.tile.StaticTile",256                    "isLinkPersonalizationSupported": true,257                    "formFactor": "Desktop,Tablet",258                    "chipId": "catalogTile_45",259                    "properties": {260                        "title": "[FEATURED] Sample App for ShellUIService",261                        "text": "[FEATURED] Sample App for ShellUIService",262                        "subtitle": "",263                        "infoState": "Neutral",264                        "info": "#Action-toappshelluiservicesample",265                        "icon": "sap-icon://syringe",266                        "targetURL": "#Action-toappshelluiservicesample"267                    }268                }]269            }]270        };271    [272        {273            testDescription: "when enableFeaturedGroup is true",274            input: {275                enableFeaturedGroup: true276            },277            output: {278                numberOfFeaturedGroups: 1279            }280        },281        {282            testDescription: "when enableFeaturedGroup is false",283            input: {284                enableFeaturedGroup: false285            },286            output: {287                numberOfFeaturedGroups: 0288            }289        }290    ].forEach(function (oFixture) {291        module("sap.ushell.services.LaunchPage " + oFixture.testDescription, {292            beforeEach: function (assert) {293                oLastStub = sinon.stub(Config, 'last');294                oLastStub.withArgs("/core/spaces/enabled").returns(false);295                oLastStub.returns(oFixture.input.enableFeaturedGroup);296                oGetMockAdapterConfigStub = sinon.stub(FeaturedGroupMock, "getMockAdapterConfig").returns(297                    oFeatureGroupConfig298                );299                oGetConfigAdaptersStub = sinon.stub(AdapterFactoryConfig, "_getConfigAdapters").returns(300                    aAdditionalAdapterConfig301                );302            },303            teardown: function () {304                testUtils.restoreSpies(305                );306                oLastStub.restore();307                oGetMockAdapterConfigStub.restore();308                oGetConfigAdaptersStub.restore();309            }310        });311        test("addBookmark failures", function () {312            var oLaunchPageService = new LaunchPage();313            // code under test and tests314            throws(function () {315                oLaunchPageService.addBookmark();316            });317            throws(function () {318                oLaunchPageService.addBookmark("Test");319            });320            throws(function () {321                oLaunchPageService.addBookmark({});322            }, /Title missing in bookmark configuration/);323            throws(function () {324                oLaunchPageService.addBookmark({title: ""});325            }, /Title missing in bookmark configuration/);326            throws(function () {327                oLaunchPageService.addBookmark({title: "MyTitle"});328            }, /URL missing in bookmark configuration/);329        });330        test("addBookmark success", function () {331            var oActualPromise,332                oBookmarkConfig = { title: "MyTitle", url: "MyUrl" },333                oLaunchPageAdapter = {334                    addBookmark: sinon.stub().returns(new jQuery.Deferred().promise())335                },336                oLaunchPageService;337            // prepare test338            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);339            // code under test340            oActualPromise = oLaunchPageService.addBookmark(oBookmarkConfig);341            // test342            ok(oLaunchPageAdapter.addBookmark.calledOnce);343            ok(oLaunchPageAdapter.addBookmark.calledWith(oBookmarkConfig));344            strictEqual(oActualPromise, oLaunchPageAdapter.addBookmark.returnValues[0]);345        });346        test("setTileVisible", function () {347            var oTile = {},348                oLaunchPageAdapter = {349                    setTileVisible: sinon.spy()350                },351                oLaunchPageService;352            // prepare test353            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);354            // code under test355            oLaunchPageService.setTileVisible(oTile, true);356            // test357            ok(oLaunchPageAdapter.setTileVisible.calledOnce);358            ok(oLaunchPageAdapter.setTileVisible.calledWithExactly(oTile, true));359        });360        test("getCatalogError", function () {361            var oCatalog = {},362                oLaunchPageAdapter = {363                    getCatalogError: sinon.stub().returns("foo")364                },365                oLaunchPageService;366            // prepare test367            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);368            // code under test369            strictEqual(oLaunchPageService.getCatalogError(oCatalog), "foo");370            // test371            ok(oLaunchPageAdapter.getCatalogError.calledOnce);372            ok(oLaunchPageAdapter.getCatalogError.calledWithExactly(oCatalog));373        });374        test("isTileIntentSupported", function () {375            var oTile = {},376                oLaunchPageAdapter = {377                    isTileIntentSupported: sinon.stub().returns("foo") // deliberately no boolean378                },379                oLaunchPageService;380            // part 1: unsupported in adapter381            oLaunchPageService = new LaunchPage({});382            strictEqual(oLaunchPageService.isTileIntentSupported(oTile), true);383            // part 2: delegates to adapter384            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);385            strictEqual(oLaunchPageService.isTileIntentSupported(oTile), "foo");386            ok(oLaunchPageAdapter.isTileIntentSupported.calledOnce);387            ok(oLaunchPageAdapter.isTileIntentSupported.calledWithExactly(oTile));388        });389        test("getCardManifest", function () {390            var oCard = {},391                oLaunchPageAdapter = {392                    getCardManifest: sinon.stub().returns("Manifest")393                },394                oLaunchPageService;395            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);396            strictEqual(oLaunchPageService.getCardManifest(oCard), "Manifest");397            ok(oLaunchPageAdapter.getCardManifest.calledOnce);398            ok(oLaunchPageAdapter.getCardManifest.calledWithExactly(oCard));399        });400        test("isGroupVisible", function () {401            var oGroup = {},402                oLaunchPageAdapter = {403                    isGroupVisible: sinon.stub().returns("visible")404                },405                oLaunchPageService;406            // part 1: unsupported in adapter - default value received from the service directly407            oLaunchPageService = new LaunchPage({});408            strictEqual(oLaunchPageService.isGroupVisible(oGroup), true);409            // part 2: delegates to adapter410            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);411            strictEqual(oLaunchPageService.isGroupVisible(oGroup), "visible");412            ok(oLaunchPageAdapter.isGroupVisible.calledOnce);413            ok(oLaunchPageAdapter.isGroupVisible.calledWithExactly(oGroup));414        });415        test("isGroupLocked", function () {416            var oGroup = {},417                oLaunchPageAdapter = {418                    isGroupLocked: sinon.stub().returns("foo")419                },420                oLaunchPageService;421            // part 1: unsupported in adapter - default value received from the service directly422            oLaunchPageService = new LaunchPage({});423            strictEqual(oLaunchPageService.isGroupLocked(oGroup), false);424            // part 2: delegates to adapter425            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);426            strictEqual(oLaunchPageService.isGroupLocked(oGroup), "foo");427            ok(oLaunchPageAdapter.isGroupLocked.calledOnce);428            ok(oLaunchPageAdapter.isGroupLocked.calledWithExactly(oGroup));429        });430        test("hideGroups", function () {431            var aGroups = [],432                oLaunchPageAdapter = {433                    hideGroups: sinon.stub().returns({434                        fail: function (f) {},435                        done: function (f) { return this; }436                    })437                },438                oLaunchPageService;439            // part 1: unsupported in adapter - A deferred object is expected which is in failed status440            oLaunchPageService = new LaunchPage({});441            var oDeferred = oLaunchPageService.hideGroups([]);442            strictEqual(oDeferred.state(), "rejected");443            // part 2: delegates to adapter444            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);445            oLaunchPageService.hideGroups(aGroups);446            ok(oLaunchPageAdapter.hideGroups.calledOnce);447            ok(oLaunchPageAdapter.hideGroups.calledWithExactly(aGroups));448        });449        test("getCatalogData", function () {450            var oCatalog = {},451                oResult = {},452                oLaunchPageAdapter,453                oLaunchPageService,454                oLogMock = testUtils.createLogMock()455                    .filterComponent("sap.ushell.services.LaunchPage")456                    .warning("getCatalogData not implemented in adapter", null,457                        "sap.ushell.services.LaunchPage");458            // part 1: unsupported in adapter459            oLaunchPageService = new LaunchPage({460                getCatalogId: function (oCatalog0) {461                    strictEqual(oCatalog0, oCatalog);462                    return "foo";463                }464            });465            deepEqual(oLaunchPageService.getCatalogData(oCatalog), {id: "foo"});466            oLogMock.verify();467            // part 2: delegates to adapter468            oLaunchPageAdapter = {469                getCatalogData: sinon.stub().returns(oResult)470            };471            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);472            strictEqual(oLaunchPageService.getCatalogData(oCatalog), oResult);473            ok(oLaunchPageAdapter.getCatalogData.calledOnce);474            ok(oLaunchPageAdapter.getCatalogData.calledWithExactly(oCatalog));475        });476        test("test countBookmarks", function () {477            var oActualPromise,478                oExpectedPromise = (new jQuery.Deferred()).promise(),479                oLaunchPageAdapter = {480                    countBookmarks: sinon.stub().returns(oExpectedPromise)481                },482                oLaunchPageService;483            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);484            throws(function () {485                oLaunchPageService.countBookmarks();486            }, /Missing URL/);487            throws(function () {488                oLaunchPageService.countBookmarks("");489            }, /Missing URL/);490            throws(function () {491                oLaunchPageService.countBookmarks({});492            }, /Missing URL/);493            ok(oLaunchPageAdapter.countBookmarks.notCalled);494            oActualPromise = oLaunchPageService.countBookmarks("###");495            strictEqual(oActualPromise, oExpectedPromise);496            ok(oLaunchPageAdapter.countBookmarks.calledOnce);497            strictEqual(oLaunchPageAdapter.countBookmarks.args[0][0], "###");498        });499        test("test deleteBookmarks", function () {500            var oActualPromise,501                oExpectedPromise = (new jQuery.Deferred()).promise(),502                oLaunchPageAdapter = {503                    deleteBookmarks: sinon.stub().returns(oExpectedPromise)504                },505                oLaunchPageService;506            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);507            throws(function () {508                oLaunchPageService.deleteBookmarks();509            }, /Missing URL/);510            throws(function () {511                oLaunchPageService.deleteBookmarks("");512            }, /Missing URL/);513            throws(function () {514                oLaunchPageService.deleteBookmarks({});515            }, /Missing URL/);516            ok(oLaunchPageAdapter.deleteBookmarks.notCalled);517            oActualPromise = oLaunchPageService.deleteBookmarks("###");518            strictEqual(oActualPromise, oExpectedPromise);519            ok(oLaunchPageAdapter.deleteBookmarks.calledOnce);520            strictEqual(oLaunchPageAdapter.deleteBookmarks.args[0][0], "###");521        });522        test("test updateBookmarks", function () {523            var oActualPromise,524                oExpectedPromise = (new jQuery.Deferred()).promise(),525                oLaunchPageAdapter = {526                    updateBookmarks: sinon.stub().returns(oExpectedPromise)527                },528                oLaunchPageService,529                oParameters = {530                    url: "foo"531                };532            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);533            throws(function () {534                oLaunchPageService.updateBookmarks();535            }, /Missing URL/);536            throws(function () {537                oLaunchPageService.updateBookmarks("");538            }, /Missing URL/);539            throws(function () {540                oLaunchPageService.updateBookmarks({});541            }, /Missing URL/);542            throws(function () {543                oLaunchPageService.updateBookmarks("foo");544            }, /Missing parameters/);545            throws(function () {546                oLaunchPageService.updateBookmarks("foo", true);547            }, /Missing parameters/);548            ok(oLaunchPageAdapter.updateBookmarks.notCalled);549            oActualPromise = oLaunchPageService.updateBookmarks("###", oParameters);550            strictEqual(oActualPromise, oExpectedPromise);551            ok(oLaunchPageAdapter.updateBookmarks.calledOnce);552            strictEqual(oLaunchPageAdapter.updateBookmarks.args[0][0], "###");553            strictEqual(oLaunchPageAdapter.updateBookmarks.args[0][1], oParameters);554        });555        test("Tile actions", function () {556            var oTile = {},557                aInternalActions,558                aExternalActions1,559                aExternalActions2,560                oLaunchPageAdapter,561                oLaunchPageService;562            // part 1: no actions563            oLaunchPageAdapter = {};564            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);565            deepEqual(oLaunchPageService.getTileActions(oTile), []);566            // part 2: internal actions567            aInternalActions = [{text: "InternalAction1"}, {text: "InternalAction2"}];568            oLaunchPageAdapter = {569                getTileActions: sinon.stub().returns(aInternalActions)570            };571            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);572            deepEqual(oLaunchPageService.getTileActions(oTile), aInternalActions);573            ok(oLaunchPageAdapter.getTileActions.calledWithExactly(oTile));574            // part 3: external actions575            aExternalActions1 = [{text: "ExternalAction11"}, {text: "ExternalAction12"}];576            aExternalActions2 = [{text: "ExternalAction21"}, {text: "ExternalAction22"}];577            oLaunchPageAdapter = {};578            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);579            oLaunchPageService.registerTileActionsProvider(sinon.stub().returns(aExternalActions1));580            oLaunchPageService.registerTileActionsProvider(sinon.stub().returns(aExternalActions2));581            deepEqual(oLaunchPageService.getTileActions(oTile), aExternalActions1.concat(aExternalActions2));582            // part 4: internal and external actions583            aInternalActions = [{text: "InternalAction1"}, {text: "InternalAction2"}];584            oLaunchPageAdapter = {585                getTileActions: sinon.stub().returns(aInternalActions)586            };587            aExternalActions1 = [{text: "ExternalAction11"}, {text: "ExternalAction12"}];588            aExternalActions2 = [{text: "ExternalAction21"}, {text: "ExternalAction22"}];589            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);590            oLaunchPageService.registerTileActionsProvider(sinon.stub().returns(aExternalActions1));591            oLaunchPageService.registerTileActionsProvider(sinon.stub().returns(aExternalActions2));592            deepEqual(oLaunchPageService.getTileActions(oTile), aInternalActions.concat(aExternalActions1.concat(aExternalActions2)));593            ok(oLaunchPageAdapter.getTileActions.calledWithExactly(oTile));594        });595        test("getCatalogTileTargetURL", function () {596            var oLaunchPageService,597                sTargetUrl,598                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);599            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);600            // part 1: TargetUrl exist in configuration601            sTargetUrl = oLaunchPageService.getCatalogTileTargetURL(oLaunchPageConfig.config.groups[0].tiles[0]);602            strictEqual(sTargetUrl, oLaunchPageConfig.config.groups[0].tiles[0].properties.targetURL, "TargetUrl as expected");603            // part 2: TargetUrl does not exist in configuration604            sTargetUrl = oLaunchPageService.getCatalogTileTargetURL(oLaunchPageConfig.config.groups[0].tiles[1]);605            strictEqual(sTargetUrl, null, "TargetUrl default value is null");606        });607        test("getCatalogTilePreviewTitle", function () {608            var oLaunchPageService,609                sPreviewTitle,610                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);611            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);612            // part 1: Title exist in configuration613            sPreviewTitle = oLaunchPageService.getCatalogTilePreviewTitle(oLaunchPageConfig.config.groups[0].tiles[0]);614            strictEqual(sPreviewTitle, oLaunchPageConfig.config.groups[0].tiles[0].properties.title, "Preview title as expected");615            // part 2: Title does not exist in configuration616            sPreviewTitle = oLaunchPageService.getCatalogTilePreviewTitle(oLaunchPageConfig.config.groups[0].tiles[1]);617            strictEqual(sPreviewTitle, null, "Preview title default value is null");618        });619        test("getCatalogTilePreviewInfo", function () {620            // Arrange621            var oLaunchPageService,622                sPreviewInfo,623                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);624            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);625            // Act626            sPreviewInfo = oLaunchPageService.getCatalogTilePreviewInfo(oLaunchPageConfig.config.groups[0].tiles[0]);627            // Assert628            strictEqual(sPreviewInfo, oLaunchPageConfig.config.groups[0].tiles[0].properties.info, "The function getCatalogTilePreviewInfo returns the correct catalog tile preview info.");629        });630        test("getCatalogTilePreviewSubtitle", function () {631            var oLaunchPageService,632                sPreviewSubtitle,633                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);634            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);635            // part 1: Title exist in configuration636            sPreviewSubtitle = oLaunchPageService.getCatalogTilePreviewSubtitle(oLaunchPageConfig.config.groups[0].tiles[0]);637            strictEqual(sPreviewSubtitle, oLaunchPageConfig.config.groups[0].tiles[0].properties.subtitle, "Preview subtitle as expected");638            // part 2: Title does not exist in configuration639            sPreviewSubtitle = oLaunchPageService.getCatalogTilePreviewSubtitle(oLaunchPageConfig.config.groups[0].tiles[1]);640            strictEqual(sPreviewSubtitle, null, "Preview subtitle default value is null");641        });642        test("getCatalogTilePreviewIcon", function () {643            var oLaunchPageService,644                sPreviewIcon,645                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);646            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);647            // part 1: Title exist in configuration648            sPreviewIcon = oLaunchPageService.getCatalogTilePreviewIcon(oLaunchPageConfig.config.groups[0].tiles[0]);649            strictEqual(sPreviewIcon, oLaunchPageConfig.config.groups[0].tiles[0].properties.icon, "Preview icon as expected");650            // part 2: Title does not exist in configuration651            sPreviewIcon = oLaunchPageService.getCatalogTilePreviewIcon(oLaunchPageConfig.config.groups[0].tiles[1]);652            strictEqual(sPreviewIcon, null, "Preview icon default value is null");653        });654        asyncTest("getCatalogWithTranslation", function () {655            var oLaunchPageService,656            oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);657            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);658            oLaunchPageService.getCatalogs().done(function (aCatalogs) {659                start();660                strictEqual(aCatalogs[0].title, "Translated Catalog 1", "Correct catalog [0] title");661                strictEqual(aCatalogs[1].title, "Translated Catalog 2", "Correct catalog [1] title");662            });663        });664        asyncTest("getGroupsWithTranslation", function () {665            var oLaunchPageService,666                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);667            // part 1: unsupported in adapter668            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);669            oLaunchPageService.getGroups().done(function (aGroups) {670                start();671                strictEqual(aGroups[0].title, "Translated Group 1", "Group translation error for aGroups[0].title");672                strictEqual(aGroups[1].title, "Translated Group 2", "Group translation error for aGroups[1].title");673            });674        });675        asyncTest("getGroupsWithFeatureGroup", function () {676            var iNumFeaturedGroups,677                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig),678                oLaunchPageService = new LaunchPage(oLaunchPageAdapter);679                oLaunchPageService.getGroups().done(function (aGroups) {680                    start();681                    iNumFeaturedGroups = aGroups.filter(function (oGroup) {682                        return oGroup.contentProvider === "feature";683                    }).length;684                    strictEqual(iNumFeaturedGroups, oFixture.output.numberOfFeaturedGroups, "feature group loaded");685            });686        });687        asyncTest("getViewDataWithTranslation", function () {688            var oLaunchPageService,689                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);690            // part 1: unsupported in adapter691            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);692            oLaunchPageService.getTileView(oLaunchPageConfig.config.groups[0].tiles[0]).done(function (oView) {693                start();694                strictEqual(oView.getProperty("title"), "Translated Header title", "Translated title check");695                strictEqual(oView.getProperty("subtitle"), "Translated Sub Title", "Translated Sub Title");696                strictEqual(oView.getProperty("info"), "Translated Info", "Translated Info");697                strictEqual(oLaunchPageConfig.config.groups[0].tiles[0].keywords[0], "Translated Keyword", "Translated keywords");698            });699        });700        asyncTest("getViewForComponentTile", function () {701            var oLaunchPageService,702                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);703            // part 1: unsupported in adapter704            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);705            oLaunchPageService.getTileView(oLaunchPageConfig.config.groups[2].tiles[0]).done(function (oTileUI) {706                start();707                ok(oTileUI.getMetadata().getName() === "sap.ui.core.ComponentContainer", "Module path registered and Component wrapped with ComponentContainer");708            });709        });710        asyncTest("getViewForViewTileTile", function () {711            var oLaunchPageService,712                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);713            // part 1: unsupported in adapter714            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);715            oLaunchPageService.getTileView(oLaunchPageConfig.config.groups[2].tiles[1]).done(function (oTileUI) {716                start();717                ok(oTileUI.getMetadata().getName() === "sap.ui.core.mvc.JSView", "Modelu path registered and View tile retreived");718            });719        });720        asyncTest("getViewForHeaderModeTile", function () {721            var oLaunchPageService,722                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);723            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);724            oLaunchPageService.getTileView(oLaunchPageConfig.config.groups[0].tiles[4]).done(function (oTileUI) {725                start();726                ok(oTileUI.getProperty("mode") === "HeaderMode", "Tile is in Header Mode");727            });728        });729        asyncTest("getViewForContentModeTile", function () {730            var oLaunchPageService,731                oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig);732            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);733            oLaunchPageService.getTileView(oLaunchPageConfig.config.groups[0].tiles[5]).done(function (oTileUI) {734                start();735                ok(oTileUI.getProperty("mode") === "ContentMode", "Tile is in Content Mode");736            });737        });738        test("isLinkPersonalizationSupported", function () {739            var oTile = {},740                oLaunchPageAdapter = {741                    isLinkPersonalizationSupported: sinon.stub().returns(true)742                },743                oLaunchPageService;744            oLaunchPageService = new LaunchPage({});745            strictEqual(oLaunchPageService.isLinkPersonalizationSupported(oTile), false);746            oLaunchPageService = new LaunchPage(oLaunchPageAdapter);747            strictEqual(oLaunchPageService.isLinkPersonalizationSupported(oTile), true);748            ok(oLaunchPageAdapter.isLinkPersonalizationSupported.calledOnce);749            ok(oLaunchPageAdapter.isLinkPersonalizationSupported.calledWithExactly(oTile));750        });751        test("getCatalogTileView", function () {752            var oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig),753            oLaunchPageService = new LaunchPage(oLaunchPageAdapter),754            oTileData = {755                namespace: undefined,756                path: undefined,757                moduleType: undefined,758                tileType: "tileTypePart1.tileTypePart2.tileTypePart3",759                properties: {760                    title: "title",761                    subtitle: "subTitle",762                    info: "info",763                    targetURL: "#a-b"764                }765            },766            oView,767            oViewConstructor = function (oProps) {768                var oViewObject = {769                    oViewProperties: oProps770                };771                return oViewObject;772            },773            oHandleTilePressStub = sinon.stub(oLaunchPageAdapter, "_handleTilePress").returns({}),774            oApplyDynamicTileIfoStateStub = sinon.stub(oLaunchPageAdapter, "_applyDynamicTileIfoState").returns({}),775            oJQuaryRequireStub = sinon.stub(jQuery.sap, "require"),776            oJQuaryGetObjectStub = sinon.stub(jQuery.sap, "getObject").callsFake( function (sObjectPath) {777                if (sObjectPath === "tileTypePart1.tileTypePart2.tileTypePart3") {778                    return oViewConstructor;779                }780            }),781            oRiginalSapUiRequire = sap.ui.require;782            sap.ui.require = sinon.spy();783            oView = oLaunchPageService.getCatalogTileView(oTileData);784            ok(sap.ui.require.called, "sap.ui.require is called");785            ok(sap.ui.require.args[sap.ui.require.args.length - 1][0] === "tileTypePart1/tileTypePart2/tileTypePart3", "sap.ui.require called for the view path tileTypePart1/tileTypePart2/tileTypePart3");786            ok(oJQuaryGetObjectStub.calledTwice === true, "sap.ui.getObject calledTwice");787            ok(oJQuaryGetObjectStub.args[0][0] === "tileTypePart1.tileTypePart2.tileTypePart3", "1st call to sap.ui.getObject for tileTypePart1.tileTypePart2.tileTypePart3");788            ok(oJQuaryGetObjectStub.args[1][0] === "tileTypePart1.tileTypePart2.tileTypePart3", "2nd call to sap.ui.getObject for tileTypePart1.tileTypePart2.tileTypePart3");789            ok(oHandleTilePressStub.calledOnce === true, "_handleTilePressStub called once");790            ok(oApplyDynamicTileIfoStateStub.calledOnce === true, "_applyDynamicTileIfoState called once");791            ok(oView.oViewProperties.title === "title", "Returned view title is correct");792            sap.ui.require = oRiginalSapUiRequire;793            oJQuaryRequireStub.restore();794            oJQuaryGetObjectStub.restore();795            oHandleTilePressStub.restore();796            oApplyDynamicTileIfoStateStub.restore();797        });798        asyncTest("getCatalogTileViewControl", function () {799            var oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig),800                oLaunchPageService = new LaunchPage(oLaunchPageAdapter),801                oTileData = {802                    namespace: undefined,803                    path: undefined,804                    moduleType: undefined,805                    tileType: "tileTypePart1.tileTypePart2.tileTypePart3",806                    properties: {807                        title: "title",808                        subtitle: "subTitle",809                        info: "info",810                        targetURL: "#a-b"811                    }812                },813                oViewConstructor = function (oProps) {814                    var oViewObject = {815                        oViewProperties: oProps816                    };817                    return oViewObject;818                },819                oOrigRequire = sap.ui.require,820                oGetImageContentStub = sinon.stub(oLaunchPageAdapter, "_getImageContent").returns({821                    addStyleClass: function () {}822                }),823                oRequireStub = sinon.stub(sap.ui, "require").callsFake( function (aRequirePath, fCallback) {824                    fCallback(oViewConstructor);825                }),826                oHandleTilePressStub = sinon.stub(oLaunchPageAdapter, "_handleTilePress").returns({}),827                oApplyDynamicTileIfoState = sinon.stub(oLaunchPageAdapter, "_applyDynamicTileIfoState").returns({});828            oLaunchPageService.getCatalogTileViewControl(oTileData).done(function (oView) {829                start();830                ok(oRequireStub.callCount === 1, "sap.ui.require called");831                ok(oRequireStub.args[0][0][0] === "tileTypePart1/tileTypePart2/tileTypePart3", "sap.ui.require called for tileTypePart1/tileTypePart2/tileTypePart3");832                ok(oHandleTilePressStub.calledOnce === true, "_handleTilePressStub called once");833                ok(oApplyDynamicTileIfoState.calledOnce === true, "_applyDynamicTileIfoState called once");834                ok(oView.oViewProperties.title === "title", "Returned view title is correct");835                sap.ui.require = oOrigRequire;836                oGetImageContentStub.restore();837                oHandleTilePressStub.restore();838                oApplyDynamicTileIfoState.restore();839            });840        });841        test("getCatalogTileViewRedirect", function () {842            var oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig),843                oLaunchPageService = new LaunchPage(oLaunchPageAdapter),844                oGetCatalogTileViewStub;845            oLaunchPageAdapter.getCatalogTileViewControl = undefined;846            oGetCatalogTileViewStub = sinon.stub(oLaunchPageAdapter, "getCatalogTileView").returns({text: "viewText"});847            oLaunchPageService.getCatalogTileViewControl().done(function (obj) {848                ok(oLaunchPageAdapter.getCatalogTileView.calledOnce === true, "When adapter function getCatalogTileViewControl does not exist - getCatalogTileView is called");849                ok(obj.text === "viewText", "Correct returned object");850                oGetCatalogTileViewStub.restore();851            });852        });853    });854    asyncTest("getGroupsForBookmarks when part of the groups are locked or not visable", function () {855        var oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig),856        oLaunchPageService = new LaunchPage(oLaunchPageAdapter);857        oLaunchPageService.getGroupsForBookmarks().done(function (aGroups) {858            start();859            strictEqual(aGroups.length, 3, "groups were filtered correctly");860            strictEqual(aGroups[0].title, "My Home", "title was changed correctly");861        });862    });863    module("getGroups", function () {864        asyncTest("getGroups with pages enabled should return a promise resolving to an empty array",  function() {865            var oConfigStub = sinon.stub(Config, "last");866            oConfigStub.withArgs("/core/spaces/enabled").returns(true);867            var oLaunchPageAdapter = new LaunchPageAdapter(undefined, undefined, oLaunchPageConfig),868                oLaunchPageService = new LaunchPage(oLaunchPageAdapter);869            oLaunchPageService.getGroups().done(function (aGroups) {870                strictEqual(aGroups.length, 0, "an empty array is returned");871                start();872            });873        });874    });...index.js
Source:index.js  
1import Head from "next/head";2import Image from "next/image";3import styles from "../styles/Home.module.css";4import { ApolloClient, InMemoryCache, gql } from "@apollo/client";5export default function Home({ launches }) {6  return (7    <div className={styles.container}>8      <Head>9        <title>SpaceX launch Sequece</title>10        <meta name="description" content="Generated by create next app" />11        <link rel="icon" href="/favicon.ico" />12      </Head>13      <main className={styles.main}>14        <h1 className={styles.title}>15          Welcome to <a href="https://nextjs.org">Next.js!</a>16        </h1>17        <div className={styles.grid}>18          {launches.map((launch) => {19            return (20              <span key={launch.id} className={styles.card}>21                <a href={launch.links.video_link}>22                  <h3>{launch.mission_name}</h3>23                  <p>24                    <strong>Launch Date:</strong>{" "}25                    {new Date(launch.launch_date_local).toLocaleDateString(26                      "en-US"27                    )}28                  </p>29                  <Image30                    src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"31                    placeholder="blur"32                    blurDataURL="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"33                    height={100}34                    width={100}35                    quality={80}36                    alt={37                      launch.links.mission_patch38                        ? launch.links.mission_patch39                        : "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"40                    }41                  />42                  <br />43                </a>44                <a45                  href={launch.links.mission_patch}46                  target="_blank"47                  rel="noopener noreferrer"48                >49                  Open Image50                </a>51              </span>52            );53          })}54        </div>55      </main>56      <footer className={styles.footer}>57        <a58          href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"59          target="_blank"60          rel="noopener noreferrer"61        >62          Powered by{" "}63          <span className={styles.logo}>64            <Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />65          </span>66        </a>67      </footer>68    </div>69  );70}71export async function getStaticProps() {72  try {73    const client = new ApolloClient({74      uri: "https://api.spacex.land/graphql/",75      cache: new InMemoryCache(),76    });77    const { data } = await client.query({78      query: gql`79        query GetLaunches {80          launchesPast(limit: 10) {81            id82            mission_name83            launch_date_local84            launch_site {85              site_name_long86            }87            links {88              article_link89              video_link90              mission_patch91            }92            rocket {93              rocket_name94            }95          }96        }97      `,98    });99    // Code will go here100    return {101      props: {102        launches: data.launchesPast,103      },104    };105  } catch (error) {106    return {107      props: {108        launches: [109          {110            __typename: "Launch",111            id: "109",112            mission_name: "Starlink-15 (v1.0)",113            launch_date_local: "2020-10-24T11:31:00-04:00",114            launch_site: {115              __typename: "LaunchSite",116              site_name_long:117                "Cape Canaveral Air Force Station Space Launch Complex 40",118            },119            links: {120              __typename: "LaunchLinks",121              article_link: null,122              video_link: "https://youtu.be/J442-ti-Dhg",123              mission_patch: "https://images2.imgbox.com/d2/3b/bQaWiil0_o.png",124            },125            rocket: { __typename: "LaunchRocket", rocket_name: "Falcon 9" },126          },127          {128            __typename: "Launch",129            id: "108",130            mission_name: "Sentinel-6 Michael Freilich",131            launch_date_local: "2020-11-21T09:17:00-08:00",132            launch_site: {133              __typename: "LaunchSite",134              site_name_long:135                "Vandenberg Air Force Base Space Launch Complex 4E",136            },137            links: {138              __typename: "LaunchLinks",139              article_link:140                "https://spaceflightnow.com/2020/11/21/international-satellite-launches-to-extend-measurements-of-sea-level-rise/",141              video_link: "https://youtu.be/aVFPzTDCihQ",142              mission_patch: null,143            },144            rocket: { __typename: "LaunchRocket", rocket_name: "Falcon 9" },145          },146          {147            __typename: "Launch",148            id: "107",149            mission_name: "Crew-1",150            launch_date_local: "2020-11-15T19:27:00-05:00",151            launch_site: {152              __typename: "LaunchSite",153              site_name_long:154                "Kennedy Space Center Historic Launch Complex 39A",155            },156            links: {157              __typename: "LaunchLinks",158              article_link:159                "https://spaceflightnow.com/2020/11/16/astronauts-ride-spacex-crew-capsule-in-landmark-launch-for-commercial-spaceflight/",160              video_link: "https://youtu.be/bnChQbxLkkI",161              mission_patch: "https://i.imgur.com/t5R4BAQ.png",162            },163            rocket: { __typename: "LaunchRocket", rocket_name: "Falcon 9" },164          },165          {166            __typename: "Launch",167            id: "106",168            mission_name: "GPS III SV04 (Sacagawea)",169            launch_date_local: "2020-11-05T18:24:00-05:00",170            launch_site: {171              __typename: "LaunchSite",172              site_name_long:173                "Cape Canaveral Air Force Station Space Launch Complex 40",174            },175            links: {176              __typename: "LaunchLinks",177              article_link:178                "https://spaceflightnow.com/2020/11/06/spacex-launches-gps-navigation-satellite-from-cape-canaveral/",179              video_link: "https://youtu.be/wufXF5YKR1M",180              mission_patch: "https://i.imgur.com/Ehe9AgY.png",181            },182            rocket: { __typename: "LaunchRocket", rocket_name: "Falcon 9" },183          },184          {185            __typename: "Launch",186            id: "105",187            mission_name: "Starlink-14 (v1.0)",188            launch_date_local: "2020-10-24T11:31:00-04:00",189            launch_site: {190              __typename: "LaunchSite",191              site_name_long:192                "Cape Canaveral Air Force Station Space Launch Complex 40",193            },194            links: {195              __typename: "LaunchLinks",196              article_link:197                "https://spaceflightnow.com/2020/10/24/spacex-adds-another-60-satellites-to-starlink-network/",198              video_link: "https://youtu.be/2gbVgTxLgN0",199              mission_patch: "https://images2.imgbox.com/d2/3b/bQaWiil0_o.png",200            },201            rocket: { __typename: "LaunchRocket", rocket_name: "Falcon 9" },202          },203          {204            __typename: "Launch",205            id: "104",206            mission_name: "Starlink-13 (v1.0)",207            launch_date_local: "2020-10-18T08:25:00-04:00",208            launch_site: {209              __typename: "LaunchSite",210              site_name_long:211                "Kennedy Space Center Historic Launch Complex 39A",212            },213            links: {214              __typename: "LaunchLinks",215              article_link:216                "https://spaceflightnow.com/2020/10/18/spacex-launches-another-batch-of-starlink-satellites/",217              video_link: "https://youtu.be/UM8CDDAmp98",218              mission_patch: "https://images2.imgbox.com/d2/3b/bQaWiil0_o.png",219            },220            rocket: { __typename: "LaunchRocket", rocket_name: "Falcon 9" },221          },222          {223            __typename: "Launch",224            id: "103",225            mission_name: "Starlink-12 (v1.0)",226            launch_date_local: "2020-10-06T07:29:00-04:00",227            launch_site: {228              __typename: "LaunchSite",229              site_name_long:230                "Kennedy Space Center Historic Launch Complex 39A",231            },232            links: {233              __typename: "LaunchLinks",234              article_link: null,235              video_link: "https://youtu.be/8O8Z2yPyTnc",236              mission_patch: "https://images2.imgbox.com/d2/3b/bQaWiil0_o.png",237            },238            rocket: { __typename: "LaunchRocket", rocket_name: "Falcon 9" },239          },240          {241            __typename: "Launch",242            id: "102",243            mission_name: "Starlink-11 (v1.0)",244            launch_date_local: "2020-09-03T08:46:00-04:00",245            launch_site: {246              __typename: "LaunchSite",247              site_name_long:248                "Kennedy Space Center Historic Launch Complex 39A",249            },250            links: {251              __typename: "LaunchLinks",252              article_link: null,253              video_link: "https://youtu.be/_j4xR7LMCGY",254              mission_patch: "https://images2.imgbox.com/d2/3b/bQaWiil0_o.png",255            },256            rocket: { __typename: "LaunchRocket", rocket_name: "Falcon 9" },257          },258          {259            __typename: "Launch",260            id: "101",261            mission_name: "SAOCOM 1B, GNOMES-1, Tyvak-0172",262            launch_date_local: "2020-08-30T19:18:00-04:00",263            launch_site: {264              __typename: "LaunchSite",265              site_name_long:266                "Cape Canaveral Air Force Station Space Launch Complex 40",267            },268            links: {269              __typename: "LaunchLinks",270              article_link:271                "https://spaceflightnow.com/2020/08/31/spacex-launches-first-polar-orbit-mission-from-florida-in-decades/",272              video_link: "https://youtu.be/P-gLOsDjE3E",273              mission_patch: "https://images2.imgbox.com/43/33/36WPntCu_o.png",274            },275            rocket: { __typename: "LaunchRocket", rocket_name: "Falcon 9" },276          },277          {278            __typename: "Launch",279            id: "100",280            mission_name: "Starlink-10 (v1.0) & SkySat 19-21",281            launch_date_local: "2020-08-18T10:31:00-04:00",282            launch_site: {283              __typename: "LaunchSite",284              site_name_long:285                "Cape Canaveral Air Force Station Space Launch Complex 40",286            },287            links: {288              __typename: "LaunchLinks",289              article_link:290                "https://spaceflightnow.com/2020/08/18/spacex-adds-more-satellites-to-ever-growing-starlink-network/",291              video_link: "https://youtu.be/jTMJK7wb0rM",292              mission_patch: "https://images2.imgbox.com/d2/3b/bQaWiil0_o.png",293            },294            rocket: { __typename: "LaunchRocket", rocket_name: "Falcon 9" },295          },296        ],297      },298    };299  }...LaunchUIComponent.js
Source:LaunchUIComponent.js  
1'use strict';2Object.defineProperty(exports, "__esModule", {3  value: true4});5exports.LaunchUIComponent = undefined;6var _string;7function _load_string() {8  return _string = require('nuclide-commons/string');9}10var _react = _interopRequireDefault(require('react'));11var _AtomInput;12function _load_AtomInput() {13  return _AtomInput = require('nuclide-commons-ui/AtomInput');14}15var _UniversalDisposable;16function _load_UniversalDisposable() {17  return _UniversalDisposable = _interopRequireDefault(require('nuclide-commons/UniversalDisposable'));18}19var _nuclideUri;20function _load_nuclideUri() {21  return _nuclideUri = _interopRequireDefault(require('nuclide-commons/nuclideUri'));22}23var _nuclideDebuggerBase;24function _load_nuclideDebuggerBase() {25  return _nuclideDebuggerBase = require('../../nuclide-debugger-base');26}27var _classnames;28function _load_classnames() {29  return _classnames = _interopRequireDefault(require('classnames'));30}31function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }32class LaunchUIComponent extends _react.default.Component {33  constructor(props) {34    super(props);35    this._handleLaunchClick = () => {36      // TODO: perform some validation for the input.37      const launchExecutable = this.refs.launchExecutable.getText().trim();38      const coreDump = this.refs.coreDump.getText().trim();39      const launchArguments = (0, (_string || _load_string()).shellParse)(this.refs.launchArguments.getText());40      const launchEnvironmentVariables = (0, (_string || _load_string()).shellParse)(this.refs.launchEnvironmentVariables.getText());41      const launchWorkingDirectory = this.refs.launchWorkingDirectory.getText().trim();42      const stdinFilePath = this.refs.stdinFilePath.getText().trim();43      const launchTarget = {44        executablePath: launchExecutable,45        arguments: launchArguments,46        environmentVariables: launchEnvironmentVariables,47        workingDirectory: launchWorkingDirectory,48        stdinFilePath,49        coreDump50      };51      // Fire and forget.52      this.props.actions.launchDebugger(launchTarget);53      (0, (_nuclideDebuggerBase || _load_nuclideDebuggerBase()).serializeDebuggerConfig)(...this._getSerializationArgs(), {54        launchExecutable: this.state.launchExecutable,55        launchArguments: this.state.launchArguments,56        launchEnvironmentVariables: this.state.launchEnvironmentVariables,57        launchWorkingDirectory: this.state.launchWorkingDirectory,58        stdinFilePath: this.state.stdinFilePath,59        coreDump: this.state.coreDump60      });61    };62    this._disposables = new (_UniversalDisposable || _load_UniversalDisposable()).default();63    this.state = {64      launchExecutable: '',65      launchArguments: '',66      launchEnvironmentVariables: '',67      launchWorkingDirectory: '',68      stdinFilePath: '',69      coreDump: ''70    };71  }72  _getSerializationArgs() {73    return [(_nuclideUri || _load_nuclideUri()).default.isRemote(this.props.targetUri) ? (_nuclideUri || _load_nuclideUri()).default.getHostname(this.props.targetUri) : 'local', 'launch', 'native'];74  }75  setState(newState) {76    super.setState(newState);77    this.props.configIsValidChanged(this._debugButtonShouldEnable());78  }79  _debugButtonShouldEnable() {80    return true;81  }82  componentDidMount() {83    (0, (_nuclideDebuggerBase || _load_nuclideDebuggerBase()).deserializeDebuggerConfig)(...this._getSerializationArgs(), (transientSettings, savedSettings) => {84      this.setState({85        launchExecutable: savedSettings.launchExecutable,86        launchArguments: savedSettings.launchArguments,87        launchEnvironmentVariables: savedSettings.launchEnvironmentVariables,88        launchWorkingDirectory: savedSettings.launchWorkingDirectory,89        stdinFilePath: savedSettings.stdinFilePath,90        coreDump: savedSettings.coreDump || ''91      });92    });93    const launchExecutableInput = this.refs.launchExecutable;94    if (launchExecutableInput != null) {95      launchExecutableInput.focus();96    }97    this._disposables.add(atom.commands.add('atom-workspace', {98      'core:confirm': () => {99        this._handleLaunchClick();100      }101    }));102    this.props.configIsValidChanged(true);103  }104  componentWillUnmount() {105    this._disposables.dispose();106  }107  render() {108    // TODO: smart fill the working directory textbox.109    // TODO: make tab stop between textbox work.110    // Reserve tabIndex [1~10] to header portion of the UI so we start from "11" here.111    return _react.default.createElement(112      'div',113      { className: 'block' },114      _react.default.createElement(115        'label',116        null,117        'Executable: '118      ),119      _react.default.createElement((_AtomInput || _load_AtomInput()).AtomInput, {120        ref: 'launchExecutable',121        tabIndex: '11',122        placeholderText: 'Input the executable path you want to launch',123        value: this.state.launchExecutable,124        onDidChange: value => this.setState({ launchExecutable: value })125      }),126      _react.default.createElement(127        'label',128        null,129        'Core dump file: '130      ),131      _react.default.createElement((_AtomInput || _load_AtomInput()).AtomInput, {132        ref: 'coreDump',133        tabIndex: '12',134        placeholderText: 'Optional path to a core dump file to offline debug a crash',135        value: this.state.coreDump,136        onDidChange: value => this.setState({ coreDump: value })137      }),138      _react.default.createElement(139        'div',140        { className: 'nuclide-native-launch-small-text' },141        'Be sure to copy the core dump to a location where Nuclide has read access. (Nuclide server does not run as root).'142      ),143      _react.default.createElement(144        'div',145        {146          className: (0, (_classnames || _load_classnames()).default)({147            'nuclide-native-launch-disabled': this.state.coreDump !== ''148          }) },149        _react.default.createElement(150          'label',151          null,152          'Arguments: '153        ),154        _react.default.createElement((_AtomInput || _load_AtomInput()).AtomInput, {155          ref: 'launchArguments',156          tabIndex: '13',157          disabled: this.state.coreDump !== '',158          placeholderText: 'Arguments to the executable',159          value: this.state.launchArguments,160          onDidChange: value => this.setState({ launchArguments: value })161        }),162        _react.default.createElement(163          'label',164          null,165          'Environment Variables: '166        ),167        _react.default.createElement((_AtomInput || _load_AtomInput()).AtomInput, {168          ref: 'launchEnvironmentVariables',169          tabIndex: '14',170          disabled: this.state.coreDump !== '',171          placeholderText: 'Environment variables (e.g., SHELL=/bin/bash PATH=/bin)',172          value: this.state.launchEnvironmentVariables,173          onDidChange: value => this.setState({ launchEnvironmentVariables: value })174        }),175        _react.default.createElement(176          'label',177          null,178          'Working directory: '179        ),180        _react.default.createElement((_AtomInput || _load_AtomInput()).AtomInput, {181          ref: 'launchWorkingDirectory',182          tabIndex: '15',183          disabled: this.state.coreDump !== '',184          placeholderText: 'Working directory for the launched executable',185          value: this.state.launchWorkingDirectory,186          onDidChange: value => this.setState({ launchWorkingDirectory: value })187        }),188        _react.default.createElement(189          'label',190          null,191          'Stdin file: '192        ),193        _react.default.createElement((_AtomInput || _load_AtomInput()).AtomInput, {194          ref: 'stdinFilePath',195          tabIndex: '16',196          disabled: this.state.coreDump !== '',197          placeholderText: 'Redirect stdin to this file',198          value: this.state.stdinFilePath,199          onDidChange: value => this.setState({ stdinFilePath: value })200        })201      )202    );203  }204}205exports.LaunchUIComponent = LaunchUIComponent; /**206                                                * Copyright (c) 2015-present, Facebook, Inc.207                                                * All rights reserved.208                                                *209                                                * This source code is licensed under the license found in the LICENSE file in210                                                * the root directory of this source tree.211                                                *212                                                * 213                                                * @format...pc-launch-filter.js
Source:pc-launch-filter.js  
1// Filter Phone2document.getElementById("phone-label").addEventListener("click", function (event) {3    //if()4    var list = document.getElementsByClassName('phone-call-tag');5    for (var i = 0; i < list.length; i++) {6        list[i].style.display = 'none';7    }8});9// Filter Phone10document.getElementById("phone-label").addEventListener("click", function (event) {11    //if()12    $("li.phone-call-tag").not("")13});14// Filter Chat15document.getElementById("chat-label").addEventListener("click", function (event) {16    //if()17    var list = document.getElementsByClassName('chat-tag');18    for (var i = 0; i < list.length; i++) {19        list[i].style.display = 'none';20    }21});22// Filter Email23document.getElementById("email-label").addEventListener("click", function (event) {24    //if()25    var list = document.getElementsByClassName('email-tag');26    for (var i = 0; i < list.length; i++) {27        list[i].style.display = 'none';28    }29});30// Filter SMS31document.getElementById("sms-label").addEventListener("click", function (event) {32    //if()33    var list = document.getElementsByClassName('sms-tag');34    for (var i = 0; i < list.length; i++) {35        list[i].style.display = 'none';36    }37});38// Filter DFO39document.getElementById("dfo-label").addEventListener("click", function (event) {40    //if()41    var list = document.getElementsByClassName('dfo-tag');42    for (var i = 0; i < list.length; i++) {43        list[i].style.display = 'none';44    }45});46// Sidebar Reporting View47$('#Reporting-View').on('click', function (e) {48    if ($("div#launch-chats").closest(".email-app-details").hasClass('show')) {49        $("div#launch-chats").closest(".email-app-details").toggleClass('show');50    } else if ($("div#launch-emails").closest(".email-app-details").hasClass('show')) {51        $("div#launch-emails").closest(".email-app-details").toggleClass('show');52    } else if ($("div#launch-sms").closest(".email-app-details").hasClass('show')) {53        $("div#launch-sms").closest(".email-app-details").toggleClass('show');54    } else if ($("div#launch-dfo").closest(".email-app-details").hasClass('show')) {55        $("div#launch-dfo").closest(".email-app-details").toggleClass('show');56    } else if ($("div#launch-phone-call").closest(".email-app-details").hasClass('show')) {57        $("div#launch-phone-call").closest(".email-app-details").toggleClass('show');58    }else {59        60    }61    62});63// Sidebar Phone64$('#phone-launch-btn').on('click', function (e) {65    if ($("div#launch-chats").closest(".email-app-details").hasClass('show')) {66        $("div#launch-chats").closest(".email-app-details").toggleClass('show');67    } else if ($("div#launch-emails").closest(".email-app-details").hasClass('show')) {68        $("div#launch-emails").closest(".email-app-details").toggleClass('show');69    } else if ($("div#launch-sms").closest(".email-app-details").hasClass('show')) {70        $("div#launch-sms").closest(".email-app-details").toggleClass('show');71    } else if ($("div#launch-dfo").closest(".email-app-details").hasClass('show')) {72        $("div#launch-dfo").closest(".email-app-details").toggleClass('show');73    } else {74    $("div#launch-phone-call").closest(".email-app-details").toggleClass('show');75    }76});77// Sidebar Chat78$('#chat-launch-btn').on('click', function (e) {79    if ($("div#launch-phone-call").closest(".email-app-details").hasClass('show')) {80        $("div#launch-phone-call").closest(".email-app-details").toggleClass('show');81    } else if ($("div#launch-emails").closest(".email-app-details").hasClass('show')) {82        $("div#launch-emails").closest(".email-app-details").toggleClass('show');83    } else if ($("div#launch-sms").closest(".email-app-details").hasClass('show')) {84        $("div#launch-sms").closest(".email-app-details").toggleClass('show');85    } else if ($("div#launch-dfo").closest(".email-app-details").hasClass('show')) {86        $("div#launch-dfo").closest(".email-app-details").toggleClass('show');87    }88    $("div#launch-chats").closest(".email-app-details").toggleClass('show');89});90// Sidebar Email91$('#email-launch-btn').on('click', function (e) {92    if ($("div#launch-phone-call").closest(".email-app-details").hasClass('show')) {93        $("div#launch-phone-call").closest(".email-app-details").toggleClass('show');94    } else if ($("div#launch-chats").closest(".email-app-details").hasClass('show')) {95        $("div#launch-chats").closest(".email-app-details").toggleClass('show');96    } else if ($("div#launch-chats").closest(".email-app-details").hasClass('show')) {97        $("div#launch-chats").closest(".email-app-details").toggleClass('show');98    } else if ($("div#launch-sms").closest(".email-app-details").hasClass('show')) {99        $("div#launch-sms").closest(".email-app-details").toggleClass('show');100    } else if ($("div#launch-dfo").closest(".email-app-details").hasClass('show')) {101        $("div#launch-dfo").closest(".email-app-details").toggleClass('show');102    }103    $("div#launch-emails").closest(".email-app-details").toggleClass('show');104});105// Sidebar SMS106$('#sms-launch-btn').on('click', function (e) {107    if ($("div#launch-phone-call").closest(".email-app-details").hasClass('show')) {108        $("div#launch-phone-call").closest(".email-app-details").toggleClass('show');109    } else if ($("div#launch-chats").closest(".email-app-details").hasClass('show')) {110        $("div#launch-chats").closest(".email-app-details").toggleClass('show');111    } else if ($("div#launch-chats").closest(".email-app-details").hasClass('show')) {112        $("div#launch-chats").closest(".email-app-details").toggleClass('show');113    } else if ($("div#launch-emails").closest(".email-app-details").hasClass('show')) {114        $("div#launch-emails").closest(".email-app-details").toggleClass('show');115    } else if ($("div#launch-dfo").closest(".email-app-details").hasClass('show')) {116        $("div#launch-dfo").closest(".email-app-details").toggleClass('show');117    }118    $("div#launch-sms").closest(".email-app-details").toggleClass('show');119});120// Sidebar DFO121$('#dfo-launch-btn').on('click', function (e) {122    if ($("div#launch-phone-call").closest(".email-app-details").hasClass('show')) {123        $("div#launch-phone-call").closest(".email-app-details").toggleClass('show');124    } else if ($("div#launch-chats").closest(".email-app-details").hasClass('show')) {125        $("div#launch-chats").closest(".email-app-details").toggleClass('show');126    } else if ($("div#launch-chats").closest(".email-app-details").hasClass('show')) {127        $("div#launch-chats").closest(".email-app-details").toggleClass('show');128    } else if ($("div#launch-emails").closest(".email-app-details").hasClass('show')) {129        $("div#launch-emails").closest(".email-app-details").toggleClass('show');130    } else if ($("div#launch-sms").closest(".email-app-details").hasClass('show')) {131        $("div#launch-sms").closest(".email-app-details").toggleClass('show');132    }133    $("div#launch-dfo").closest(".email-app-details").toggleClass('show');134    // Math for current time135    var d = new Date();136    var ampm = d.getHours >= 12 ? 'am' : 'pm';137    var b12 = d.getHours();138    var a12 = d.getHours() - 12;139    var hours = d.getHours >= 12 ? b12 : a12;140    // Math for current date141    var currentDay = d.getDate();142    var currentMonth = d.toLocaleString('default', {143        month: 'long'144    });145    var currentYear = d.getFullYear();146    // Display current time147    document.getElementById("currentTime").innerHTML = hours + ":" + d.getMinutes() + " " + ampm;148    document.getElementById("currentDate").innerHTML = currentDay + " " + currentMonth + " " + currentYear;149});150// MailTo Email151$("button#email-submit").on("click", function() {152    var toAddress = $("input#emailTo").val();153    var eSubject = $("input#emailSubject").val();154    var eCC = $("input#emailCC").val();155    var eBody = $("div#emailBody").val();156    $(".email-submit").attr("onClick", "mailTo:" + toAddress + "?cc=" + eCC + "&" + eSubject);157    console.log("did this work?");158});159$("button#refreshButton").on("click", function(){160    window.location.reload();...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!!
