From 55cceec7df4b70ea6095351a55a95c9013ab8475 Mon Sep 17 00:00:00 2001
From: Esteban GS <26440947+esteban-gs@users.noreply.github.com>
Date: Thu, 9 Feb 2023 17:47:42 -0800
Subject: [PATCH] Feature/e2e test pipeline (#136)
* New build pipeline
dockerfile and pipeline
use e2e command
install before test
use cypress plug in
consolidate into one job
dockerignore non build files
remove unnecessary ignore
use node 16
* use multiple jobs
add action
* add dotnet tool restore step to build
* fix: bugs after machete-client
* e2e-tests: fix for pipeline and machete-client
* remove unsupported mask
* don't use bionic image
* disable cypress record video
* fix e2e tests
* remove non-doc comment
---
.dockerignore | 9 ++
.github/workflows/node.js.yml | 20 +++-
ci.Dockerfile | 23 +++++
cypress.json | 3 +-
cypress/fixtures/employers/profile.json | 33 +++++++
cypress/integration/employer.spec.ts | 18 +---
.../hirer-portal/intro-confirm.spec.ts | 21 +++--
.../hirer-portal/introduction.spec.ts | 9 +-
.../hirer-portal/order-confirm.spec.ts | 12 +--
.../hirer-portal/work-assignments.spec.ts | 25 ++---
.../hirer-portal/work-order.spec.ts | 7 +-
cypress/support/commands.ts | 91 +++++++++++++++++--
.../support/machete-client-types/config.d.ts | 8 ++
.../support/machete-client-types/index.d.ts | 1 +
cypress/support/support.d.ts | 20 +++-
docker-compose.yml | 20 ++++
env_variables.conf | 12 +++
package-lock.json | 2 +-
src/app/configs/configs.service.ts | 1 +
src/app/employers/employers.component.html | 4 +-
.../intro-confirm/intro-confirm.component.ts | 6 +-
.../transport-providers.service.ts | 4 +-
22 files changed, 265 insertions(+), 84 deletions(-)
create mode 100644 .dockerignore
create mode 100644 ci.Dockerfile
create mode 100644 cypress/fixtures/employers/profile.json
create mode 100644 cypress/support/machete-client-types/config.d.ts
create mode 100644 cypress/support/machete-client-types/index.d.ts
create mode 100644 docker-compose.yml
create mode 100644 env_variables.conf
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..f2f3d380
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,9 @@
+node_modules
+.idea
+.devcontainer
+.vscode
+cypress
+dist
+**.md
+.github
+test
diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml
index fa8ca17d..7e76a083 100644
--- a/.github/workflows/node.js.yml
+++ b/.github/workflows/node.js.yml
@@ -10,7 +10,7 @@ on:
branches: [ master ]
jobs:
- build:
+ unit-test:
runs-on: ubuntu-latest
@@ -34,3 +34,21 @@ jobs:
- run: npm ci
- run: npm run build --if-present
- run: npm run test-headless
+
+ ui-e2e-tests:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: "Start project compose services"
+ run: docker compose -f docker-compose.yml up -d
+ - name: "Wait for docker to finish building"
+ run: sleep 10
+
+ - name: Run cypress e2e tests
+ uses: cypress-io/github-action@v4
+ with:
+ config-file: cypress.json
+ wait-on: "http://localhost:4213/V2"
diff --git a/ci.Dockerfile b/ci.Dockerfile
new file mode 100644
index 00000000..ff43b159
--- /dev/null
+++ b/ci.Dockerfile
@@ -0,0 +1,23 @@
+FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-dotnet
+WORKDIR /admin
+RUN apt update && apt upgrade -y && apt install git
+RUN git clone https://github.com/SavageLearning/Machete.git
+
+WORKDIR /admin/Machete
+RUN sed -i 's/localhost/sqlserver/g' Machete.Web/appsettings.json
+RUN dotnet tool restore
+RUN dotnet build --no-incremental
+RUN dotnet publish -o output Machete.Web
+
+FROM node:16-alpine as build-nodejs
+WORKDIR /app
+COPY ./ ./
+RUN npm install
+RUN npm run --silent build-prod
+
+FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
+RUN mkdir -p /app/api/Content /app/api/Identity /app/api/dist
+COPY --from=build-dotnet /admin/Machete/output/ /app/api
+COPY --from=build-nodejs /app/dist /app/api/dist
+WORKDIR /app/api
+ENTRYPOINT ["dotnet","Machete.Web.dll"]
diff --git a/cypress.json b/cypress.json
index 4a55c052..ab1ca1fd 100644
--- a/cypress.json
+++ b/cypress.json
@@ -10,5 +10,6 @@
"macheteApiUrl": "http://localhost:4213/api",
"macheteLegacyUrl": "http://localhost:4213"
},
- "video": false
+ "video": false,
+ "screenshotOnRunFailure": true
}
diff --git a/cypress/fixtures/employers/profile.json b/cypress/fixtures/employers/profile.json
new file mode 100644
index 00000000..0d13a109
--- /dev/null
+++ b/cypress/fixtures/employers/profile.json
@@ -0,0 +1,33 @@
+{
+ "data": {
+ "active": false,
+ "address1": "fake address",
+ "address2": null,
+ "blogparticipate": null,
+ "business": false,
+ "businessname": null,
+ "cellphone": null,
+ "city": "gotham city",
+ "driverslicense": null,
+ "email": "jciispam@gmail.com",
+ "fax": null,
+ "isOnlineProfileComplete": null,
+ "licenseplate": null,
+ "name": "fake Employer",
+ "notes": null,
+ "onlineSigninID": "984fff15-93c5-41c4-b45d-2ed6f20f54f1",
+ "onlineSource": true,
+ "phone": "123-456-7891",
+ "receiveUpdates": false,
+ "referredby": 25,
+ "referredbyOther": null,
+ "returnCustomer": false,
+ "state": "WA",
+ "zipcode": "98122",
+ "createdby": "jciispam@gmail.com",
+ "datecreated": "2023-01-16T01:05:00.857",
+ "dateupdated": "2023-01-16T01:21:24.0310004+00:00",
+ "id": 1,
+ "updatedby": "jciispam@gmail.com"
+ }
+}
diff --git a/cypress/integration/employer.spec.ts b/cypress/integration/employer.spec.ts
index fa35bc84..9735940f 100644
--- a/cypress/integration/employer.spec.ts
+++ b/cypress/integration/employer.spec.ts
@@ -2,30 +2,19 @@ import { ENV_KEY_MACHETE_EMPLOYER, MACHETE_ADMIN } from "cypress/constants";
import { Employer } from "src/app/shared/models/employer";
describe("employers profile", () => {
- before(() => {
- cy.getEmployerProfile();
- if (Cypress.env(ENV_KEY_MACHETE_EMPLOYER) === 0) {
- // if new employer
- cy.log(Cypress.env(ENV_KEY_MACHETE_EMPLOYER));
- cy.fillOutEmployerProfile();
- cy.visit("/employers");
- cy.getEmployerProfile();
- }
- });
-
beforeEach(() => {
cy.apiLogin(MACHETE_ADMIN.user, MACHETE_ADMIN.password);
- cy.visit("/employers");
- cy.getEmployerProfile();
-
+ cy.apiGetEmployerProfile();
});
it("should display username", () => {
+ cy.visit("/employers");
const employerProfile = Cypress.env(ENV_KEY_MACHETE_EMPLOYER) as Employer;
cy.get(`[id="name"]`).should("have.value", employerProfile.name);
});
it("form should validate", () => {
+ cy.visit("/employers");
const employer = Cypress.env(ENV_KEY_MACHETE_EMPLOYER);
// name
@@ -94,6 +83,7 @@ describe("employers profile", () => {
});
it("should navigate to hire worker form on save", () => {
+ cy.visit("/employers");
const employer: Employer = Cypress.env(ENV_KEY_MACHETE_EMPLOYER);
cy.get("#name").should("contain.value", employer.name);
cy.get(`[type="submit"]`).should("exist").click();
diff --git a/cypress/integration/hirer-portal/intro-confirm.spec.ts b/cypress/integration/hirer-portal/intro-confirm.spec.ts
index 18f23379..74afa34e 100644
--- a/cypress/integration/hirer-portal/intro-confirm.spec.ts
+++ b/cypress/integration/hirer-portal/intro-confirm.spec.ts
@@ -1,15 +1,22 @@
-import { ENV_KEY_MACHETE_EMPLOYER, MACHETE_ADMIN, onlineOrderRoutes } from "cypress/constants";
+import {
+ ENV_KEY_MACHETE_CONFIGS,
+ MACHETE_ADMIN,
+ onlineOrderRoutes,
+} from "cypress/constants";
+import { ConfigVM } from "machete-client";
+
+const loadConfigs = () => Cypress.env(ENV_KEY_MACHETE_CONFIGS) as ConfigVM[];
describe("hirer portal - intro-comfirm - flow", () => {
+ before(() => {
+ cy.getMacheteConfigs();
+ });
+
beforeEach(() => {
cy.apiLogin(MACHETE_ADMIN.user, MACHETE_ADMIN.password);
- cy.getEmployerProfile();
+ cy.apiGetEmployerProfile();
- if (Cypress.env(ENV_KEY_MACHETE_EMPLOYER) == 0) {
- // if new employer
- console.log(Cypress.env(ENV_KEY_MACHETE_EMPLOYER));
- cy.fillOutEmployerProfile();
- }
+ cy.enableOnlineOrdersSetting(loadConfigs());
});
//#region intro-comfirm
diff --git a/cypress/integration/hirer-portal/introduction.spec.ts b/cypress/integration/hirer-portal/introduction.spec.ts
index 23763ff5..c7248bd6 100644
--- a/cypress/integration/hirer-portal/introduction.spec.ts
+++ b/cypress/integration/hirer-portal/introduction.spec.ts
@@ -1,5 +1,4 @@
import {
- ENV_KEY_MACHETE_EMPLOYER,
MACHETE_ADMIN,
onlineOrderRoutes,
} from "cypress/constants";
@@ -7,13 +6,7 @@ import {
describe("hirer portal - introduction - flow", () => {
beforeEach(() => {
cy.apiLogin(MACHETE_ADMIN.user, MACHETE_ADMIN.password);
- cy.getEmployerProfile();
-
- if (Cypress.env(ENV_KEY_MACHETE_EMPLOYER) == 0) {
- // if new employer
- console.log(Cypress.env(ENV_KEY_MACHETE_EMPLOYER));
- cy.fillOutEmployerProfile();
- }
+ cy.apiGetEmployerProfile();
});
//#region intro
diff --git a/cypress/integration/hirer-portal/order-confirm.spec.ts b/cypress/integration/hirer-portal/order-confirm.spec.ts
index 692f88d7..0d8dfece 100644
--- a/cypress/integration/hirer-portal/order-confirm.spec.ts
+++ b/cypress/integration/hirer-portal/order-confirm.spec.ts
@@ -1,6 +1,5 @@
import {
ENV_KEY_ANY_SKILL,
- ENV_KEY_MACHETE_EMPLOYER,
ENV_KEY_MACHETE_PAID_TRANSPORT_RULE,
MACHETE_ADMIN,
onlineOrderRoutes,
@@ -10,7 +9,7 @@ import {
generateWorkAssignmentsStub,
getExpectedCostForWorkerCount,
} from "cypress/utils";
-import { Lookup } from "src/app/lookups/models/lookup";
+import { LookupVM } from "machete-client";
import { TransportRule } from "src/app/online-orders/shared/models/transport-rule";
import { WorkAssignment } from "src/app/shared/models/work-assignment";
import { stepsToWorkAssignments } from "./work-assignments.spec";
@@ -19,7 +18,7 @@ let waInTest: WorkAssignment[];
const stepsToOrderConfirm = () => {
// arrange base state
- const anySkill: Lookup = Cypress.env(ENV_KEY_ANY_SKILL);
+ const anySkill: LookupVM = Cypress.env(ENV_KEY_ANY_SKILL);
if (anySkill === null || anySkill === undefined) throw new Error();
const paidTransportRule = Cypress.env(
ENV_KEY_MACHETE_PAID_TRANSPORT_RULE
@@ -46,12 +45,7 @@ describe("hirer portal - order confirm flow", () => {
cy.getMacheteScheduleRules();
cy.getMacheteTransportProviders();
cy.getMacheteLookups();
- cy.getEmployerProfile();
- if (Cypress.env(ENV_KEY_MACHETE_EMPLOYER) == 0) {
- // if new employer
- console.log(Cypress.env(ENV_KEY_MACHETE_EMPLOYER));
- cy.fillOutEmployerProfile();
- }
+ cy.apiGetEmployerProfile();
});
beforeEach(() => {
diff --git a/cypress/integration/hirer-portal/work-assignments.spec.ts b/cypress/integration/hirer-portal/work-assignments.spec.ts
index 5f03b56e..a855e1f6 100644
--- a/cypress/integration/hirer-portal/work-assignments.spec.ts
+++ b/cypress/integration/hirer-portal/work-assignments.spec.ts
@@ -14,7 +14,7 @@ import {
generateWorkOrderStub,
} from "cypress/utils/helpers";
import * as faker from "faker";
-import { Lookup } from "src/app/lookups/models/lookup";
+import { LookupVM } from "machete-client";
import { ScheduleRule } from "src/app/online-orders/shared/models/schedule-rule";
import { TransportProvider } from "src/app/online-orders/shared/models/transport-provider";
import { TransportRule } from "src/app/online-orders/shared/models/transport-rule";
@@ -73,12 +73,7 @@ describe("hirer portal - work-assignments - flow", () => {
cy.getFirstMachetePaidTransportRule();
cy.getMacheteScheduleRules();
cy.getMacheteTransportProviders();
- cy.getEmployerProfile();
- if (Cypress.env(ENV_KEY_MACHETE_EMPLOYER) == 0) {
- // if new employer
- console.log(Cypress.env(ENV_KEY_MACHETE_EMPLOYER));
- cy.fillOutEmployerProfile();
- }
+ cy.apiGetEmployerProfile();
cy.getMacheteLookups();
});
@@ -129,7 +124,7 @@ describe("hirer portal - work-assignments - flow", () => {
.should("not.have.attr", "disabled");
});
it("should not display add request if invalid", () => {
- const anySkill: Lookup = Cypress.env(ENV_KEY_ANY_SKILL);
+ const anySkill: LookupVM = Cypress.env(ENV_KEY_ANY_SKILL);
cy.get(WorkAssignmentSelectors.fieldHoursNeeded).type(
anySkill.minHour.toString()
);
@@ -155,7 +150,7 @@ describe("hirer portal - work-assignments - flow", () => {
);
});
it("should add request to list when valid and swtich to review tab", () => {
- const anySkill: Lookup = Cypress.env(ENV_KEY_ANY_SKILL);
+ const anySkill: LookupVM = Cypress.env(ENV_KEY_ANY_SKILL);
selectAnySkill(anySkill);
cy.get(WorkAssignmentSelectors.buttonAddCurrentJobToRequest).click();
cy.get(".p-tabview-nav-content ul li:first")
@@ -166,7 +161,7 @@ describe("hirer portal - work-assignments - flow", () => {
.contains(stringToTitleCase(anySkill.text_EN));
});
it("should show success message when request is added", () => {
- const anySkill: Lookup = Cypress.env(ENV_KEY_ANY_SKILL);
+ const anySkill: LookupVM = Cypress.env(ENV_KEY_ANY_SKILL);
selectAnySkill(anySkill);
cy.get(WorkAssignmentSelectors.buttonAddCurrentJobToRequest).click();
cy.get(`p-messages .p-message-summary`).contains(`Success!`);
@@ -175,7 +170,7 @@ describe("hirer portal - work-assignments - flow", () => {
);
});
it("should edit request", () => {
- const anySkill: Lookup = Cypress.env(ENV_KEY_ANY_SKILL);
+ const anySkill: LookupVM = Cypress.env(ENV_KEY_ANY_SKILL);
const uniqueValue = "MacheteRocks";
selectAnySkill(anySkill);
cy.get(WorkAssignmentSelectors.buttonAddCurrentJobToRequest).click();
@@ -189,7 +184,7 @@ describe("hirer portal - work-assignments - flow", () => {
cy.get(`tbody`).contains((anySkill.minHour + 1).toString());
});
it("should delete request", () => {
- const anySkill: Lookup = Cypress.env(ENV_KEY_ANY_SKILL);
+ const anySkill: LookupVM = Cypress.env(ENV_KEY_ANY_SKILL);
const uniqueValue = "MacheteRocks";
cy.get(WorkAssignmentSelectors.fieldAdditionalInfo).type(uniqueValue);
selectAnySkill(anySkill);
@@ -198,7 +193,7 @@ describe("hirer portal - work-assignments - flow", () => {
cy.get(`tbody`).should("not.contain", uniqueValue);
});
it("Add More Jobs should switch to blank form", () => {
- const anySkill: Lookup = Cypress.env(ENV_KEY_ANY_SKILL);
+ const anySkill: LookupVM = Cypress.env(ENV_KEY_ANY_SKILL);
selectAnySkill(anySkill);
cy.get(WorkAssignmentSelectors.buttonAddCurrentJobToRequest).click();
cy.get(WorkAssignmentSelectors.buttonAddMoreJobs).click();
@@ -208,7 +203,7 @@ describe("hirer portal - work-assignments - flow", () => {
);
});
it(`Save and Continue should navigate to ${onlineOrderRoutes.orderConfirm}`, () => {
- const anySkill: Lookup = Cypress.env(ENV_KEY_ANY_SKILL);
+ const anySkill: LookupVM = Cypress.env(ENV_KEY_ANY_SKILL);
selectAnySkill(anySkill);
cy.get(WorkAssignmentSelectors.buttonAddCurrentJobToRequest).click();
cy.get(WorkAssignmentSelectors.buttonSaveAndContinue).click();
@@ -216,7 +211,7 @@ describe("hirer portal - work-assignments - flow", () => {
});
});
-const selectAnySkill = (anySkill: Lookup) => {
+const selectAnySkill = (anySkill: LookupVM) => {
cy.wait(REMOTE_TEST_WAIT_MS);
cy.get(WorkAssignmentSelectors.chooseJobsTab).click();
cy.get(WorkAssignmentSelectors.fieldChageSkillSelection).click();
diff --git a/cypress/integration/hirer-portal/work-order.spec.ts b/cypress/integration/hirer-portal/work-order.spec.ts
index 8ffea411..1cb77309 100644
--- a/cypress/integration/hirer-portal/work-order.spec.ts
+++ b/cypress/integration/hirer-portal/work-order.spec.ts
@@ -43,12 +43,7 @@ describe("hirer portal - work-orders - flow", () => {
cy.apiLogin(MACHETE_ADMIN.user, MACHETE_ADMIN.password);
cy.getMacheteTransportRules();
cy.getMacheteTransportProviders();
- cy.getEmployerProfile();
- if (Cypress.env(ENV_KEY_MACHETE_EMPLOYER) == 0) {
- // if new employer
- console.log(Cypress.env(ENV_KEY_MACHETE_EMPLOYER));
- cy.fillOutEmployerProfile();
- }
+ cy.apiGetEmployerProfile();
});
beforeEach(() => {
diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts
index da391e97..e1a78f11 100644
--- a/cypress/support/commands.ts
+++ b/cypress/support/commands.ts
@@ -14,7 +14,7 @@ import {
} from "cypress/constants";
import { TransportProvider } from "src/app/online-orders/shared/models/transport-provider";
-import { Lookup } from "src/app/lookups/models/lookup";
+import { LookupVM, ConfigVM } from "machete-client";
import { Employer } from "src/app/shared/models/employer";
import { TransportRule } from "src/app/online-orders/shared/models/transport-rule";
import { ScheduleRule } from "src/app/online-orders/shared/models/schedule-rule";
@@ -54,7 +54,7 @@ function getMacheteConfigs(): void {
(config) => config["key"] === "DisableOnlineOrders"
);
// At least one should be there
- expect(theConfig).to.include(true);
+ expect(theConfig).to.not.null;
Cypress.env(ENV_KEY_MACHETE_CONFIGS, data);
});
}
@@ -108,7 +108,7 @@ function getMacheteTransportProviders(): void {
});
}
-function getEmployerProfile(): void {
+function apiGetEmployerProfile(): void {
const endpoint = `${Cypress.env("macheteApiUrl")}/employers/profile`;
cy.request({
url: endpoint,
@@ -121,30 +121,61 @@ function getEmployerProfile(): void {
expect(response.body).haveOwnProperty("data");
const employer = response.body.data as Employer;
expect(employer).to.not.be.null.and.not.be.undefined;
- logWrapper("getEmployerProfile()", employer);
+ logWrapper("apiGetEmployerProfile()", employer);
Cypress.env(ENV_KEY_MACHETE_EMPLOYER, employer);
} else {
+ cy.apiFillOutEmployerProfile();
Cypress.env(ENV_KEY_MACHETE_EMPLOYER, 0);
- logWrapper("getEmployerProfile()", 0);
+ logWrapper("apiGetEmployerProfile()", 0);
}
});
}
+function enableOnlineOrdersSetting(configs: ConfigVM[]): void {
+ const { id, value } = configs.filter(
+ (config: ConfigVM) => config.key === "DisableOnlineOrders"
+ )[0];
+ expect(id).not.null;
+ const disableOnlineOrdersConfig = {
+ id: id,
+ key: "DisableOnlineOrders",
+ value: "FALSE",
+ description:
+ "Enter either TRUE or FALSE. Enter TRUE to turn off access to the online hiring portal",
+ category: "OnlineOrders",
+ publicConfig: true,
+ createdby: "Init T. Script",
+ datecreated: "2023-01-06T22:25:14.18",
+ dateupdated: "2023-01-06T22:25:14.18",
+ updatedby: "Init T. Script",
+ };
+
+ if (value === "TRUE") {
+ cy.request(
+ "PUT",
+ `${Cypress.env("macheteApiUrl")}/configs/${id}`,
+ disableOnlineOrdersConfig
+ ).then(() => {
+ cy.getMacheteConfigs();
+ });
+ }
+}
+
function getMacheteLookups(): void {
const endpoint = `${Cypress.env("macheteApiUrl")}/Lookups`;
cy.request(endpoint).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.data).to.not.be.null.and.not.be.undefined;
- const data = response.body.data as Lookup[];
+ const data = response.body.data as LookupVM[];
logWrapper("getMacheteLookups()", data);
Cypress.env(ENV_KEY_MACHETE_LOOKUPS, data);
- const anySkill: Lookup = data.find((lu) => lu.category.includes("skill"));
+ const anySkill: LookupVM = data.find((lu) => lu.category.includes("skill"));
Cypress.env(ENV_KEY_ANY_SKILL, anySkill);
});
}
-function fillOutEmployerProfile(): void {
+function uiFillOutEmployerProfile(): void {
// name
const name = "#name";
cy.get(name).clear().type("fake Employer");
@@ -172,6 +203,44 @@ function fillOutEmployerProfile(): void {
cy.url().should("include", "online-orders/introduction");
}
+function apiFillOutEmployerProfile(): void {
+ const endpoint = `${Cypress.env("macheteLegacyUrl")}/api/Employers/profile`;
+ cy.request("POST", endpoint, {
+ address1: "fake address",
+ business: false,
+ city: "gotham city",
+ driverslicense: null,
+ email: "fake@gmail.com",
+ fax: null,
+ name: "fake Employer",
+ notes: null,
+ onlineSource: true,
+ phone: "123-456-7891",
+ receiveUpdates: false,
+ referredby: 25,
+ referredbyOther: null,
+ returnCustomer: false,
+ state: "WA",
+ zipcode: "98122",
+ createdby: "fake@gmail.com",
+ dateupdated: "2023-01-16T01:13:13.17",
+ id: 1,
+ updatedby: "fake@gmail.com",
+ }).then((response) => {
+ if (response.status == 200) {
+ expect(response.body).haveOwnProperty("data");
+ const employer = response.body.data as Employer;
+ expect(employer).to.not.be.null.and.not.be.undefined;
+ logWrapper("apiFillOutEmployerProfile()", employer);
+ expect(response.status).to.eq(200);
+ Cypress.env(ENV_KEY_MACHETE_EMPLOYER, employer);
+ } else {
+ Cypress.env(ENV_KEY_MACHETE_EMPLOYER, 0);
+ logWrapper("apiFillOutEmployerProfile()", 0);
+ }
+ });
+}
+
function logout(): void {
cy.clearCookie(".AspNetCore.Identity.Application");
}
@@ -208,9 +277,11 @@ Cypress.Commands.add("uiLogin", uiLogin);
Cypress.Commands.add("apiLogin", apiLogin);
Cypress.Commands.add("logout", logout);
Cypress.Commands.add("getMacheteConfigs", getMacheteConfigs);
-Cypress.Commands.add("getEmployerProfile", getEmployerProfile);
+Cypress.Commands.add("apiGetEmployerProfile", apiGetEmployerProfile);
+Cypress.Commands.add("enableOnlineOrdersSetting", enableOnlineOrdersSetting);
Cypress.Commands.add("getMacheteLookups", getMacheteLookups);
-Cypress.Commands.add("fillOutEmployerProfile", fillOutEmployerProfile);
+Cypress.Commands.add("uiFillOutEmployerProfile", uiFillOutEmployerProfile);
+Cypress.Commands.add("apiFillOutEmployerProfile", apiFillOutEmployerProfile);
Cypress.Commands.add("toggleTerms", toggleTerms);
Cypress.Commands.add("getMacheteTransportRules", getMacheteTransportRules);
Cypress.Commands.add(
diff --git a/cypress/support/machete-client-types/config.d.ts b/cypress/support/machete-client-types/config.d.ts
new file mode 100644
index 00000000..ab645ee7
--- /dev/null
+++ b/cypress/support/machete-client-types/config.d.ts
@@ -0,0 +1,8 @@
+import { ConfigVM } from "machete-client";
+
+export = ConfigVMNS;
+export as namespace ConfigVMNS;
+
+declare namespace ConfigVMNS {
+ type ConfigVMM = ConfigVM;
+}
diff --git a/cypress/support/machete-client-types/index.d.ts b/cypress/support/machete-client-types/index.d.ts
new file mode 100644
index 00000000..f50be7a2
--- /dev/null
+++ b/cypress/support/machete-client-types/index.d.ts
@@ -0,0 +1 @@
+///
diff --git a/cypress/support/support.d.ts b/cypress/support/support.d.ts
index dd2a53f3..ee37db70 100644
--- a/cypress/support/support.d.ts
+++ b/cypress/support/support.d.ts
@@ -1,4 +1,6 @@
///
+///
+
// ***********************************************
// This example namespace declaration will help
// with Intellisense and code completion in your
@@ -24,7 +26,13 @@ declare namespace Cypress {
/**
* Should be called after authentication
*/
- getEmployerProfile(): void;
+ apiGetEmployerProfile(): void;
+ /**
+ * Enables the online orders by updating the
+ * Config via an http request
+ * @param configs
+ */
+ enableOnlineOrdersSetting(configs: ConfigVMNS.ConfigVMM[]): void;
/**
* get Machete lookups and save in Cy env variable
*/
@@ -34,7 +42,9 @@ declare namespace Cypress {
* previous log in required. Should already be at route and with
* specifi use case.
*/
- fillOutEmployerProfile(): void;
+ uiFillOutEmployerProfile(): void;
+
+ apiFillOutEmployerProfile(): void;
/**
* Requires: previous login with at least the hirer role
* @param toggleState `"check" | "uncheck"`
@@ -45,11 +55,11 @@ declare namespace Cypress {
*/
getMacheteTransportRules(): void;
/**
- * Gets the first transport rule with a cost and sets the record in the
+ * Gets the first transport rule with a cost and sets the record in the
* environment variable available through the key in the
* `ENV_KEY_MACHETE_PAID_TRANSPORT_PROVIDER` constant
*/
- getFirstMachetePaidTransportRule(): void;
+ getFirstMachetePaidTransportRule(): void;
/**
* Should be called after authentication
*/
@@ -63,7 +73,7 @@ declare namespace Cypress {
* Gets the schedule rules
* `ENV_KEY_MACHETE_TRANSPORT_SCHEDULE_RULES` constant
*/
- getMacheteScheduleRules(): void;
+ getMacheteScheduleRules(): void;
logWrapper(method: string, data: any): void;
}
}
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 00000000..a6d4ba38
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,20 @@
+version: "3.9"
+services:
+ sqlserver:
+ env_file: "./env_variables.conf"
+ environment:
+ ACCEPT_EULA: Y
+
+ image: mcr.microsoft.com/mssql/server:2017-CU31-ubuntu-18.04
+ ports:
+ - 1433:1433
+ - 1444:1444
+
+ dev_dotnet:
+ build:
+ context: .
+ dockerfile: ci.Dockerfile
+ depends_on:
+ - sqlserver
+ ports:
+ - 4213:4213
diff --git a/env_variables.conf b/env_variables.conf
new file mode 100644
index 00000000..476590b9
--- /dev/null
+++ b/env_variables.conf
@@ -0,0 +1,12 @@
+COMPOSE_HTTP_TIMEOUT=120
+# set for localdev. change to /opt/machete for prod
+OPTDIR=./opt/
+SA_PASSWORD=passw0rD!
+SQLSERVER_CERT_SECRET=bigsecret
+ASPNETCORE_ENVIRONMENT=production
+MACHETE_Authentication__State=fakestate
+MACHETE_Authentication__Google__ClientSecret=something
+MACHETE_Authentication__Google__ClientId=something
+MACHETE_Authentication__Facebook__AppSecret=something
+MACHETE_Authentication__Facebook__AppId=something
+
diff --git a/package-lock.json b/package-lock.json
index 915e6303..628131de 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5909,7 +5909,7 @@
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
- "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"connect": {
diff --git a/src/app/configs/configs.service.ts b/src/app/configs/configs.service.ts
index 6795f5f1..17f899e1 100644
--- a/src/app/configs/configs.service.ts
+++ b/src/app/configs/configs.service.ts
@@ -38,6 +38,7 @@ export class ConfigsService {
return this.client.apiConfigsGet().pipe(
pluck("data"),
map((data) => data as Config[]),
+ tap((data) => (this.configs = data)),
tap(() => (this.configsAge = Date.now()))
);
}
diff --git a/src/app/employers/employers.component.html b/src/app/employers/employers.component.html
index dcb86ba0..3948776d 100644
--- a/src/app/employers/employers.component.html
+++ b/src/app/employers/employers.component.html
@@ -144,7 +144,7 @@
formControlName="zipcode"
inputId="zipcode"
type="text"
- mask="99999?-9999">
+ mask="99999">
@@ -159,4 +159,4 @@
-
\ No newline at end of file
+
diff --git a/src/app/online-orders/intro-confirm/intro-confirm.component.ts b/src/app/online-orders/intro-confirm/intro-confirm.component.ts
index c6f7f65c..6fbd886e 100644
--- a/src/app/online-orders/intro-confirm/intro-confirm.component.ts
+++ b/src/app/online-orders/intro-confirm/intro-confirm.component.ts
@@ -23,9 +23,9 @@ export class IntroConfirmComponent implements OnInit {
ngOnInit(): void {
this.onlineService.getInitialConfirmedStream().subscribe((confirmed) => {
this.confirmChoices = confirmed;
- this.confirmStatus = this.confirmChoices
- .map((a) => a.confirmed)
- .reduce((a, b) => a && b);
+ this.confirmStatus = this.confirmChoices.every(
+ (confirm) => confirm.confirmed
+ );
});
}
diff --git a/src/app/online-orders/transport-providers.service.ts b/src/app/online-orders/transport-providers.service.ts
index 36026a99..ac73bcd0 100644
--- a/src/app/online-orders/transport-providers.service.ts
+++ b/src/app/online-orders/transport-providers.service.ts
@@ -40,9 +40,9 @@ export class TransportProvidersService {
}
getTransportProviders(): Observable {
- if (this.isNotStale()) {
+ const cache = sessionStorage.getItem("tranportProviders");
+ if (this.isNotStale() && cache) {
console.log("returning cache", this.providersAge);
- const cache = sessionStorage.getItem("tranportProviders");
return of(JSON.parse(cache) as TransportProvider[]);
}