Skip to content

Commit

Permalink
Merge tag 'v0.15.0-rc.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
evanp committed Sep 17, 2024
2 parents ab1209a + 97f3cc7 commit 258f765
Show file tree
Hide file tree
Showing 75 changed files with 15,893 additions and 9,897 deletions.
1 change: 1 addition & 0 deletions .github/workflows/global-api-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:

- name: Deploying service
run: |
export VERSION=${REF#refs/tags/v}
export VERSION=${REF#refs/tags/v}
kubectl create -f k8s/cc-global-api-migrate.yml -n default
kubectl apply -f k8s/cc-global-api-deploy.yml -n default
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/web-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ jobs:

- name: Deploying service
run: |
export VERSION=${REF#refs/tags/v}
export VERSION=${REF#refs/tags/v}
kubectl create -f k8s/prod/cc-prod-migrate.yml -n default
kubectl create -f k8s/prod/cc-prod-seed.yml -n default
Expand Down
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
7 changes: 1 addition & 6 deletions app/e2e/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
test as setup,
expect,
test,
APIRequestContext,
} from "@playwright/test";
import { expect, test as setup, test } from "@playwright/test";
import { randomUUID } from "node:crypto";
import { expectText, signup } from "./helpers";

Expand Down
2 changes: 1 addition & 1 deletion app/e2e/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, type Page, APIRequestContext } from "@playwright/test";
import { APIRequestContext, expect, type Page } from "@playwright/test";

export async function expectText(page: Page, text: string) {
await expect(page.getByText(text).first()).toBeVisible();
Expand Down
138 changes: 57 additions & 81 deletions app/e2e/manual-input.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect, Page, APIRequestContext } from "@playwright/test";
import { APIRequestContext, expect, Page, test } from "@playwright/test";
import { indexPageRegex, regexForPath } from "./utils";

// inventory creation data
Expand Down Expand Up @@ -120,7 +120,7 @@ const sectorData = [
},
];

const EmissionFactos = {
const EmissionFactors = {
CO2: 120,
N2O: 202,
CH4: 300,
Expand Down Expand Up @@ -153,17 +153,17 @@ test.describe.serial("Manual Input", () => {
);

// check for sector cards
const stationaryEnergySectorCard = await page.getByTestId(
const stationaryEnergySectorCard = page.getByTestId(
testIds.stationaryEnergySectorCard,
);
expect(stationaryEnergySectorCard).toBeTruthy();

const transportationSectorCard = await page.getByTestId(
const transportationSectorCard = page.getByTestId(
testIds.transportationSectorCard,
);
expect(transportationSectorCard).toBeTruthy();

const wasteSectorCard = await page.getByTestId(testIds.wasteSectorCard);
const wasteSectorCard = page.getByTestId(testIds.wasteSectorCard);
expect(wasteSectorCard).toBeTruthy();
});

Expand All @@ -174,11 +174,9 @@ test.describe.serial("Manual Input", () => {
await page.waitForURL(regexForPath("/data/"));
await expect(page).toHaveURL(regexForPath("/data/"));
// wait for sector card to load
const sectorCard = await page.getByTestId(sector.testId);
const sectorCard = page.getByTestId(sector.testId);
expect(sectorCard).toBeTruthy();
const sectorCardBtn = await sectorCard?.getByTestId(
testIds.sectorCardButton,
);
const sectorCardBtn = sectorCard?.getByTestId(testIds.sectorCardButton);
await sectorCardBtn?.click();
await page.waitForURL(regexForPath(sector.url1));
await expect(page).toHaveURL(regexForPath(sector.url1));
Expand All @@ -187,7 +185,7 @@ test.describe.serial("Manual Input", () => {
// wait for 10 seconds
await page.waitForTimeout(3000);

const subsectorCards = await page.getByTestId(testIds.subsectorCard);
const subsectorCards = page.getByTestId(testIds.subsectorCard);
expect(await subsectorCards.count()).toBeGreaterThan(0);

// await page response
Expand All @@ -199,89 +197,79 @@ test.describe.serial("Manual Input", () => {
});

test(`should list methodologies in ${sector.sectorName}`, async () => {
// check on a list of methodologies
const methodologyCards = await page.getByTestId(
testIds.methodologyCard,
test.skip(
sector.sectorName === "Waste" ||
sector.sectorName === "Transportation",
);
// check on a list of methodologies
const methodologyCards = page.getByTestId(testIds.methodologyCard);
expect(await methodologyCards.count()).toBeGreaterThan(0);
});

test(`test direct measure methodology in scope 1 with incomplete & complete values in in ${sector.sectorName}`, async () => {
test.skip(sector.sectorName === "Waste");
// TODO expand test case to handle multi-select fields, and the dynamic nature of the form
test.skip(
sector.sectorName === "Waste" ||
sector.sectorName === "Transportation",
);
// look for a direct measure
// select all the methodology card headers and check if any of them is direct measure
const directMeasureCardHeader = await page
const directMeasureCardHeader = page
.getByTestId(testIds.methodologyCardHeader)
.filter({
hasText: "Direct Measure",
})
.first();

expect(directMeasureCardHeader).toBeVisible();
await expect(directMeasureCardHeader).toBeVisible();
// click on the direct measure card
await directMeasureCardHeader?.click();

const addEmissionButton = await page.getByTestId(
testIds.addEmissionButton,
);
expect(addEmissionButton).toBeTruthy();
await addEmissionButton?.click();
await page.getByTestId(testIds.addEmissionButton).click();

// wait for the modal to open;
const addEmissionModal = await page.getByTestId(
testIds.addEmissionModal,
);
const addEmissionModal = page.getByTestId(testIds.addEmissionModal);

// fill in the select fields
const selectElements = await page.locator("select");
const selectElements = page.locator("select");
for (let i = 0; i < (await selectElements.count()); i++) {
const dropdown = selectElements.nth(i);
await dropdown.selectOption({ index: 1 });
}

const inputElements = await page.locator("input[type='text']");
const inputElements = page.locator("input[type='text']");
for (let i = 0; i < (await inputElements.count()); i++) {
const input = inputElements.nth(i);
await input.fill("1");
}

const textInput = await addEmissionModal.getByTestId(
const textInput = addEmissionModal.getByTestId(
testIds.sourceReferenceInput,
);

await textInput.fill("");

// fill in the emission values
const co2Input = await addEmissionModal.getByTestId(
testIds.co2EmissionInput,
);
// TODO wrong. These are total emissions amount, NOT emissions factors
const co2Input = addEmissionModal.getByTestId(testIds.co2EmissionInput);
await co2Input.fill(EmissionFactors.CO2.toString());

await co2Input.fill(EmissionFactos.CO2.toString());
const n2oInput = addEmissionModal.getByTestId(testIds.n2oEmissionInput);
await n2oInput.fill(EmissionFactors.N2O.toString());

const n2oInput = await addEmissionModal.getByTestId(
testIds.n2oEmissionInput,
);

await n2oInput.fill(EmissionFactos.N2O.toString());

const ch4Input = await addEmissionModal.getByTestId(
testIds.ch4EmissionInput,
);

await ch4Input.fill(EmissionFactos.CH4.toString());
const ch4Input = addEmissionModal.getByTestId(testIds.ch4EmissionInput);
await ch4Input.fill(EmissionFactors.CH4.toString());

// try to submit the form
const submitButton = await addEmissionModal.getByTestId(
const submitButton = addEmissionModal.getByTestId(
testIds.addEmissionModalSubmitButton,
);

await submitButton?.click();

// look for error-text within the modal "please select a source reference"
const element = await page.getByText(
"Please select a source reference",
);

// TODO this will fail when using i18n, let's not use getByText if at all possible
const element = page.getByText("Please select a source reference");
expect(element).toBeTruthy();

// fill in the text fields
Expand All @@ -296,63 +284,51 @@ test.describe.serial("Manual Input", () => {

test(`should display newly created activity in activity table in in ${sector.sectorName}`, async () => {
// TODO: Enable these tests when manul input for waste works.
test.skip(sector.sectorName === "Waste");
test.skip(
sector.sectorName === "Waste" ||
sector.sectorName === "Transportation",
);
// wait for the page to load
// wait for the table to load
const table = await page.locator("table");
const table = page.locator("table");

// Ensure the table exists
expect(table).not.toBeNull();
await expect(table).toBeVisible();

const cellWithValue = await page
?.getByRole("cell", { name: "tCO2" })
.first();

expect(cellWithValue).toBeTruthy();
const cellWithValue = page?.getByRole("cell", { name: "tCO2" }).first();
await expect(cellWithValue).toBeVisible();

// Ensure the cell has the correct value
// TODO this is wrong, the final result should be the multiple of activity value and emissions factor
// (or the result of the formula if it's using a different formula than activity-times-emissions-factor)
expect(await cellWithValue?.innerText()).toContain(
EmissionFactos.CO2.toString(),
EmissionFactors.CO2.toString(),
);
});

test(`should delete the activity from the table in in ${sector.sectorName}`, async () => {
test.skip(sector.sectorName === "Waste");
test.skip(
sector.sectorName === "Waste" ||
sector.sectorName === "Transportation",
);
// wait for the page to load
// wait for the table to load
const table = await page.locator("table");

// Ensure the table exists
const table = page.locator("table");
expect(table).not.toBeNull();

const moreButton = await page.getByTestId(testIds.activityMoreButton);

expect(moreButton).toBeTruthy();

await moreButton.click();

const deleteButton = await page.getByTestId(
testIds.deleteActivityButton,
);

expect(deleteButton).toBeTruthy();

await deleteButton.click();
await page.getByTestId(testIds.activityMoreButton).click();
await page.getByTestId(testIds.deleteActivityButton).click();

// wait for the modal to open
await page.waitForTimeout(500);
const deleteModal = await page.getByTestId(
testIds.deleteActivityModalHeader,
);
const deleteModal = page.getByTestId(testIds.deleteActivityModalHeader);
await expect(deleteModal).toBeVisible();

expect(deleteModal).toBeVisible();

const confirmButton = await page.getByTestId(
const confirmButton = page.getByTestId(
testIds.deleteActivityModalConfirmButton,
);

expect(confirmButton).toBeVisible();

await expect(confirmButton).toBeVisible();
await confirmButton.click();

// wait for a 200 response
Expand Down
Loading

0 comments on commit 258f765

Please sign in to comment.