-
Notifications
You must be signed in to change notification settings - Fork 204
feat: add page for creating org #1179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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(); |
| 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(); | ||
| } | ||
| ); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| 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.
| 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" | ||
| } | ||
| ] |
| 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" | ||
| } | ||
| ] | ||
| } |
| 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" | ||
| } | ||
| ] | ||
| } |
| 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" | ||
| } | ||
| ] | ||
| } |
| 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" | ||
| } |
| 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" | ||
| } | ||
| ] |
| 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" | ||
| } | ||
| ] | ||
| } |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| 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" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| http://localhost:3001/organization/apply |
This file was deleted.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
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 useThere was a problem hiding this comment.
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