Skip to content

Commit

Permalink
feat: association functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dbouwman committed Sep 13, 2023
1 parent e126a0a commit beb9194
Show file tree
Hide file tree
Showing 25 changed files with 781 additions and 139 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ENV='qaext'
LOCATION='qaext'
QACREDS_PSW='ADD-THE-REAL-PSW'
QACREDS_USER_PSW='ADD-THE-REAL-PSW'
QA_PORTAL_CREDS_PSW='ADD-THE-REAL-PSW'
121 changes: 57 additions & 64 deletions karma.e2e.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = function(config) {
browserDisconnectTimeout: 120000,
pingTimeout: 1200000,


// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "",

Expand All @@ -23,7 +22,13 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
"packages/*/{src,e2e}/**/*.ts",
{ pattern: 'e2e/test-images/*.jpg', watched: false, included: false, served: true, nocache: false }
{
pattern: "e2e/test-images/*.jpg",
watched: false,
included: false,
served: true,
nocache: false,
},
],

// list of files to exclude
Expand All @@ -33,92 +38,85 @@ module.exports = function(config) {
coverageOptions: {
// Exclude all files - we don't want code coverage on e2e type tests
// also critical so that we can debug in the code
exclude: [
/\.ts$/i,
/fixture*/,
/expected*/
],
exclude: [/\.ts$/i, /fixture*/, /expected*/],
threshold: {
global: {
statements: 0,
branches: 0,
functions: 0,
lines: 0,
excludes: [
'packages/*/examples/**/*.ts',
'packages/*/test/**/*.ts',
'packages/*/e2e/**/*.ts',
]
}
}
"packages/*/examples/**/*.ts",
"packages/*/test/**/*.ts",
"packages/*/e2e/**/*.ts",
],
},
},
},
reports: {
"json": {
"directory": "coverage",
"filename": "coverage.json"
json: {
directory: "coverage",
filename: "coverage.json",
},
"html": "coverage"
html: "coverage",
},
compilerOptions: {
module: "commonjs",
importHelpers: true
importHelpers: true,
},
tsconfig: "./tsconfig.json",
bundlerOptions: {
// validateSyntax: false,
transforms: [
require("karma-typescript-es6-transform")(
{
presets: [
["@babel/preset-env", {
targets: {
chrome: "94"
}
}]
]
}
)
require("karma-typescript-es6-transform")({
presets: [
[
"@babel/preset-env",
{
targets: {
chrome: "94",
},
},
],
],
}),
],
exclude: ["@esri/arcgis-rest-types"],
resolve: {
// karmas resolver cant figure out the symlinked deps from lerna
// so we need to manually alias each package here.
alias: fs
.readdirSync("packages")
.filter(p => p[0] !== ".")
.filter((p) => p[0] !== ".")
.reduce((alias, p) => {
alias[`@esri/templates-${p}`] = `packages/${p}/src/index.ts`;
return alias;
}, {})
}
}
}, {}),
},
},
},

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"packages/*/src/**/*.ts": ["karma-typescript"],
"packages/*/e2e/**/*.ts": ["karma-typescript"],
"packages/*/e2e/**/helpers/config.ts": ["karma-typescript", "env"]
"packages/*/e2e/**/helpers/config.ts": ["karma-typescript", "env"],
},

// Expose this as `window.__env__.QACREDS_PSW
// Used in config files in e2e folders
envPreprocessor: [
"QACREDS_PSW"
],
envPreprocessor: ["QACREDS_PSW", "QACREDS_USER_PSW"],

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
// reporters: ["spec", "karma-typescript", "coverage"],
reporters: ["dots", "karma-typescript"],
reporters: ["dots", "karma-typescript"],
coverageReporter: {
// specify a common output directory
dir: 'coverage',
reporters: [
{ type: 'lcov', subdir: 'lcov' }
]
dir: "coverage",
reporters: [{ type: "lcov", subdir: "lcov" }],
},

// web server port
Expand All @@ -136,24 +134,19 @@ module.exports = function(config) {

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [
'Chrome',
'Edge',
'Firefox'
],
browsers: ["Chrome", "Edge", "Firefox"],
plugins: [
require('karma-env-preprocessor'),
require('@chiragrupani/karma-chromium-edge-launcher'),
require('karma-chrome-launcher'),
require('karma-coverage'),
require('karma-firefox-launcher'),
require('karma-jasmine'),
require('karma-jasmine-diff-reporter'),
require('karma-safari-launcher'),
require('karma-spec-reporter'),
require('karma-typescript'),
require('karma-typescript-es6-transform')

require("karma-env-preprocessor"),
require("@chiragrupani/karma-chromium-edge-launcher"),
require("karma-chrome-launcher"),
require("karma-coverage"),
require("karma-firefox-launcher"),
require("karma-jasmine"),
require("karma-jasmine-diff-reporter"),
require("karma-safari-launcher"),
require("karma-spec-reporter"),
require("karma-typescript"),
require("karma-typescript-es6-transform"),
],

// Continuous Integration mode
Expand All @@ -165,13 +158,13 @@ module.exports = function(config) {
concurrency: Infinity,
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
base: "ChromeHeadless",
flags: ["--no-sandbox"],
},
ChromeDevTools: {
base: 'Chrome',
flags: ['--auto-open-devtools-for-tabs']
}
base: "Chrome",
flags: ["--auto-open-devtools-for-tabs"],
},
},
});
};
149 changes: 149 additions & 0 deletions packages/common/e2e/associations.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import {
IHubInitiative,
fetchRelatedProjects,
fetchAssociatedProjects,
fetchHubEntity,
fetchUnRelatedProjects,
} from "../src";
import Artifactory from "./helpers/Artifactory";
import config from "./helpers/config";
import {
ICreateOutput,
cleanupItems,
createInitiative,
createProjects,
createScopeGroup,
} from "./helpers/metric-fixtures-crud";

