Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ REACT_APP_ENABLE_TOOLTIPS=true
REACT_APP_ENABLE_STAKEHOLDERS=true
REACT_APP_KEYCLOAK_URL=https://dev-k8s.treetracker.org/keycloak
REACT_APP_KEYCLOAK_REALM=treetracker
REACT_APP_KEYCLOAK_CLIENT_ID=treetracker-admin-client
REACT_APP_KEYCLOAK_CLIENT_ID=treetracker-admin-client-fe
3 changes: 2 additions & 1 deletion features/login.feature
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Feature: Login

@skip
Scenario: Login with wrong credentials shows an error message
Given I am on the login page
When I enter username "admin" and password "wrongpwd"
And I click the login button
Then I should see an error message


@skip
Scenario: Login with valid credentials succeeds
Given I am on the login page
When I enter username "user-test-treetracker-admin-client" and password "LjyxVk4t5^yx&!Gl"
Expand Down
1 change: 0 additions & 1 deletion features/organization.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Feature: Organization Features
We allow user to apply for an organization, as an organization, user can approve or reject trees, manage grower under the org.
Check the `docs/organization-onboarding.md` for more details.

@skip
Scenario: Apply for an organization
Given I am registered user
And I am on the organization application page
Expand Down
98 changes: 98 additions & 0 deletions features/page-objects/OrganizationPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
class OrganizationPage {
get nameInput() {
return $('#organization-name');
}

get emailInput() {
return $('#organization-email');
}

get phoneInput() {
return $('#organization-phone');
}

get websiteInput() {
return $('#organization-website');
}

get logoUrlInput() {
return $('#organization-logo-url');
}

get mapNameInput() {
return $('#organization-map-name');
}

get submitButton() {
return $('button[type="submit"]');
}

get successAlert() {
return $('div=Organization created successfully.');
}

get verifyMenuItem() {
return $('a=Verify');
}

async waitForPage() {
await this.nameInput.waitForDisplayed({ timeout: 10000 });
await this.emailInput.waitForDisplayed({ timeout: 10000 });
}

async fillOrganizationDetails(details) {
await this.waitForPage();

await this.nameInput.setValue(details.name);
await this.emailInput.setValue(details.email);
await this.phoneInput.setValue(details.phone);
await this.websiteInput.setValue(details.website);
await this.logoUrlInput.setValue(details.logoUrl);
await this.mapNameInput.setValue(details.mapName);
}

async submit() {
await this.submitButton.waitForDisplayed({ timeout: 10000 });
await this.submitButton.click();
}

async waitForConfirmation() {
await this.successAlert.waitForDisplayed({
timeout: 60000,
timeoutMsg:
'Expected a confirmation message after submitting organization details',
});
}

async waitForHomeRedirect() {
const baseUrl = browser.options.baseUrl;

await browser.waitUntil(
async () => {
const currentUrl = await browser.getUrl();

if (!baseUrl || !currentUrl.startsWith(baseUrl)) {
return false;
}

return new URL(currentUrl).pathname === '/';
},
{
timeout: 60000,
interval: 500,
timeoutMsg:
'Expected organization submit flow to return to the home page',
}
);
}

async waitForVerifyMenuItem() {
await this.verifyMenuItem.waitForDisplayed({
timeout: 60000,
timeoutMsg:
'Expected the Verify menu item to be visible after onboarding',
});
}
}

module.exports = new OrganizationPage();
102 changes: 102 additions & 0 deletions features/step-definitions/organization.steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
const { Given, When, Then } = require('@cucumber/cucumber');

const LoginPage = require('../page-objects/LoginPage');
const OrganizationPage = require('../page-objects/OrganizationPage');

const LOG_OUT_BUTTON = 'button=LOG OUT';
const USERNAME = 'user-test-treetracker-admin-client';
const PASSWORD = 'LjyxVk4t5^yx&!Gl';

let organizationDetails;

async function navigate(path) {
await browser.url(path, { wait: 'none' });
}

async function isExisting(selector) {
return $(selector)
.isExisting()
.catch(() => false);
}

async function openKeycloakLoginPage() {
await navigate('/login');

if (await LoginPage.isOpen()) {
await LoginPage.waitForPage();
return;
}

await navigate('/account');

try {
await browser.waitUntil(
async () =>
(await LoginPage.isOpen()) || (await isExisting(LOG_OUT_BUTTON)),
{ timeout: 15000, interval: 250 }
);
} catch {
await navigate('/login');
await LoginPage.waitForPage();
return;
}

if (await LoginPage.isOpen()) {
await LoginPage.waitForPage();
return;
}

const logoutButton = $(LOG_OUT_BUTTON);
await logoutButton.waitForDisplayed({ timeout: 10000 });
await logoutButton.scrollIntoView();
await logoutButton.click();
await LoginPage.waitForPage();
}

function buildOrganizationDetails() {
const timestamp = Date.now();

return {
name: `Organization BDD ${timestamp}`,
email: `organization-bdd-${timestamp}@example.com`,
phone: '+23270000000',
website: `https://example.com/organization-bdd-${timestamp}`,
logoUrl: 'https://example.com/logo.png',
mapName: `freetown-${timestamp}`,
};
}

Given('I am registered user', async () => {
await openKeycloakLoginPage();
await LoginPage.login(USERNAME, PASSWORD);
await LoginPage.waitForSuccessfulRedirect();
});

Given('I am on the organization application page', async () => {
await browser.url('/organization/apply');
await OrganizationPage.waitForPage();
});

When('I fill in the organization details', async () => {
organizationDetails = buildOrganizationDetails();
await OrganizationPage.fillOrganizationDetails(organizationDetails);
});

When('I submit the form', async () => {
await OrganizationPage.submit();
});

