Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix wms maps can't load when can't request default map service #1550

Merged
merged 3 commits into from
Jun 8, 2022

Conversation

junqiu-lei
Copy link
Member

@junqiu-lei junqiu-lei commented May 5, 2022

Signed-off-by: Junqiu Lei junqiu@amazon.com

Description

Fix the bug that users can't load their own map tiles service by custom WMS when the environment unable access to default maps service(VPC or air-gapped region).

Issues Resolved

#1506

Check List

  • New functionality includes testing.
    • All tests pass
      • yarn test:jest
      • yarn test:jest_integration
      • yarn test:ftr
  • Commits are signed per the DCO using --signoff

@junqiu-lei junqiu-lei requested a review from a team as a code owner May 5, 2022 17:53
@junqiu-lei junqiu-lei added the maps Issues or PRs related to the Maps Service label May 5, 2022
@tmarkley
Copy link
Contributor

tmarkley commented May 18, 2022

Hey @junqiu-lei thanks for the PR! Can you add tests for these changes as the checklist item New functionality includes testing. requests? Let us know if you need help with that.

@junqiu-lei
Copy link
Member Author

@tmarkley Thanks feedback, will add the test to PR.

@tmarkley
Copy link
Contributor

I also removed the ems client option

Are we documenting this anywhere? This seems like a breaking change.

@junqiu-lei
Copy link
Member Author

I also removed the ems client option

Are we documenting this anywhere? This seems like a breaking change.

I have talked with @kavilla about it. Currently we have two map client setting options, OpenSearchMapsClient(extended from EMSClient) and EMSClient, we don't think the EMSClient will need to be used in any case, so that here I removed EMSClient option on the map client setting. https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/maps_legacy/public/map/service_settings.js#L134-L147

@tmarkley
Copy link
Contributor

I also removed the ems client option

Are we documenting this anywhere? This seems like a breaking change.

I have talked with @kavilla about it. Currently we have two map client setting options, OpenSearchMapsClient(extended from EMSClient) and EMSClient, we don't think the EMSClient will need to be used in any case, so that here I removed EMSClient option on the map client setting. https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/maps_legacy/public/map/service_settings.js#L134-L147

@junqiu-lei what was discussed? Can those details be provided here in the open? Is there any documentation that requires an update?

@junqiu-lei
Copy link
Member Author

I also removed the ems client option

Are we documenting this anywhere? This seems like a breaking change.

I have talked with @kavilla about it. Currently we have two map client setting options, OpenSearchMapsClient(extended from EMSClient) and EMSClient, we don't think the EMSClient will need to be used in any case, so that here I removed EMSClient option on the map client setting. https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/maps_legacy/public/map/service_settings.js#L134-L147

@junqiu-lei what was discussed? Can those details be provided here in the open? Is there any documentation that requires an update?

Offline discussed with @tmarkley, I will update the PR to keep the EMS options there and only focus on wms maps load bug fix at no Internet condition.

@codecov-commenter
Copy link

codecov-commenter commented May 31, 2022

Codecov Report

Merging #1550 (42f877c) into main (b888cca) will decrease coverage by 0.00%.
The diff coverage is 4.54%.

@@            Coverage Diff             @@
##             main    #1550      +/-   ##
==========================================
- Coverage   68.08%   68.08%   -0.01%     
==========================================
  Files        3072     3072              
  Lines       59015    59027      +12     
  Branches     8924     8924              
