Skip to content

Commit

Permalink
Merge pull request #375 from bcgov/test-env
Browse files Browse the repository at this point in the history
sales report menu and under-19 question
  • Loading branch information
chloe-yuu authored Nov 15, 2023
2 parents b341eed + fdab447 commit b785eb3
Show file tree
Hide file tree
Showing 19 changed files with 210 additions and 107 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/e2etest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
name: cypress
runs-on: ubuntu-20.04
concurrency: ci-test
timeout-minutes: 50
timeout-minutes: 80
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: '17'

- name: Install deps
run: npm install
Expand All @@ -37,12 +37,8 @@ jobs:
uses: cypress-io/github-action@v2
with:
wait-on-timeout: 200
wait-on: 'http://localhost:3000/retailer'
wait-on: 'http://localhost:3000/retailer, http://localhost:3000/portal'
record: true
env:
CYPRESS_RECORD_KEY: 'f89f5784-9f69-4445-ae27-951ee12a2b9a'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Sleep for 30 seconds
run: sleep 30s
shell: bash
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ describe("Testing Location input form", () => {
})
})

it("Fails underage other field validation", () => {
cy.get(dialog).within(() => {
cy.get(locationFieldNames.underage.other).click();
cy.get(locationFieldNames.underageOther).focus().blur();
cy.contains(locationErrorMessages.underageOther.required);
})
})

