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: add e2e to verify site + domain removal #1531

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -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'
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'
9 changes: 7 additions & 2 deletions karma.e2e.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/common/e2e/helpers/Artifactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
82 changes: 64 additions & 18 deletions packages/common/e2e/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand All @@ -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: {
Expand All @@ -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",
Expand All @@ -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: {
Expand All @@ -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,
},
},
},
},
},
};

Expand Down
113 changes: 109 additions & 4 deletions packages/common/e2e/hub-sites.e2e.ts
Original file line number Diff line number Diff line change
@@ -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<IHubSite> = {
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<IHubSite> = {
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<IHubSite> = {
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;
}
});
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/sites/HubSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/common/test/sites/HubSites.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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 () => {
Expand Down
Loading
Loading