Then('I should see a confirmation message', async () => {
await OrganizationPage.waitForConfirmation();
});

Then('Go the home page', async () => {
await OrganizationPage.waitForHomeRedirect();
});

Then(
'I should see the `verify` menu item on the menu bar on the top left',
async () => {
await OrganizationPage.waitForVerifyMenuItem();
}
);
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.1",
"assert": "npm:assert",
"axios": "^1.13.6",
"axios": "1.13.6",
"chart.js": "^3.7.1",
"classnames": "*",
"d3": "^5.16.0",
Expand Down Expand Up @@ -54,6 +54,7 @@
"redux": "^4.0.5",
"stream": "npm:stream-browserify",
"typeface-roboto": "*",
"zod": "^4.3.6",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greenstand also use joi, for schema verification, but up to you to deceide which one to use

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i m more familiar with zod that is why i used it

"zxcvbn": "^4.4.2"
},
"scripts": {
Expand Down
Binary file not shown.
9 changes: 0 additions & 9 deletions reports/allure-html/data/attachments/104cbfe65382e93.txt

This file was deleted.

3 changes: 0 additions & 3 deletions reports/allure-html/data/attachments/105219bbaba282e9.txt

This file was deleted.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions reports/allure-html/data/attachments/11f6f367fd0372b9.txt

This file was deleted.

9 changes: 9 additions & 0 deletions reports/allure-html/data/attachments/12222ca9157f6f8d.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"script": "<script> [8489 bytes]",
"args": [
{
"element-6066-11e4-a52e-4f735466cecf": "f.8EE896DAA7B8DEB49D4FD3C2E89579EC.d.838EB47B42987EAA8583B08819B3F155.e.17",
"ELEMENT": "f.8EE896DAA7B8DEB49D4FD3C2E89579EC.d.838EB47B42987EAA8583B08819B3F155.e.17"
}
]
}

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions reports/allure-html/data/attachments/1430a5eb9b59e573.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{
"element-6066-11e4-a52e-4f735466cecf": "f.8EE896DAA7B8DEB49D4FD3C2E89579EC.d.838EB47B42987EAA8583B08819B3F155.e.3"
}
]
Binary file not shown.
9 changes: 9 additions & 0 deletions reports/allure-html/data/attachments/14e697d93f2f6a13.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"script": "<script> [8489 bytes]",
"args": [
{
"element-6066-11e4-a52e-4f735466cecf": "f.321E16C334E69F39FA610DF494370409.d.DA90D4CC25D46B4DCF7722A1F8FE47EB.e.17",
"ELEMENT": "f.321E16C334E69F39FA610DF494370409.d.DA90D4CC25D46B4DCF7722A1F8FE47EB.e.17"
}
]
}
9 changes: 9 additions & 0 deletions reports/allure-html/data/attachments/152b22bd11751ae9.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"script": "<script> [8489 bytes]",
"args": [
{
"element-6066-11e4-a52e-4f735466cecf": "f.321E16C334E69F39FA610DF494370409.d.DCB7C0B21670D89108B3E508A2FF5130.e.2",
"ELEMENT": "f.321E16C334E69F39FA610DF494370409.d.DCB7C0B21670D89108B3E508A2FF5130.e.2"
}
]
}
9 changes: 9 additions & 0 deletions reports/allure-html/data/attachments/153e6787e9154666.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"script": "<script> [8489 bytes]",
"args": [
{
"element-6066-11e4-a52e-4f735466cecf": "f.321E16C334E69F39FA610DF494370409.d.DCB7C0B21670D89108B3E508A2FF5130.e.2",
"ELEMENT": "f.321E16C334E69F39FA610DF494370409.d.DCB7C0B21670D89108B3E508A2FF5130.e.2"
}
]
}
Binary file not shown.
3 changes: 3 additions & 0 deletions reports/allure-html/data/attachments/1664f198a6da3cdb.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"element-6066-11e4-a52e-4f735466cecf": "f.8EE896DAA7B8DEB49D4FD3C2E89579EC.d.AAC1AD0038D70BC6E5695536CAF18A31.e.40"
}
5 changes: 5 additions & 0 deletions reports/allure-html/data/attachments/170f41a808382411.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{
"element-6066-11e4-a52e-4f735466cecf": "f.8EE896DAA7B8DEB49D4FD3C2E89579EC.d.93ED94C3D4B67CFF42E03B6DFD1500CB.e.3"
}
]
9 changes: 9 additions & 0 deletions reports/allure-html/data/attachments/176375624ca2f654.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"script": "<script> [8489 bytes]",
"args": [
{
"element-6066-11e4-a52e-4f735466cecf": "f.321E16C334E69F39FA610DF494370409.d.59F4CC60DD98172007CFCD242F89B0FF.e.2",
"ELEMENT": "f.321E16C334E69F39FA610DF494370409.d.59F4CC60DD98172007CFCD242F89B0FF.e.2"
}
]
}
Binary file not shown.

This file was deleted.

5 changes: 0 additions & 5 deletions reports/allure-html/data/attachments/17c59fa8756b5188.txt

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions reports/allure-html/data/attachments/192c18209b1e7d03.txt

This file was deleted.

This file was deleted.

3 changes: 3 additions & 0 deletions reports/allure-html/data/attachments/195e81bb1dcef7da.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"element-6066-11e4-a52e-4f735466cecf": "f.8EE896DAA7B8DEB49D4FD3C2E89579EC.d.AAC1AD0038D70BC6E5695536CAF18A31.e.30"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://localhost:3001/organization/apply
3 changes: 0 additions & 3 deletions reports/allure-html/data/attachments/1a2932fe354223b0.txt

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading
Loading