Skip to content

Commit

Permalink
Fix test failures, especially timeouts.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Jul 23, 2023
1 parent a162279 commit 10f92cf
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
3 changes: 2 additions & 1 deletion buildprocess/babelPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const babelPlugin = (options = {}) => ({
caller: {
name: "esbuild-plugin-babel",
supportsStaticESM: true
}
},
inputSourceMap: true
});
if (!babelOptions) return { contents };

Expand Down
3 changes: 2 additions & 1 deletion buildprocess/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ esbuild
babelPlugin({
filter: /\.[jt]sx$/,
config: {
sourceMaps: true,
plugins: [
//"babel-plugin-jsx-control-statements",
transformJsxControlStatements,
Expand All @@ -87,7 +88,7 @@ esbuild
".glb": "file",
".xml": "file",
".DAC": "file",
".csv": "file"
".csv": "text"
},
external: [
// Don't try to load node-only modules and other unnecessary stuff
Expand Down
27 changes: 15 additions & 12 deletions src/Models/Catalog/Ows/SensorObservationServiceCatalogItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import StratumOrder from "../../Definition/StratumOrder";
import { SelectableDimension } from "../../SelectableDimensions/SelectableDimensions";
import Terria from "../../Terria";
import proxyCatalogItemUrl from "../proxyCatalogItemUrl";
import loadText from "../../../Core/loadText";

interface GetFeatureOfInterestResponse {
featureMember?: FeatureMember[] | FeatureMember;
Expand Down Expand Up @@ -206,14 +207,6 @@ class GetObservationRequest {
return this.catalogItem.url;
}

@computed
get requestTemplate() {
return (
this.catalogItem.requestTemplate ||
SensorObservationServiceCatalogItem.defaultRequestTemplate
);
}

@computed
get parameters() {
const foiIdentifier = this.catalogItem.chartFeatureOfInterestIdentifier;
Expand Down Expand Up @@ -302,7 +295,8 @@ class GetObservationRequest {
const response = await loadSoapBody(
this.catalogItem,
this.url,
this.requestTemplate,
this.catalogItem.requestTemplate ||
(await this.catalogItem._private_getDefaultRequestTemplate()),
templateContext
);

Expand All @@ -314,7 +308,7 @@ export default class SensorObservationServiceCatalogItem extends TableMixin(
CreateModel(SensorObservationServiceCatalogItemTraits)
) {
static readonly type = "sos";
static defaultRequestTemplate = require("./SensorObservationServiceRequestTemplate.xml");
static defaultRequestTemplate: string | undefined = undefined;

constructor(
id: string | undefined,
Expand Down Expand Up @@ -352,12 +346,21 @@ export default class SensorObservationServiceCatalogItem extends TableMixin(
return "0d";
}

async _private_getDefaultRequestTemplate() {
if (!SensorObservationServiceCatalogItem.defaultRequestTemplate) {
const defaultRequestTemplateUrl = require("./SensorObservationServiceRequestTemplate.xml");
SensorObservationServiceCatalogItem.defaultRequestTemplate =
await loadText(defaultRequestTemplateUrl);
}

return SensorObservationServiceCatalogItem.defaultRequestTemplate!;
}

@action
async _private_loadFeaturesData() {
const request = new GetFeatureOfInterestRequest(
this,
this.requestTemplate ||
SensorObservationServiceCatalogItem.defaultRequestTemplate
this.requestTemplate || (await this._private_getDefaultRequestTemplate())
);
const response = await request.perform();
if (response === undefined) {
Expand Down
4 changes: 4 additions & 0 deletions src/ReactViews/Map/Panels/HelpPanel/StyledHtml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,8 @@ const StyledHtml: React.FC<PropsType> = observer((props: PropsType) => {
);
});

StyledHtml.defaultProps = {
injectTooltips: true
};

export default StyledHtml;
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ describe("SensorObservationServiceCatalogItem", function () {
test: (xhr) => /^application\/soap\+xml/.test(xhr.contentType()),
parse: (paramString) => paramString
});
jasmine.Ajax.stubRequest(
"build/TerriaJS/data/regionMapping.json"
).andReturn({ responseText: regionMapping });

async function completeActualRequest(request: JasmineAjaxRequest) {
const response = await fetch(request.url);
request.respondWith({
responseText: await response.text()
});
}

jasmine.Ajax.stubRequest(/^esbuild/).andCallFunction(completeActualRequest);
jasmine.Ajax.stubRequest(/^\//).andCallFunction(completeActualRequest);

item = new SensorObservationServiceCatalogItem("test", new Terria());
item.setTrait(CommonStrata.user, "url", "https://sos.example.com");
Expand Down
3 changes: 2 additions & 1 deletion test/SpecMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "../lib/Core/prerequisites";
import "jasmine-ajax";
import { configure, spy } from "mobx";
import i18next from "i18next";
import { initReactI18next } from "react-i18next";
import registerCatalogMembers from "../lib/Models/Catalog/registerCatalogMembers";

configure({
Expand All @@ -24,7 +25,7 @@ spy((event) => {
});

beforeAll(async function () {
await i18next.init({
await i18next.use(initReactI18next).init({
lng: "cimode",
debug: false,
resources: {}
Expand Down

0 comments on commit 10f92cf

Please sign in to comment.