From e5224fb132127862cb800e6e03fa7205def989b3 Mon Sep 17 00:00:00 2001 From: qiwei Date: Mon, 8 Apr 2024 21:24:44 +0800 Subject: [PATCH] fix webprint ut --- test/common/iServer/WebPrintingServiceSpec.js | 70 +++++++++++++------ test/resources/WebPrintingJobService.js | 46 ++++++++++++ 2 files changed, 96 insertions(+), 20 deletions(-) diff --git a/test/common/iServer/WebPrintingServiceSpec.js b/test/common/iServer/WebPrintingServiceSpec.js index 9a76b35632..72e5b02650 100644 --- a/test/common/iServer/WebPrintingServiceSpec.js +++ b/test/common/iServer/WebPrintingServiceSpec.js @@ -1,29 +1,59 @@ -import {WebPrintingService} from '../../../src/common/iServer/WebPrintingService'; +import { WebPrintingService } from '../../../src/common/iServer/WebPrintingService'; +import { FetchRequest } from '../../../src/common/util/FetchRequest'; var url = GlobeParameter.webPrintingURL; var initWebPringtingService = () => { - return new WebPrintingService(url); + return new WebPrintingService(url); } describe('WebPrintingService', () => { - it("constructor", () => { - var webPrintingService = initWebPringtingService(); - expect(webPrintingService).not.toBeNull(); - expect(webPrintingService.url).toEqual(url); - }); + it("constructor", () => { + var webPrintingService = initWebPringtingService(); + expect(webPrintingService).not.toBeNull(); + expect(webPrintingService.url).toEqual(url); + }); - it('headers', () => { - let myHeaders = new Headers(); - var webPrintingService = new WebPrintingService(url, { headers: myHeaders }); - expect(webPrintingService).not.toBeNull(); - expect(webPrintingService.headers).not.toBeNull(); - webPrintingService.destroy(); - }); + it('headers', () => { + let myHeaders = new Headers(); + var webPrintingService = new WebPrintingService(url, { headers: myHeaders }); + expect(webPrintingService).not.toBeNull(); + expect(webPrintingService.headers).not.toBeNull(); + webPrintingService.destroy(); + }); - it('crossOrigin', () => { - var webPrintingService = new WebPrintingService(url, { crossOrigin: false }); - expect(webPrintingService).not.toBeNull(); - expect(webPrintingService.crossOrigin).toBeFalsy(); - webPrintingService.destroy(); - }); + it('crossOrigin', () => { + var webPrintingService = new WebPrintingService(url, { crossOrigin: false }); + expect(webPrintingService).not.toBeNull(); + expect(webPrintingService.crossOrigin).toBeFalsy(); + webPrintingService.destroy(); + }); + it('running status not trigger callback', (done) => { + var count = 0; + var webPrintingService = new WebPrintingService(url, { crossOrigin: false }); + var jobId = 'e3ff26fa-a0b5-46d3-ad4a-096611a59c03@9fd5defe-d77d-4e17-967e-643c4f34d67e'; + spyOn(FetchRequest, 'commit').and.callFake((method, testUrl) => { + count++; + expect(method).toBe('GET'); + expect(testUrl).toBe(url + `/jobs/${jobId}`); + if (count === 3) { + return Promise.resolve(new Response(JSON.stringify(getPrintingJobResultJson))); + } + return Promise.resolve(new Response(JSON.stringify(getPrintingJobRunningJson))); + }); + webPrintingService.getPrintingJob(jobId, (result) => { + var serviceResult = result; + try { + expect(serviceResult).not.toBeNull(); + expect(serviceResult.type).toBe('processCompleted'); + expect(serviceResult.result).not.toBeNull(); + expect(serviceResult.result.id).toEqual(jobId); + expect(serviceResult.result.status).toEqual('FINISHED'); + done(); + } catch (e) { + console.log("'getPrintingJob'案例失败" + e.name + ':' + e.message); + expect(false).toBeTruthy(); + done(); + } + }); + }); }); diff --git a/test/resources/WebPrintingJobService.js b/test/resources/WebPrintingJobService.js index 6b6a5b44f8..365d69699c 100644 --- a/test/resources/WebPrintingJobService.js +++ b/test/resources/WebPrintingJobService.js @@ -48,6 +48,52 @@ var getPrintingJobResultJson = { status: 'FINISHED' }; +var getPrintingJobRunningJson = { + "result": { + "downloadUrl": "http://localhost:9876/iserver/services/webprinting/rest/webprinting/v1/jobs/00edd5df-510f-48dc-8fbf-17d46ce78376@4d8facfc-4784-4ca4-b201-110500f65350/result" + }, + "startTime": "2024-04-08 20:19:27", + "id": "00edd5df-510f-48dc-8fbf-17d46ce78376@4d8facfc-4784-4ca4-b201-110500f65350", + "info": { + "layoutOptions": { + "template": "A2_landscape", + "copyright": "", + "littleMapOptions": { + "center": { + "x": "108.90481660020251", + "y": "23.82283337896889" + }, + "scale": 0.00012532763580614162 + }, + "subTitle": "", + "templateName": "A2_landscape", + "author": "北京超图软件股份有限公司", + "legendOptions": { + "picAsBase64": "iVBORw0KGgoAAAANSUhEUgAAAuUAAABhCAYAAABxhN8ZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFxEAABcRAcom8z8AABBnSURBVHhe7d07rxxFGofxc7wSEeGKACFArIXEF AmICDABAQbgAQkECBusQUJIQnIMTcRQAJol5AAExAA4vYFkJBBsFoRrDYkQlrO1jMzr10ud8/0zOnpru55ftKruboNPlPT/36rus/xkaTR/HbhvZPV3bVuPP/04ja9f3G7K7bTto30mt8HkiSN5MzqVlKlIkjvM5BLkqRxGcqlivUVpA3kkiTV7fj2C9d3mj4fwo/nf3f6XAclBeXW8ddHkGYb6LKd9F7Hn6pycvJdNfun4 O7HB S9spOuSRJkjQyQ7lUob665GzjtNuRJEn75/IVaUQpMF8z/voM5Ntw Ypq4/IVaXs/fHuxmnFzx93nHDdbsFMuVYIgPVYglyRJ4zKUSxWIIG0glyTpMBnKpZH1FaQN5JIkTZehXBpRH0GabRjIJUmaNkO5JEmSNDJDuTSiPrrkbKOP7UiSpPEYyqWJ6mvJiktfJEkan6FcmqA gjTbMJBLklQHQ7k0MX0FcrZhINccHb//7ure1dqel6Qa7BzKfzz/ WSNIw A7kkSarHTqGcIH77hesvl Fc2i C9IQC X2puvya55dSXVrelSTpsG0dyiOQ5/JwXgl29p8u7zYiCDy vCtpIt5YlSRJs Oa8mYE9nUdPF7v0gmUTi262y5bOfol1QupOOiWJGlWDOXd3JaKEM6tNJi gvTEAjkHxIy3sl5LBW6bXl83OyZJUtXmFMojOFPstM9lj2ONa9TfUn1YPLfrtDhdu9iG1Js gjTbGDCQxzj4cvHoyuNYOx6PoxinjMV4zDgNb6Y63rIeTiVJOoXv3n3zqqoA 5CDWLo4p1D c6rYOV9cVTz anWbf7ry16kXU0XAJrBHWGjqvj2wuo1gUcWnVvPRVyBnGwN2yGMsvbx4dOXx66nOZo jeN9P2WPG6SYxRqVrcMnDuOxh3M rf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MoS22G5C7e8nz/HY5bGxOuxHZR/9965fEWSJEm1IyRH2A4EaC4jSsCOg5FyTTnBnXCN91IRsstLHcaa9fz5wS91bSiXJElSzSJY593vwDl9BGqqvCIRv0woOunl6zwfvzSoCZfFbrrM797wHyhJkqQZmOnylV00BfhcLIVpQ2jf9rKjp2KnXJIkSTWLTnjX6oLA3vRnowYN5DCUS5IkqUax1ntb/Jl1XXJJkiRJKh0d/R/xG4kGdYu0AQAAAABJRU5ErkJggg==", + "title": "" + }, + "title": "Land Use", + "scaleBarOptions": { + "intervals": "", + "unit": "METER", + "scaleText": "", + "type": "BAR" + } + }, + "exportOptions": { + "center": null, + "format": "PDF", + "scale": 0.00006266381790307081, + "dpi": 96 + }, + "content": { + "type": "WEBMAP", + "url": "https://iportal.supermap.io/iportal/web/maps/169081517/map.json" + } + }, + "status": "RUNNING" +}; + var getLayoutsResultJson = [ { layoutOptions: {