==========================================
+ Hits        40183    40186       +3     
- Misses      16645    16655      +10     
+ Partials     2187     2186       -1     
Impacted Files Coverage Δ
...aps_legacy/public/common/opensearch_maps_client.js 0.00% <0.00%> (ø)
...plugins/maps_legacy/public/map/service_settings.js 1.62% <4.76%> (+0.72%) ⬆️
...ic/application/models/sense_editor/sense_editor.ts 64.88% <0.00%> (+0.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b888cca...42f877c. Read the comment docs.

@junqiu-lei junqiu-lei added the bug Something isn't working label May 31, 2022
@junqiu-lei junqiu-lei requested a review from ashwin-pc June 1, 2022 00:01
let serviceSettings;
let tileMapServices;

const expectedDefaultTmService = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can export and use the default setting described in opensearch_maps_client.ts instead of defining it again here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, updated.

@@ -87,6 +100,17 @@ describe('service_settings (FKA tile_map test)', function () {
return serviceSettings;
}

function makeServiceSettingsWhenUnableFetchMapsService(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, this is a mouthful. Cant we just modify makeServiceSettings to exit early for a failed request?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, updated it into makeServiceSettings

Comment on lines 310 to 311
let serviceSettings;
let tileMapServices;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Cant we just define these as consts inside the test case like the other tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, updated.

Comment on lines 23 to 25
// silently ignoring the exception and returning false.
return false;
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we changing the return value? I dont see this being used anywhere in this PR and this will default the return value of isEnabled to true in the case of an error. Is that expected?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is expected. When await this._fetchWithTimeout(this._manifestServiceUrl) fail to access our maps service(no-internet condition), it will make OpenSearchMapsClient isn't enabled, and down to use EMS client here, in this case, we can actually still use OpenSearchMapsClient rather than EMS client. And actually all our use cases can use OpenSearchMaps client.

@junqiu-lei junqiu-lei requested review from ashwin-pc and a team June 2, 2022 15:50
ashwin-pc
ashwin-pc previously approved these changes Jun 2, 2022
Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

describe('when unable to access OpenSearch maps service', function () {
const expectedDefaultTmService = DEFAULT_SERVICE[0];

async function assertObject(actual, expected) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This does not need to be an async function since you aren't awaiting anything inside it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, updated.

ashwin-pc
ashwin-pc previously approved these changes Jun 2, 2022
@junqiu-lei junqiu-lei requested a review from a team June 2, 2022 23:30
@@ -21,7 +21,7 @@ export class OpenSearchMapsClient extends EMSClient {
result = await this._fetchWithTimeout(this._manifestServiceUrl);
} catch (e) {
// silently ignoring the exception and returning false.
Copy link
Member

@ananzh ananzh Jun 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this comment be updated since the return value is changed and we are not ignoring the exceptions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, just updated.

@@ -59,15 +60,35 @@ describe('service_settings (FKA tile_map test)', function () {
},
};

const mapConfigWithFakeManifest = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if order is not important, maybe we could do

const mapConfigWithFakeManifest = {
    ...defaultMapConfig,
    emsFakeManifestApiUrl,
  };

to remove some duplications?

Copy link
Member

@ananzh ananzh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just nit stuff for comment and duplications

:shipit: found fail test and updated the review


describe('service_settings (FKA tile_map test)', function () {
const emsFileApiUrl = 'https://files.foobar';
const emsTileApiUrl = 'https://tiles.foobar';
const emsFakeManifestApiUrl = 'https://fakemapmanifest.foobar';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this URL is breaking the link checker. Can you either use an ignored URL from ./.lycheeexclude or add this there. Ideally using one from there is preferred.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, will update

@ananzh
Copy link
Member

ananzh commented Jun 3, 2022

Meanwhile, current yarn test:jest is not running this added unit test.

yarn test:jest /src/plugins/maps_legacy/public/map/service_settings.test.js
yarn run v1.22.19
$ node scripts/jest /src/plugins/maps_legacy/public/map/service_settings.test.js
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /home/ubuntu/work/other/OpenSearch-Dashboards
  7062 files checked.
  roots: /home/ubuntu/work/other/OpenSearch-Dashboards/src/plugins, /home/ubuntu/work/other/OpenSearch-Dashboards/src/legacy/ui, /home/ubuntu/work/other/OpenSearch-Dashboards/src/core, /home/ubuntu/work/other/OpenSearch-Dashboards/src/legacy/server, /home/ubuntu/work/other/OpenSearch-Dashboards/src/cli, /home/ubuntu/work/other/OpenSearch-Dashboards/src/cli_keystore, /home/ubuntu/work/other/OpenSearch-Dashboards/src/cli_plugin, /home/ubuntu/work/other/OpenSearch-Dashboards/packages/osd-test/target/functional_test_runner, /home/ubuntu/work/other/OpenSearch-Dashboards/src/dev, /home/ubuntu/work/other/OpenSearch-Dashboards/src/optimize, /home/ubuntu/work/other/OpenSearch-Dashboards/src/legacy/utils, /home/ubuntu/work/other/OpenSearch-Dashboards/src/setup_node_env, /home/ubuntu/work/other/OpenSearch-Dashboards/packages, /home/ubuntu/work/other/OpenSearch-Dashboards/src/test_utils, /home/ubuntu/work/other/OpenSearch-Dashboards/test/functional/services/remote - 7062 matches
  testMatch: **/*.test.{js,mjs,ts,tsx} - 1485 matches
  testPathIgnorePatterns: /home/ubuntu/work/other/OpenSearch-Dashboards/packages/osd-ui-framework/(dist)/, /home/ubuntu/work/other/OpenSearch-Dashboards/packages/osd-pm/dist/, integration_tests/ - 6998 matches
  testRegex:  - 0 matches
Pattern: /src/plugins/maps_legacy/public/map/service_settings.test.js - 0 matches
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The reason is due to this line
https://github.com/junqiu-lei/OpenSearch-Dashboards/blob/1caf90752d8e34ceece81d8a69f6ec79aabfa9c1/src/dev/jest/config.js#L81

@junqiu-lei you can remove this line and run the test. Below is the result:

yarn test:jest /src/plugins/maps_legacy/public/map/service_settings.test.js
yarn run v1.22.19
$ node scripts/jest /src/plugins/maps_legacy/public/map/service_settings.test.js
  console.error
    Error: Error: connect ECONNREFUSED 127.0.0.1:80
        at Object.dispatchError (/home/ubuntu/work/other/OpenSearch-Dashboards/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:63:19)
        at Request.<anonymous> (/home/ubuntu/work/other/OpenSearch-Dashboards/node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:655:18)
        at Request.emit (events.js:412:35)
        at ClientRequest.<anonymous> (/home/ubuntu/work/other/OpenSearch-Dashboards/node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:121:14)
        at ClientRequest.emit (events.js:400:28)
        at Socket.socketErrorListener (_http_client.js:475:9)
        at Socket.emit (events.js:400:28)
        at emitErrorNT (internal/streams/destroy.js:106:8)
        at emitErrorCloseNT (internal/streams/destroy.js:74:3)
        at processTicksAndRejections (internal/process/task_queues.js:82:21) undefined

      at VirtualConsole.<anonymous> (node_modules/jsdom/lib/jsdom/virtual-console.js:29:45)
      at Object.dispatchError (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:66:53)
      at Request.<anonymous> (node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:655:18)
      at ClientRequest.<anonymous> (node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:121:14)

  console.error
    Error: Error: connect ECONNREFUSED 127.0.0.1:80
        at Object.dispatchError (/home/ubuntu/work/other/OpenSearch-Dashboards/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:63:19)
        at Request.<anonymous> (/home/ubuntu/work/other/OpenSearch-Dashboards/node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:655:18)
        at Request.emit (events.js:412:35)
        at ClientRequest.<anonymous> (/home/ubuntu/work/other/OpenSearch-Dashboards/node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:121:14)
        at ClientRequest.emit (events.js:400:28)
        at Socket.socketErrorListener (_http_client.js:475:9)
        at Socket.emit (events.js:400:28)
        at emitErrorNT (internal/streams/destroy.js:106:8)
        at emitErrorCloseNT (internal/streams/destroy.js:74:3)
        at processTicksAndRejections (internal/process/task_queues.js:82:21) undefined

      at VirtualConsole.<anonymous> (node_modules/jsdom/lib/jsdom/virtual-console.js:29:45)
      at Object.dispatchError (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:66:53)
      at Request.<anonymous> (node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:655:18)
      at ClientRequest.<anonymous> (node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:121:14)

 FAIL  src/plugins/maps_legacy/public/map/service_settings.test.js
  service_settings (FKA tile_map test)
    TMS
      ✕ should NOT get url from the config (6 ms)
      ✕ should get url by resolving dynamically (1 ms)
      ✕ should get options (1 ms)
      modify - url
        ✕ accepts an object (11 ms)
        ✕ merged additions with previous values (1 ms)
        ✕ overwrites conflicting previous values (1 ms)
        ✓ should merge in tilemap url (3 ms)
        ✕ should load appropriate EMS attributes for desaturated and dark theme (1 ms)
        ✓ should exclude EMS (1 ms)
        ✓ should exclude all when not configured (1 ms)
      when unable to access OpenSearch maps service
        ✕ should return default service (57 ms)
    File layers
      ✕ should load manifest (all props) (3 ms)
      ✕ should load manifest (individual props) (1 ms)
      ✓ should exclude all when not configured (2 ms)
      ✕ should get hotlink (2 ms)
      ✕ should sanitize EMS attribution (2 ms)
      ✓ should return empty arr when unable fetch maps manifest (13 ms)
      ✓ should return null when unable fetch maps manifest (2 ms)

  ● service_settings (FKA tile_map test) › TMS › should NOT get url from the config

    TypeError: Cannot read property 'url' of undefined

      107 |       const tmsServices = await serviceSettings.getTMSServices();
      108 |       const tmsService = tmsServices[0];
    > 109 |       expect(typeof tmsService.url === 'undefined').toEqual(true);
          |                                ^
      110 |     });
      111 |
      112 |     it('should get url by resolving dynamically', async function () {

      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:109:32)

  ● service_settings (FKA tile_map test) › TMS › should get url by resolving dynamically

    TypeError: Cannot read property 'url' of undefined

      114 |       const tmsServices = await serviceSettings.getTMSServices();
      115 |       const tmsService = tmsServices[0];
    > 116 |       expect(typeof tmsService.url === 'undefined').toEqual(true);
          |                                ^
      117 |
      118 |       const attrs = await serviceSettings.getAttributesForTMSLayer(tmsService);
      119 |       expect(attrs.url.includes('{x}')).toEqual(true);

      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:116:32)

  ● service_settings (FKA tile_map test) › TMS › should get options

    TypeError: Cannot read property 'minZoom' of undefined

      135 |       const tmsServices = await serviceSettings.getTMSServices();
      136 |       const tmsService = tmsServices[0];
    > 137 |       expect(typeof tmsService.minZoom).toEqual('number');
          |                                ^
      138 |       expect(typeof tmsService.maxZoom).toEqual('number');
      139 |       expect(tmsService.attribution.includes('OpenStreetMap')).toEqual(true);
      140 |     });

      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:137:32)

  ● service_settings (FKA tile_map test) › TMS › modify - url › accepts an object

    TypeError: Cannot read property 'origin' of undefined

      284 |
      285 |   async getAttributesForTMSLayer(tmsServiceConfig, isDesaturated, isDarkMode) {
    > 286 |     if (tmsServiceConfig.origin === ORIGIN.EMS) {
          |                          ^
      287 |       return this._getAttributesForEMSTMSLayer(isDesaturated, isDarkMode);
      288 |     } else if (tmsServiceConfig.origin === ORIGIN.OPENSEARCH_DASHBOARDS_YML) {
      289 |       const attrs = _.pick(this._tilemapsConfig, ['url', 'minzoom', 'maxzoom', 'attribution']);

      at ServiceSettings.getAttributesForTMSLayer (src/plugins/maps_legacy/public/map/service_settings.js:286:26)
      at assertQuery (src/plugins/maps_legacy/public/map/service_settings.test.js:147:45)
      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:158:15)

  ● service_settings (FKA tile_map test) › TMS › modify - url › merged additions with previous values

    TypeError: Cannot read property 'origin' of undefined

      284 |
      285 |   async getAttributesForTMSLayer(tmsServiceConfig, isDesaturated, isDarkMode) {
    > 286 |     if (tmsServiceConfig.origin === ORIGIN.EMS) {
          |                          ^
      287 |       return this._getAttributesForEMSTMSLayer(isDesaturated, isDarkMode);
      288 |     } else if (tmsServiceConfig.origin === ORIGIN.OPENSEARCH_DASHBOARDS_YML) {
      289 |       const attrs = _.pick(this._tilemapsConfig, ['url', 'minzoom', 'maxzoom', 'attribution']);

      at ServiceSettings.getAttributesForTMSLayer (src/plugins/maps_legacy/public/map/service_settings.js:286:26)
      at assertQuery (src/plugins/maps_legacy/public/map/service_settings.test.js:147:45)
      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:167:15)

  ● service_settings (FKA tile_map test) › TMS › modify - url › overwrites conflicting previous values

    TypeError: Cannot read property 'origin' of undefined

      284 |
      285 |   async getAttributesForTMSLayer(tmsServiceConfig, isDesaturated, isDarkMode) {
    > 286 |     if (tmsServiceConfig.origin === ORIGIN.EMS) {
          |                          ^
      287 |       return this._getAttributesForEMSTMSLayer(isDesaturated, isDarkMode);
      288 |     } else if (tmsServiceConfig.origin === ORIGIN.OPENSEARCH_DASHBOARDS_YML) {
      289 |       const attrs = _.pick(this._tilemapsConfig, ['url', 'minzoom', 'maxzoom', 'attribution']);

      at ServiceSettings.getAttributesForTMSLayer (src/plugins/maps_legacy/public/map/service_settings.js:286:26)
      at assertQuery (src/plugins/maps_legacy/public/map/service_settings.test.js:147:45)
      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:177:15)

  ● service_settings (FKA tile_map test) › TMS › modify - url › should load appropriate EMS attributes for desaturated and dark theme

    TypeError: Cannot read property 'origin' of undefined

      284 |
      285 |   async getAttributesForTMSLayer(tmsServiceConfig, isDesaturated, isDarkMode) {
    > 286 |     if (tmsServiceConfig.origin === ORIGIN.EMS) {
          |                          ^
      287 |       return this._getAttributesForEMSTMSLayer(isDesaturated, isDarkMode);
      288 |     } else if (tmsServiceConfig.origin === ORIGIN.OPENSEARCH_DASHBOARDS_YML) {
      289 |       const attrs = _.pick(this._tilemapsConfig, ['url', 'minzoom', 'maxzoom', 'attribution']);

      at ServiceSettings.getAttributesForTMSLayer (src/plugins/maps_legacy/public/map/service_settings.js:286:26)
      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:225:57)

  ● service_settings (FKA tile_map test) › TMS › when unable to access OpenSearch maps service › should return default service

    TypeError: Cannot read property 'origin' of undefined

      302 |       function assertObject(actual, expected) {
      303 |         Object.keys(expected).forEach((key) => {
    > 304 |           expect(actual[key]).toEqual(expected[key]);
          |                        ^
      305 |         });
      306 |       }
      307 |

      at forEach (src/plugins/maps_legacy/public/map/service_settings.test.js:304:24)
          at Array.forEach (<anonymous>)
      at assertObject (src/plugins/maps_legacy/public/map/service_settings.test.js:303:31)
      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:312:15)

  ● service_settings (FKA tile_map test) › File layers › should load manifest (all props)

    expect(received).toEqual(expected) // deep equality

    Expected: 19
    Received: 0

      322 |       serviceSettings.setQueryParams({ foo: 'bar' });
      323 |       const fileLayers = await serviceSettings.getFileLayers();
    > 324 |       expect(fileLayers.length).toEqual(19);
          |                                 ^
      325 |       const assertions = fileLayers.map(async function (fileLayer) {
      326 |         expect(fileLayer.origin).toEqual(ORIGIN.EMS);
      327 |         const fileUrl = await serviceSettings.getUrlForRegionLayer(fileLayer);

      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:324:33)

  ● service_settings (FKA tile_map test) › File layers › should load manifest (individual props)

    TypeError: Cannot read property 'attribution' of undefined

      353 |       const actual = fileLayers[0];
      354 |
    > 355 |       expect(expected.attribution).toEqual(actual.attribution);
          |                                                   ^
      356 |       expect(expected.format).toEqual(actual.format);
      357 |       expect(expected.fields).toEqual(actual.fields);
      358 |       expect(expected.name).toEqual(actual.name);

      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:355:51)

  ● service_settings (FKA tile_map test) › File layers › should get hotlink

    expect(received).toEqual(expected) // deep equality

    Expected: "?locale=en#file/world_countries"
    Received: null

      374 |       const fileLayers = await serviceSettings.getFileLayers();
      375 |       const hotlink = await serviceSettings.getEMSHotLink(fileLayers[0]);
    > 376 |       expect(hotlink).toEqual('?locale=en#file/world_countries'); //url host undefined becuase emsLandingPageUrl is set at opensearch-dashboards-load
          |                       ^
      377 |     });
      378 |
      379 |     it('should sanitize EMS attribution', async () => {

      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:376:23)

  ● service_settings (FKA tile_map test) › File layers › should sanitize EMS attribution

    TypeError: Cannot read property 'attribution' of undefined

      383 |         return layer.id === 'world_countries_with_compromised_attribution';
      384 |       });
    > 385 |       expect(fileLayer.attribution).toEqual(
          |                        ^
      386 |         '<a rel="noreferrer noopener" href="http://www.naturalearthdata.com/about/terms-of-use">&lt;div onclick=\'alert(1\')&gt;Made with NaturalEarth&lt;/div&gt;</a> | <a rel="noreferrer noopener">OpenSearch Maps Service</a>'
      387 |       );
      388 |     });

      at Object.<anonymous> (src/plugins/maps_legacy/public/map/service_settings.test.js:385:24)

Test Suites: 1 failed, 1 total
Tests:       12 failed, 6 passed, 18 total
Snapshots:   0 total
Time:        1.593 s, estimated 2 s
Ran all test suites matching /\/src\/plugins\/maps_legacy\/public\/map\/service_settings.test.js/i.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I see multiple fail tests. I think most of them are not related to your PR and we could open another issue to fix them. But I do see the following new added test fails:

when unable to access OpenSearch maps service › should return default service

I think it is fair to fix this test in the current PR.

Copy link
Member

@ananzh ananzh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit test fail.

@junqiu-lei junqiu-lei force-pushed the wms-no-internet branch 2 times, most recently from e9bcd57 to b1bfb7e Compare June 3, 2022 07:18
@junqiu-lei
Copy link
Member Author

@ananzh Yes, current I will update this PR's unit test to pass and then we can create a new issue to fix other tests.

Copy link
Contributor

@tmarkley tmarkley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the improvements!

@junqiu-lei junqiu-lei merged commit b2cfb6e into opensearch-project:main Jun 8, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 8, 2022
* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)
tmarkley pushed a commit that referenced this pull request Jun 8, 2022
* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 8, 2022
* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 8, 2022
* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 8, 2022
* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)
kavilla pushed a commit to kavilla/OpenSearch-Dashboards-1 that referenced this pull request Jun 8, 2022
…ct#1550)

* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
kavilla pushed a commit to kavilla/OpenSearch-Dashboards-1 that referenced this pull request Jun 8, 2022
…ct#1550)

* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
tmarkley pushed a commit that referenced this pull request Jun 13, 2022
* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)
kavilla pushed a commit to kavilla/OpenSearch-Dashboards-1 that referenced this pull request Jun 16, 2022
…ct#1550)

* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
manasvinibs pushed a commit that referenced this pull request Jul 7, 2022
* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)
manasvinibs pushed a commit that referenced this pull request Jul 7, 2022
* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)
manasvinibs pushed a commit that referenced this pull request Jul 8, 2022
* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)
@junqiu-lei junqiu-lei deleted the wms-no-internet branch July 18, 2022 21:38
joshuarrrr pushed a commit that referenced this pull request Jul 27, 2022
* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)

Co-authored-by: Junqiu Lei <junqiu@amazon.com>
Co-authored-by: Kawika Avilla <kavilla414@gmail.com>
kavilla pushed a commit that referenced this pull request Aug 23, 2022
* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)

Co-authored-by: Junqiu Lei <junqiu@amazon.com>
pjfitzgibbons pushed a commit to pjfitzgibbons/OpenSearch-Dashboards that referenced this pull request Oct 24, 2022
…ct#1550) (opensearch-project#1707)

* Fix WMS can't load when unable access maps services

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit b2cfb6e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.3 backport 2.x bug Something isn't working maps Issues or PRs related to the Maps Service needs-documentation v1.3.4 v2.0.1 v2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants