diff --git a/.env.example b/.env.example index efe5b1169be..05a900f0020 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,7 @@ 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' \ No newline at end of file +PROD_CREDS_PSW='ADD-THE-REAL-PSW' +DEV_CREDS_PSW='ADD-THE-REAL-PSW' +QA_CREDS_PSW='ADD-THE-REAL-PSW' +QA_CREDS_USER_PSW='ADD-THE-REAL-PSW' +QA_PORTAL_CREDS_PSW='ADD-THE-REAL-PSW' diff --git a/karma.e2e.conf.js b/karma.e2e.conf.js index e3610f90dee..309fdc9a849 100644 --- a/karma.e2e.conf.js +++ b/karma.e2e.conf.js @@ -5,7 +5,7 @@ const fs = require("fs"); require('dotenv').config(); -module.exports = function(config) { +module.exports = function (config) { config.set({ // this allows debugging browserNoActivityTimeout: 12000000, @@ -106,7 +106,12 @@ module.exports = function(config) { // Expose this as `window.__env__.QACREDS_PSW // Used in config files in e2e folders - envPreprocessor: ["QACREDS_PSW", "QACREDS_USER_PSW"], + envPreprocessor: [ + "QA_CREDS_PSW", + "QA_CREDS_USER_PSW", + "PROD_CREDS_PSW", + "DEV_CREDS_PSW", + ], // test results reporter to use // possible values: 'dots', 'progress' diff --git a/packages/common/e2e/helpers/Artifactory.ts b/packages/common/e2e/helpers/Artifactory.ts index 8a6d2c24c9e..f57a5b1856b 100644 --- a/packages/common/e2e/helpers/Artifactory.ts +++ b/packages/common/e2e/helpers/Artifactory.ts @@ -18,10 +18,10 @@ export default class Artifactory { public orgs: any[]; public agoBaseDomain: string; - constructor(config: any) { + constructor(config: any, env: string = "qaext") { // qaext | prod // console.info(`Artifactory configured for qaext`); - this.env = "qaext"; + this.env = env; // hold the orgs... this.orgs = config.envs[this.env].orgs; // Copy over a set of other properties... diff --git a/packages/common/e2e/helpers/config.ts b/packages/common/e2e/helpers/config.ts index 8e9be2ca452..3ff22e01c58 100644 --- a/packages/common/e2e/helpers/config.ts +++ b/packages/common/e2e/helpers/config.ts @@ -6,28 +6,42 @@ */ import { getProp } from "../../src"; -let PWD; +let QA_PWD; let USER_PWD; +let PROD_PWD; +let DEV_PWD; +const list = [ + "QA_CREDS_PSW", + "QA_CREDS_USER_PSW", + "PROD_CREDS_PSW", + "DEV_CREDS_PSW", +]; + if (typeof window === "undefined" && process.env) { - if (!process.env.QACREDS_PSW || !process.env.QACREDS_USER_PSW) { + const missing = list.filter((key) => !getProp(process.env, key)); + if (missing.length) { throw new Error( - "QACREDS_PSW or QACREDS_USER_PSW Could not be read! Please ensure you have a .env file configured! Use the .env-example file and ask others on the team where to get the values!" + `${missing.join( + ", " + )} Could not be read! Please ensure you have a .env file configured! Use the .env-example file and ask others on the team where to get the values!` ); } else { - PWD = process.env.QACREDS_PSW; - USER_PWD = process.env.QACREDS_USER_PSW; + QA_PWD = process.env.QA_CREDS_PSW; + USER_PWD = process.env.QA_CREDS_USER_PSW; } } else { - if ( - !getProp(window, "__env__.QACREDS_PSW") || - !getProp(window, "__env__.QACREDS_USER_PSW") - ) { + const missing = list.filter((key) => !getProp(window, `__env__.${key}`)); + if (missing.length) { throw new Error( - "QACREDS_PSW or QACREDS_USER_PSW Could not be read! Please ensure you have a .env file configured! Use the .env-example file and ask others on the team where to get the values!" + `${missing.join( + ", " + )} Could not be read! Please ensure you have a .env file configured! Use the .env-example file and ask others on the team where to get the values!` ); } else { - PWD = getProp(window, "__env__.QACREDS_PSW"); - USER_PWD = getProp(window, "__env__.QACREDS_USER_PSW"); + QA_PWD = getProp(window, "__env__.QA_CREDS_PSW"); + USER_PWD = getProp(window, "__env__.QA_CREDS_USER_PSW"); + PROD_PWD = getProp(window, "__env__.PROD_CREDS_PSW"); + DEV_PWD = getProp(window, "__env__.DEV_CREDS_PSW"); } } @@ -47,11 +61,11 @@ const config = { orgUrl: "https://qa-pre-hub.mapsqa.arcgis.com", admin: { username: "e2e_pre_pub_admin", - password: PWD, + password: QA_PWD, }, user: { username: "e2e_pre_pub_publisher", - password: PWD, + password: QA_PWD, }, fixtures: { items: { @@ -65,11 +79,11 @@ const config = { orgUrl: "https://qa-pre-a-hub.mapsqa.arcgis.com", admin: { username: "e2e_pre_a_pub_admin", - password: PWD, + password: QA_PWD, }, user: { username: "e2e_pre_a_pub_publisher", - password: PWD, + password: QA_PWD, }, paige: { username: "paige_pa", @@ -87,11 +101,11 @@ const config = { orgUrl: "https://qa-bas-hub.mapsqa.arcgis.com", admin: { username: "e2e_bas_pub_admin", - password: PWD, + password: QA_PWD, }, user: { username: "e2e_bas_pub_publisher", - password: PWD, + password: QA_PWD, }, fixtures: { items: { @@ -114,6 +128,38 @@ const config = { }, }, }, + devext: { + agoBaseDomain: "mapsdevext.arcgis.com", + hubBaseDomain: "hubdev.arcgis.com", + orgs: { + hubPremium: { + orgShort: "dev-pre-hub", + orgUrl: "https://dev-pre-hub.mapsdevext.arcgis.com", + admin: { + username: "e2e_pre_pub_admin", + password: DEV_PWD, + }, + user: { + username: "e2e_pre_pub_publisher", + password: DEV_PWD, + }, + }, + }, + }, + prod: { + agoBaseDomain: "maps.arcgis.com", + hubBaseDomain: "hub.arcgis.com", + orgs: { + hubPremium: { + orgShort: "prod-pre-hub", + orgUrl: "https://prod-pre-hub.maps.arcgis.com", + admin: { + username: "e2e_pre_pub_admin", + password: PROD_PWD, + }, + }, + }, + }, }, }; diff --git a/packages/common/e2e/hub-sites.e2e.ts b/packages/common/e2e/hub-sites.e2e.ts index 4410708d02e..c89b4a769dc 100644 --- a/packages/common/e2e/hub-sites.e2e.ts +++ b/packages/common/e2e/hub-sites.e2e.ts @@ -1,13 +1,118 @@ +import { HubSite, IHubSite, lookupDomain, removeDomainsBySiteId } from "../src"; import Artifactory from "./helpers/Artifactory"; import config from "./helpers/config"; // TODO: RE-WRITE USING HubSite Class -describe("Hub Sites", () => { +fdescribe("Hub Sites", () => { let factory: Artifactory; - beforeAll(() => { - factory = new Artifactory(config); - jasmine.DEFAULT_TIMEOUT_INTERVAL = 200000; + fdescribe("QAEXT:", () => { + beforeAll(() => { + factory = new Artifactory(config, "qaext"); + jasmine.DEFAULT_TIMEOUT_INTERVAL = 200000; + }); + it("create and delete site", async () => { + // create context + const ctxMgr = await factory.getContextManager("hubPremium", "admin"); + // create a site + const newSite: Partial = { + name: "QA E2E Test Site", + summary: "This is the summary. Delete me", + }; + const siteInstance = await HubSite.create(newSite, ctxMgr.context); + await siteInstance.save(); + const pojo = siteInstance.toJson(); + // verify that we have a domain record + expect(pojo.url).toBeDefined(); + // rip off the protocol and look up the domain record + const domain = pojo.url?.split("://")[1] || ""; + + const domainRecord = await lookupDomain( + domain, + ctxMgr.context.hubRequestOptions + ); + expect(domainRecord).toBeDefined(); + expect(domainRecord.siteId).toEqual(siteInstance.id); + // delete the site + try { + await siteInstance.delete(); + } catch (_e) { + // debugger; + } + }); + }); + describe("DEVEXT:", () => { + beforeAll(() => { + factory = new Artifactory(config, "devext"); + jasmine.DEFAULT_TIMEOUT_INTERVAL = 200000; + }); + it("create and delete site", async () => { + // create context + const ctxMgr = await factory.getContextManager("hubPremium", "admin"); + // create a site + const newSite: Partial = { + name: "DEV E2E Test Site", + summary: "This is the summary. Delete me", + }; + const siteInstance = await HubSite.create(newSite, ctxMgr.context); + await siteInstance.save(); + const pojo = siteInstance.toJson(); + // verify that we have a domain record + expect(pojo.url).toBeDefined(); + // rip off the protocol and look up the domain record + const domain = pojo.url?.split("://")[1] || ""; + + const domainRecord = await lookupDomain( + domain, + ctxMgr.context.hubRequestOptions + ); + expect(domainRecord).toBeDefined(); + expect(domainRecord.siteId).toEqual(siteInstance.id); + // delete the site + try { + await siteInstance.delete(); + } catch (_e) { + // debugger; + } + }); + }); + describe("PROD:", () => { + beforeAll(() => { + factory = new Artifactory(config, "prod"); + jasmine.DEFAULT_TIMEOUT_INTERVAL = 200000; + }); + it("create and delete site", async () => { + // create context + const ctxMgr = await factory.getContextManager("hubPremium", "admin"); + // create a site + const newSite: Partial = { + name: "PROD E2E Test Site", + summary: "This is the summary. Delete me", + }; + const siteInstance = await HubSite.create(newSite, ctxMgr.context); + await siteInstance.save(); + const pojo = siteInstance.toJson(); + // verify that we have a domain record + expect(pojo.url).toBeDefined(); + // rip off the protocol and look up the domain record + const domain = pojo.url?.split("://")[1] || ""; + + const domainRecord = await lookupDomain( + domain, + ctxMgr.context.hubRequestOptions + ); + expect(domainRecord).toBeDefined(); + expect(domainRecord.siteId).toEqual(siteInstance.id); + // delete the site + await siteInstance.delete(); + + // check what happens when we try to remove the domain again + try { + await removeDomainsBySiteId(pojo.id, ctxMgr.context.hubRequestOptions); + } catch (_e) { + // debugger; + } + }); }); }); diff --git a/packages/common/src/sites/HubSite.ts b/packages/common/src/sites/HubSite.ts index b39d028829b..8b65c1c0c26 100644 --- a/packages/common/src/sites/HubSite.ts +++ b/packages/common/src/sites/HubSite.ts @@ -224,7 +224,7 @@ export class HubSite } this.isDestroyed = true; // Delegate to module fn - await deleteSite(this.entity.id, this.context.userRequestOptions); + await deleteSite(this.entity.id, this.context.hubRequestOptions); } /** diff --git a/packages/common/test/sites/HubSites.test.ts b/packages/common/test/sites/HubSites.test.ts index b697b1eebcb..4c1365f29b9 100644 --- a/packages/common/test/sites/HubSites.test.ts +++ b/packages/common/test/sites/HubSites.test.ts @@ -217,7 +217,7 @@ describe("HubSites:", () => { { key: "components.search.category_tabs.documents" }, { key: "components.search.category_tabs.apps_and_maps" }, ]; - const borkedSite = cloneObject(SITE_MODEL); + const borkedSite = cloneObject(SITE_MODEL) as commonModule.IModel; borkedSite.data.values.searchCategories = borkedSearchCategories; spyOn( require("../../src/sites/fetchSiteModel"), @@ -232,10 +232,10 @@ describe("HubSites:", () => { expect(chk.catalog).toBeDefined(); expect(chk.catalog.schemaVersion).toBeDefined(); // The all collection is automatically prepended, remove it from our check - const collections = chk.catalog.collections.filter( + const collections = chk.catalog.collections?.filter( (c) => c.key !== "all" ); - expect(collections.length).toBe(4); + expect(collections?.length).toBe(4); }); it("gets by domain, without auth", async () => { diff --git a/packages/teams/e2e/helpers/config.ts b/packages/teams/e2e/helpers/config.ts index 64eb69ad203..16b453761f2 100644 --- a/packages/teams/e2e/helpers/config.ts +++ b/packages/teams/e2e/helpers/config.ts @@ -6,22 +6,42 @@ */ import { getProp } from "@esri/hub-common"; -let PWD; +let QA_PWD; +let USER_PWD; +let PROD_PWD; +let DEV_PWD; +const list = [ + "QA_CREDS_PSW", + "QA_CREDS_USER_PSW", + "PROD_CREDS_PSW", + "DEV_CREDS_PSW", +]; + if (typeof window === "undefined" && process.env) { - if (!process.env.QACREDS_PSW) { + const missing = list.filter((key) => !getProp(process.env, key)); + if (missing.length) { throw new Error( - "QACREDS_PSW Could not be read! Please ensure you have a .env file configured! Use the .env-example file and ask others on the team where to get the values!" + `${missing.join( + ", " + )} Could not be read! Please ensure you have a .env file configured! Use the .env-example file and ask others on the team where to get the values!` ); } else { - PWD = process.env.QACREDS_PSW; + QA_PWD = process.env.QA_CREDS_PSW; + USER_PWD = process.env.QA_CREDS_USER_PSW; } } else { - if (!getProp(window, "__env__.QACREDS_PSW")) { + const missing = list.filter((key) => !getProp(window, `__env__.${key}`)); + if (missing.length) { throw new Error( - "QACREDS_PSW Could not be read! Please ensure you have a .env file configured! Use the .env-example file and ask others on the team where to get the values!" + `${missing.join( + ", " + )} Could not be read! Please ensure you have a .env file configured! Use the .env-example file and ask others on the team where to get the values!` ); } else { - PWD = getProp(window, "__env__.QACREDS_PSW"); + QA_PWD = getProp(window, "__env__.QA_CREDS_PSW"); + USER_PWD = getProp(window, "__env__.QA_CREDS_USER_PSW"); + PROD_PWD = getProp(window, "__env__.PROD_CREDS_PSW"); + DEV_PWD = getProp(window, "__env__.DEV_CREDS_PSW"); } } @@ -41,11 +61,11 @@ const config = { orgUrl: "https://qa-pre-hub.mapsqa.arcgis.com", admin: { username: "e2e_pre_pub_admin", - password: PWD, + password: QA_PWD, }, user: { username: "e2e_pre_pub_publisher", - password: PWD, + password: QA_PWD, }, fixtures: { items: { @@ -59,11 +79,11 @@ const config = { orgUrl: "https://qa-bas-hub.mapsqa.arcgis.com", admin: { username: "e2e_bas_pub_admin", - password: PWD, + password: QA_PWD, }, user: { username: "e2e_bas_pub_publisher", - password: PWD, + password: QA_PWD, }, fixtures: { items: {