const PAIGE_TEST_ITEMS = {
initiative: "14889476c9fd46dbabd694bfd6f65dc4",
projects: [
"1001b7f5150f4b648e61e8c812037921",
"be83e401f9994b93bb2ead0c96c45c9c",
"56e11f847fbb464282eb990cbd139cbd",
"8cc00de75b82414c8c0761aa4300bae3",
"e4852c6189f342399f2af0b69f2558c8",
"68f0231fe334405d8d863c6afedf8a04",
"e5abc74668714e84bb8c56f6c97e5c95",
"e06d9f783bff4e3595843f432a4957b5",
"c49dbaa2ea6045cbb12cefe739f871b0",
"238352acd82d4b55aa59741bba8c269e",
"30fde25db8884a40acff2c39b1e9d075",
"dc46f405197d4111a7584fbdef14c6c9",
],
};

const TEST_ITEMS = {
initiative: "7496421b25db44178bf8993d4eb368a5",
projects: [
"93b53647d84540b9ac4f97891723992c",
"674cec049f5a476ba5417fdf92be0e4c",
"4a25fa2d42b74190b6c2ca0ddabced00",
"85b59fedce9f4d44b8aa47eb580eae01",
"2a6a95d2066e4f3986cccfe81defc45b",
"1bf6055230934e92bca7dfa214507cab",
"e70ad618cb174a0181e792a461d9643d",
"9bcce39151544569a0fe1ea850861df0",
"5cad311f404c4af6be6e64bcf547bf16",
"06c9f201111643179ab8029c91baaa2a",
"980f7687a54e49b29f6ab5cc3903eb5e",
"2d13d504997740c1acb50b2b7a131ee7",
],
};

fdescribe("associations development harness:", () => {
let factory: Artifactory;
const orgName = "hubPremiumAlpha";
beforeAll(() => {
factory = new Artifactory(config);
jasmine.DEFAULT_TIMEOUT_INTERVAL = 200000;
});
xdescribe("create harness items:", () => {
it("create initative and projects", async () => {
const created: ICreateOutput[] = [];
const ctxMgr = await factory.getContextManager(orgName, "paige");
const configs = [{ key: "Assoc With Metrics", count: 12, groupId: "" }];
try {
for (const cfg of configs) {
// create the group that will be the Initaitive's Project Collection Scope
const group = await createScopeGroup(cfg, ctxMgr.context);
cfg.groupId = group.id;
// create initiative with metric definitions and project collection scope
const initiative = await createInitiative(cfg, ctxMgr.context);
// create projets with metric values, shared to the group
const projects = await createProjects(
cfg,
initiative.id,
ctxMgr.context
);
created.push({
group,
initiative,
projects,
});
}
} finally {
for (const items of created) {
const initiative = items.initiative.toJson();
/* tslint:disable no-console */
console.info(`Initiative: ${initiative.id} Group: ${items.group.id}`);
items.projects.forEach((project) => {
/* tslint:disable no-console */
console.log(`Project: ${project.id}`);
});
// debugger;
// await cleanupItems(items, ctxMgr.context);
}
}
});
});
describe("flex the functions:", () => {
it("search for associated projects", async () => {
const ctxMgr = await factory.getContextManager(orgName, "admin");
const context = ctxMgr.context;
const entity = (await fetchHubEntity(
"initiative",
TEST_ITEMS.initiative,
context
)) as IHubInitiative;
// debugger;
const projects = await fetchAssociatedProjects(
entity,
context.hubRequestOptions
);
expect(projects.length).toBe(6);
});
it("search for un-related projects", async () => {
const ctxMgr = await factory.getContextManager(orgName, "admin");
const context = ctxMgr.context;
const entity = (await fetchHubEntity(
"initiative",
TEST_ITEMS.initiative,
context
)) as IHubInitiative;
// debugger;
const projects = await fetchUnRelatedProjects(
entity,
context.hubRequestOptions
);
// need to update this so we fetch all pages
expect(projects.length).toBe(10);
});

it("search for related projects", async () => {
const ctxMgr = await factory.getContextManager(orgName, "admin");
const context = ctxMgr.context;
const entity = (await fetchHubEntity(
"initiative",
TEST_ITEMS.initiative,
context
)) as IHubInitiative;
const projects = await fetchRelatedProjects(
entity,
context.hubRequestOptions
);

expect(projects.length).toBe(6);
});
});
});
Loading

0 comments on commit beb9194

Please sign in to comment.