Skip to content

Commit cedfddd

Browse files
committed
feat: add form for adding org on home page
1 parent 79e837c commit cedfddd

1,462 files changed

Lines changed: 2144 additions & 677 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

features/organization.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ Feature: Organization Features
22
We allow user to apply for an organization, as an organization, user can approve or reject trees, manage grower under the org.
33
Check the `docs/organization-onboarding.md` for more details.
44

5-
@skip
65
Scenario: Apply for an organization
76
Given I am registered user
87
And I am on the organization application page
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
class OrganizationPage {
2+
get nameInput() {
3+
return $('#organization-name');
4+
}
5+
6+
get emailInput() {
7+
return $('#organization-email');
8+
}
9+
10+
get phoneInput() {
11+
return $('#organization-phone');
12+
}
13+
14+
get websiteInput() {
15+
return $('#organization-website');
16+
}
17+
18+
get logoUrlInput() {
19+
return $('#organization-logo-url');
20+
}
21+
22+
get mapNameInput() {
23+
return $('#organization-map-name');
24+
}
25+
26+
get submitButton() {
27+
return $('button[type="submit"]');
28+
}
29+
30+
get successAlert() {
31+
return $('div=Organization created successfully.');
32+
}
33+
34+
get verifyMenuItem() {
35+
return $('a=Verify');
36+
}
37+
38+
async waitForPage() {
39+
await this.nameInput.waitForDisplayed({ timeout: 10000 });
40+
await this.emailInput.waitForDisplayed({ timeout: 10000 });
41+
}
42+
43+
async fillOrganizationDetails(details) {
44+
await this.waitForPage();
45+
46+
await this.nameInput.setValue(details.name);
47+
await this.emailInput.setValue(details.email);
48+
await this.phoneInput.setValue(details.phone);
49+
await this.websiteInput.setValue(details.website);
50+
await this.logoUrlInput.setValue(details.logoUrl);
51+
await this.mapNameInput.setValue(details.mapName);
52+
}
53+
54+
async submit() {
55+
await this.submitButton.waitForDisplayed({ timeout: 10000 });
56+
await this.submitButton.click();
57+
}
58+
59+
async waitForConfirmation() {
60+
await this.successAlert.waitForDisplayed({
61+
timeout: 60000,
62+
timeoutMsg:
63+
'Expected a confirmation message after submitting organization details',
64+
});
65+
}
66+
67+
async waitForHomeRedirect() {
68+
const baseUrl = browser.options.baseUrl;
69+
70+
await browser.waitUntil(
71+
async () => {
72+
const currentUrl = await browser.getUrl();
73+
74+
if (!baseUrl || !currentUrl.startsWith(baseUrl)) {
75+
return false;
76+
}
77+
78+
return new URL(currentUrl).pathname === '/';
79+
},
80+
{
81+
timeout: 60000,
82+
interval: 500,
83+
timeoutMsg:
84+
'Expected organization submit flow to return to the home page',
85+
}
86+
);
87+
}
88+
89+
async waitForVerifyMenuItem() {
90+
await this.verifyMenuItem.waitForDisplayed({
91+
timeout: 60000,
92+
timeoutMsg:
93+
'Expected the Verify menu item to be visible after onboarding',
94+
});
95+
}
96+
}
97+
98+
module.exports = new OrganizationPage();
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
const { Given, When, Then } = require('@cucumber/cucumber');
2+
3+
const LoginPage = require('../page-objects/LoginPage');
4+
const OrganizationPage = require('../page-objects/OrganizationPage');
5+
6+
const LOG_OUT_BUTTON = 'button=LOG OUT';
7+
const USERNAME = 'user-test-treetracker-admin-client';
8+
const PASSWORD = 'LjyxVk4t5^yx&!Gl';
9+
10+
let organizationDetails;
11+
12+
async function navigate(path) {
13+
await browser.url(path, { wait: 'none' });
14+
}
15+
16+
async function isExisting(selector) {
17+
return $(selector)
18+
.isExisting()
19+
.catch(() => false);
20+
}
21+
22+
async function openKeycloakLoginPage() {
23+
await navigate('/login');
24+
25+
if (await LoginPage.isOpen()) {
26+
await LoginPage.waitForPage();
27+
return;
28+
}
29+
30+
await navigate('/account');
31+
32+
try {
33+
await browser.waitUntil(
34+
async () =>
35+
(await LoginPage.isOpen()) || (await isExisting(LOG_OUT_BUTTON)),
36+
{ timeout: 15000, interval: 250 }
37+
);
38+
} catch {
39+
await navigate('/login');
40+
await LoginPage.waitForPage();
41+
return;
42+
}
43+
44+
if (await LoginPage.isOpen()) {
45+
await LoginPage.waitForPage();
46+
return;
47+
}
48+
49+
const logoutButton = $(LOG_OUT_BUTTON);
50+
await logoutButton.waitForDisplayed({ timeout: 10000 });
51+
await logoutButton.scrollIntoView();
52+
await logoutButton.click();
53+
await LoginPage.waitForPage();
54+
}
55+
56+
function buildOrganizationDetails() {
57+
const timestamp = Date.now();
58+
59+
return {
60+
name: `Organization BDD ${timestamp}`,
61+
email: `organization-bdd-${timestamp}@example.com`,
62+
phone: '+23270000000',
63+
website: `https://example.com/organization-bdd-${timestamp}`,
64+
logoUrl: 'https://example.com/logo.png',
65+
mapName: `freetown-${timestamp}`,
66+
};
67+
}
68+
69+
Given('I am registered user', async () => {
70+
await openKeycloakLoginPage();
71+
await LoginPage.login(USERNAME, PASSWORD);
72+
await LoginPage.waitForSuccessfulRedirect();
73+
});
74+
75+
Given('I am on the organization application page', async () => {
76+
await browser.url('/organization/apply');
77+
await OrganizationPage.waitForPage();
78+
});
79+
80+
When('I fill in the organization details', async () => {
81+
organizationDetails = buildOrganizationDetails();
82+
await OrganizationPage.fillOrganizationDetails(organizationDetails);
83+
});
84+
85+
When('I submit the form', async () => {
86+
await OrganizationPage.submit();
87+
});
88+
89+
Then('I should see a confirmation message', async () => {
90+
await OrganizationPage.waitForConfirmation();
91+
});
92+
93+
Then('Go the home page', async () => {
94+
await OrganizationPage.waitForHomeRedirect();
95+
});
96+
97+
Then(
98+
'I should see the `verify` menu item on the menu bar on the top left',
99+
async () => {
100+
await OrganizationPage.waitForVerifyMenuItem();
101+
}
102+
);

reports/allure-html/data/attachments/1dc451b3c2d69887.txt renamed to reports/allure-html/data/attachments/104a7c397b6b7426.txt

File renamed without changes.
-817 KB
Binary file not shown.

reports/allure-html/data/attachments/104cbfe65382e93.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

reports/allure-html/data/attachments/105219bbaba282e9.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

reports/allure-html/data/attachments/10c98e57a46d2c94.png renamed to reports/allure-html/data/attachments/1080c90a17d2609c.png

File renamed without changes.

reports/allure-html/data/attachments/12ed601775572b03.png renamed to reports/allure-html/data/attachments/11286e4b3785e9ff.png

File renamed without changes.

reports/allure-html/data/attachments/11457800e8e5ca25.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)