it("Fails health authority field validation", () => {
cy.get(dialog).within(() => {
const selector = new Selector("input").addName("health_authority_display").build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="cypress" />

import { FillForm } from "../../utils/fillForm";
import { exampleManualLocations } from "../../utils/location/locationObjects";
import { exampleManualLocations, exampleManualOnlineLocation, exampleManualOnlineandPhysicalLocation } from "../../utils/location/locationObjects";
import { Navigate } from "../../utils/navigate";
import { UserAction } from "../../utils/userAction";
import { clickButton } from "../../utils/util";
Expand All @@ -21,6 +21,8 @@ describe("Tests the 1st time business submission flow", () => {
it("Successfully creates a test business with a location", () => {
FillForm.fillBusinessForm();
UserAction.addNewLocationManually(exampleManualLocations);
UserAction.addNewOnlineLocationManually(exampleManualOnlineLocation);
UserAction.addNewOnlineAndPhysicalLocationManually(exampleManualOnlineandPhysicalLocation);
UserAction.submitBusinessInfo();
cy.contains("Your Business Details have been submited.");
cy.contains("Next steps");
Expand Down
18 changes: 14 additions & 4 deletions cypress/integration/1-retailer/2-my-business/6-my-business.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { businessFieldNames, businessInfo } from "../../utils/business/businessObjects";
import { CheckForm } from "../../utils/fillForm";
import { exampleManualLocations } from "../../utils/location/locationObjects";
import { exampleManualLocations, exampleManualOnlineLocation, exampleManualOnlineandPhysicalLocation } from "../../utils/location/locationObjects";
import { Navigate } from "../../utils/navigate"
import { UserAction } from "../../utils/userAction";

Expand All @@ -18,7 +18,7 @@ describe("Tests my-business assuming the 1st business creation with 1 location",
})

it("checks the correct number of existing location", () => {
cy.contains("You have 2 retail locations")
cy.contains("You have 4 retail locations")
})

context("Tests the Existing business locations", () => {
Expand All @@ -27,15 +27,25 @@ describe("Tests my-business assuming the 1st business creation with 1 location",
cy.wait(1000);
})

it("checks that example location-1 was created/rendered with proper values", () => {
it("checks that example physical location-1 was created/rendered with proper values", () => {
UserAction.clickEditExistingLocation(0);
cy.contains("Edit Business Location")
CheckForm.checkLocationForm(exampleManualLocations[0])
})

it("checks that example location-2 was created/rendered peoperly", () => {
it("checks that example physical location-2 was created/rendered peoperly", () => {
UserAction.clickEditExistingLocation(1);
CheckForm.checkLocationForm(exampleManualLocations[1])
})

it("checks that example online location was created/rendered peoperly", () => {
UserAction.clickEditExistingLocation(2);
CheckForm.checkOnlineLocationForm(exampleManualOnlineLocation[0])
})

it("checks that example online-and-physical location-3 was created/rendered peoperly", () => {
UserAction.clickEditExistingLocation(3);
CheckForm.checkOnlineAndPhysicalLocationForm(exampleManualOnlineandPhysicalLocation[0])
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ describe("Tests NOI tables are properly render when there are no active NOIs", (
Navigate.loginRetailer();
})

it("Checks that dashboard has 2 noi that has not been submitted", () => {
it("Checks that dashboard has 4 noi that has not been submitted", () => {
cy.contains("My Dashboard");
cy.contains("Outstanding Reports");
cy.contains("2 locations with outstanding Notice of Intent");
cy.contains("4 locations with outstanding Notice of Intent");
})

it("It checks that all 3 NOI tables are rendered with proper number of locations", () => {
it("It checks that all 4 NOI tables are rendered with proper number of locations", () => {
Navigate.gotoNoi();
cy.contains("You have 2 retail locations that need a Notice of Intent");
cy.contains("You have 4 retail locations that need a Notice of Intent");
cy.contains("You have 0 locations that require a Sales Report before their NOI can be renewed.");
cy.contains("You have 0 retail locations. You can download/print the Notice of Intent for your Active locations.").scrollIntoView();
})
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/1-retailer/3-noi/2-submit-all-noi.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("Tests the submissiong flow of all outstanding NOI", () => {
Navigate.gotoNoi();
cy.get(".MuiButton-contained").contains("Submit Outstanding NOI").click();
cy.contains("Confirm and Submit Notice of Intent");
cy.contains("You have 2 retail locations");
cy.contains("You have 4 retail locations")
UserAction.clickSelectAllRowsInTable();
cy.get("button").contains("Submit").parent().should("not.be.disabled").click();
insideDialog(() => {
Expand All @@ -33,6 +33,6 @@ describe("Tests the submissiong flow of all outstanding NOI", () => {
it("Tests that NOI tables are properly updated", () => {
Navigate.gotoNoi();
cy.contains("You have 0 retail locations that need a Notice of Intent");
cy.contains("You have 2 retail locations. You can download/print the Notice of Intent for your Active locations.")
cy.contains("You have 4 retail locations. You can download/print the Notice of Intent for your Active locations.")
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("Tests when no product report is submitted yet", () => {
})

it("Tests that correct number of outstanding product report is shown in dashboard", () => {
cy.contains("2 locations with outstanding Product Reports");
cy.contains("4 locations with outstanding Product Reports");
})

it("Tests that all product report table are populated with correct values", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("Tests the submitted locations page", () => {
cy.contains("Location Creation Start Date");
cy.contains("Location Creation End Date");
cy.contains("Search");
cy.contains("2 retail locations.");
cy.contains("4 retail locations.");
})

it("Tests that link to location details page works correctly", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Updates Locations and noi creation date', () => {
})

it("Shows both NOI and sales report is outstanding", () => {
cy.contains("2 locations with outstanding Notice of Intent");
cy.contains("2 locations with outstanding Sales Report");
cy.contains("4 locations with outstanding Notice of Intent");
cy.contains("4 locations with outstanding Sales Report");
});
})
4 changes: 2 additions & 2 deletions cypress/integration/3-year-2/2-submitSalesReport.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ describe("Submit a sales report", () => {
})

it("Successfully submits a sales report", () => {
cy.contains("You have 2 retail location(s) that are missing Sales Reports");
cy.contains("You have 4 retail location(s) that are missing Sales Reports");
const wrapper = new Selector("tr").addIndex("0").build();
cy.wait(1000);
inside(wrapper, () => {
const selector = new Selector("button").addProperty("tabIndex", "0").build();
cy.get(selector).contains("Select").parent().click();
})
cy.contains("Test business name");
cy.contains("Test business name").should('be.visible', { timeout: 10000 });
UserAction.uploadSalesReport('salesReport.csv')
cy.contains("Your CSV file has been mapped successfully.");
clickButton("Next");
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/3-year-2/3-renew-noi.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ describe("Tests renewal of NOI", () => {
})

it("Contains correct number of missing reports", () => {
cy.contains("2 locations with outstanding Notice of Intent");
cy.contains("1 locations with outstanding Sales Report");
cy.contains("4 locations with outstanding Notice of Intent");
cy.contains("3 locations with outstanding Sales Report");
})

it("Shows correct number of location in noi tables", () => {
Navigate.gotoNoi();
cy.contains("You have 1 retail locations that need a Notice of Intent");
cy.contains("You have 1 locations that require a Sales Report before their NOI can be renewed.");
cy.contains("You have 3 locations that require a Sales Report before their NOI can be renewed.");
})

it("Renews NOI", () => {
Expand Down
70 changes: 63 additions & 7 deletions cypress/integration/utils/fillForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ import { UserAction } from "./userAction";
cy.get(locationFieldNames.phone).type(location.phone);
cy.get(locationFieldNames.postal).type(location.postal);
cy.get(locationFieldNames.underage[location.underage]).click();
if (location.underage === "other") {
cy.get(locationFieldNames.underageOther).type(location.underageOther);
}
/**
* Missing proper way to fill health authority other atm
* Should be added when health authority is automatically added with csv upload
Expand All @@ -49,6 +46,35 @@ import { UserAction } from "./userAction";
});
}

static fillManualOnlineLocationForm(location) {
cy.get(locationFieldNames.locationType.online).click();
cy.get(".MuiDialog-paper").within(() => {
cy.get(locationFieldNames.email).type(location.email);
cy.get(locationFieldNames.phone).type(location.phone);
cy.get(locationFieldNames.doingBusinessAs).type(location.doingBusinessAs);
cy.get(locationFieldNames.webpage).type(location.webpage);
cy.get(locationFieldNames.manufacturing[location.manufacturing]).click();
});
}

static fillManualOnlineAndPhysicalLocationForm(location) {
cy.get(locationFieldNames.locationType.both).click();
cy.get(locationFieldNames.addressLine1).type(location.addressLine1, {
delay: 100,
});
cy.wait(1000);
cy.get('.MuiAutocomplete-popper li[data-option-index="0"]').click();
cy.get(".MuiDialog-paper").within(() => {
cy.get(locationFieldNames.email).type(location.email);
cy.get(locationFieldNames.phone).type(location.phone);
cy.get(locationFieldNames.postal).type(location.postal);
cy.get(locationFieldNames.doingBusinessAs).type(location.doingBusinessAs);
cy.get(locationFieldNames.webpage).type(location.webpage);
cy.get(locationFieldNames.underage[location.underage]).click();
cy.get(locationFieldNames.manufacturing[location.manufacturing]).click();
});
}

static correctlyFillWrongLocation(){
cy.get(locationFieldNames.addressLine1).type("1200 Bla", {
delay: 100,
Expand Down Expand Up @@ -114,18 +140,16 @@ export class CheckForm {
cy.get(locationFieldNames.addressLine1).invoke("attr", "value").then( val => {
expect(val).to.have.lengthOf.above(2);
})
cy.get(locationFieldNames.phone).should("have.value", location.phone);
cy.get(locationFieldNames.email).should("have.value", location.email);
cy.get(locationFieldNames.phone).should("have.value", location.phone);
cy.get(locationFieldNames.city).invoke("attr", "value").then(val => {
expect(val).to.have.lengthOf.above(1);
})
cy.get(locationFieldNames.postal).should("have.value", location.postal);
cy.get(locationFieldNames.doingBusinessAs).invoke("attr", "value").then(val => {
expect(val).to.be.oneOf([location.doingBusinessAs || businessInfo.businessName]);
})
cy.get(locationFieldNames.underage[location.underage]).should("be.checked");
if(location.underage === "other"){
cy.get(locationFieldNames.underageOther).should("have.value", location.underageOther)
}
// Missing proper testing for health authority
// cy.get(locationFieldNames.healthAuthority[location.healthAuthority]).should("be.checked");
// if(location.healthAuthority === 'other'){
Expand All @@ -134,4 +158,36 @@ export class CheckForm {
cy.get(locationFieldNames.manufacturing[location.manufacturing]).should("be.checked");
})
}

static checkOnlineLocationForm(location){
insideDialog(() => {
cy.get(locationFieldNames.email).should("have.value", location.email);
cy.get(locationFieldNames.phone).should("have.value", location.phone);
cy.get(locationFieldNames.doingBusinessAs).invoke("attr", "value").then(val => {
expect(val).to.be.oneOf([location.doingBusinessAs || businessInfo.businessName]);
})
cy.get(locationFieldNames.webpage).should("have.value", location.webpage);
cy.get(locationFieldNames.manufacturing[location.manufacturing]).should("be.checked");
})
}

static checkOnlineAndPhysicalLocationForm(location){
insideDialog(() => {
cy.get(locationFieldNames.addressLine1).invoke("attr", "value").then( val => {
expect(val).to.have.lengthOf.above(2);
})
cy.get(locationFieldNames.email).should("have.value", location.email);
cy.get(locationFieldNames.phone).should("have.value", location.phone);
cy.get(locationFieldNames.city).invoke("attr", "value").then(val => {
expect(val).to.have.lengthOf.above(1);
})
cy.get(locationFieldNames.postal).should("have.value", location.postal);
cy.get(locationFieldNames.doingBusinessAs).invoke("attr", "value").then(val => {
expect(val).to.be.oneOf([location.doingBusinessAs || businessInfo.businessName]);
})
cy.get(locationFieldNames.webpage).should("have.value", location.webpage);
cy.get(locationFieldNames.underage[location.underage]).should("be.checked");
cy.get(locationFieldNames.manufacturing[location.manufacturing]).should("be.checked");
})
}
}
26 changes: 24 additions & 2 deletions cypress/integration/utils/location/locationObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,32 @@ export const exampleManualLocations = [
phone: "2222222222",
postal: "k0k0k0",
doingBusinessAs: "",
underage: "other",
underageOther: "Test underage",
underage: "no",
healthAuthority: "other",
healthAuthorityOther: "Test health authority",
manufacturing: "no",
}
]

export const exampleManualOnlineLocation = [
{
email: "online@test.com",
phone: "3333333333",
doingBusinessAs: "onlineBusiness",
webpage: "www.sampleonlinelocation.com",
manufacturing: "no"
}
]

export const exampleManualOnlineandPhysicalLocation = [
{
addressLine1: "123 ferry",
email: "location3@test.com",
phone: "4444444444",
postal: "a0a0a0",
doingBusinessAs: "onlineAndPhysicalBusiness",
webpage: "www.sampleonlineandphysicallocation.com",
underage: "no",
manufacturing: "no"
}
]
20 changes: 19 additions & 1 deletion cypress/integration/utils/userAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class UserAction {
static submitBusinessInfo() {
cy.wait(1000);
cy.get("button").contains("Next").click();
cy.wait(1000);
cy.wait(2000);
cy.get("button").contains("Next").click();
cy.wait(1000);
cy.get("button").contains("Submit Business Information").click();
Expand All @@ -33,6 +33,24 @@ export class UserAction {
});
}

static addNewOnlineLocationManually(locations) {
locations.forEach((l) => {
clickButton("Add Location");
FillForm.fillManualOnlineLocationForm(l);
cy.wait(1000);
clickButton("Submit");
});
}

static addNewOnlineAndPhysicalLocationManually(locations) {
locations.forEach((l) => {
clickButton("Add Location");
FillForm.fillManualOnlineAndPhysicalLocationForm(l);
cy.wait(1000);
clickButton("Submit");
});
}

static addLocationFileUpload(filename) {
const radioSelector = new Selector("input")
.addType("radio")
Expand Down
2 changes: 2 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const login = (user) => {
html.innerHTML = response.body;
let form = html.getElementsByTagName("form")[0];
let url = form.action;
cy.log('Constructed URL:', url);
cy.log('Response Body:', response.body);
return cy.request({
method: "POST",
url: url,
Expand Down
Loading

0 comments on commit b785eb3

Please sign in to comment.