-
Notifications
You must be signed in to change notification settings - Fork 6
feat: multi-currency support and E2E tests for Kotlin sample #306
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
Open
pengying
wants to merge
4
commits into
main
Choose a base branch
from
feat/sample-multi-currency-e2e-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9f0f598
feat: multi-currency support, E2E tests for Kotlin sample app
pengying eae72de
docs: add test instructions to Kotlin sample README
pengying 269bab3
fix: update external account fields to match per-country requirements
pengying b3383ac
fix: use countryOfResidence instead of nationality for beneficiary
pengying File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| import { test, expect } from '@playwright/test' | ||
|
|
||
| // These tests drive the full React UI against the running Kotlin backend + Grid sandbox API. | ||
| // Prerequisites: `cd samples/kotlin && ./gradlew run` must be running on port 8080. | ||
|
|
||
| test.describe('Payout Flow', () => { | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto('/') | ||
| await expect(page.locator('h1')).toHaveText('Grid API Sample') | ||
| }) | ||
|
|
||
| test('page loads with step 1 active', async ({ page }) => { | ||
| const step1 = page.locator('h3', { hasText: '1. Create Customer' }) | ||
| await expect(step1).toBeVisible() | ||
|
|
||
| // Create Customer button should be enabled | ||
| await expect(page.getByRole('button', { name: 'Create Customer' })).toBeEnabled() | ||
| }) | ||
|
|
||
| test('create customer advances to step 2', async ({ page }) => { | ||
| await page.getByRole('button', { name: 'Create Customer' }).click() | ||
|
|
||
| // Wait for step 2 to become active | ||
| await expect(page.getByRole('button', { name: 'Create External Account' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Step 1 should show a green checkmark summary with ID | ||
| const step1Summary = page.locator('span.text-green-400.font-mono') | ||
| await expect(step1Summary.first()).toContainText('ID:') | ||
|
|
||
| // Country dropdown should be visible | ||
| await expect(page.locator('#destination-country')).toBeVisible() | ||
| }) | ||
|
|
||
| test('country dropdown changes the JSON body', async ({ page }) => { | ||
| await page.getByRole('button', { name: 'Create Customer' }).click() | ||
| await expect(page.getByRole('button', { name: 'Create External Account' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Default country (IN) should populate the textarea | ||
| const textarea = page.locator('textarea').nth(1) | ||
|
|
||
| // Switch to India | ||
| await page.locator('#destination-country').selectOption('IN') | ||
| await expect(textarea).toHaveValue(/INR_ACCOUNT/, { timeout: 3_000 }) | ||
| await expect(textarea).toHaveValue(/vpa/) | ||
|
|
||
| // Switch to Brazil | ||
| await page.locator('#destination-country').selectOption('BR') | ||
| await expect(textarea).toHaveValue(/BRL_ACCOUNT/, { timeout: 3_000 }) | ||
| await expect(textarea).toHaveValue(/pixKey/) | ||
| }) | ||
|
|
||
| test('full flow: customer → external account → quote', async ({ page }) => { | ||
| // Step 1: Create Customer | ||
| await page.getByRole('button', { name: 'Create Customer' }).click() | ||
| await expect(page.getByRole('button', { name: 'Create External Account' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Step 2: Create External Account (default country) | ||
| await page.getByRole('button', { name: 'Create External Account' }).click() | ||
| await expect(page.getByRole('button', { name: 'Create Quote' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Step 2 summary should show ID | ||
| const summaries = page.locator('span.text-green-400.font-mono') | ||
| await expect(summaries.nth(1)).toContainText('ID:') | ||
|
|
||
| // Step 3: Source currency dropdown should be visible | ||
| await expect(page.locator('#source-currency')).toBeVisible() | ||
|
|
||
| // Verify quote JSON body has the right structure | ||
| const quoteTextarea = page.locator('textarea').last() | ||
| await expect(quoteTextarea).toHaveValue(/REALTIME_FUNDING/) | ||
| await expect(quoteTextarea).toHaveValue(/"currency": "USD"/) | ||
|
|
||
| // Create Quote | ||
| await page.getByRole('button', { name: 'Create Quote' }).click() | ||
| await expect(page.getByRole('button', { name: 'Send Sandbox Funds' })).toBeEnabled({ timeout: 15_000 }) | ||
| }) | ||
|
|
||
| test('full flow with India INR', async ({ page }) => { | ||
| // Step 1: Create Customer | ||
| await page.getByRole('button', { name: 'Create Customer' }).click() | ||
| await expect(page.getByRole('button', { name: 'Create External Account' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Step 2: Switch to India and create account | ||
| await page.locator('#destination-country').selectOption('IN') | ||
| await expect(page.locator('textarea').nth(1)).toHaveValue(/INR_ACCOUNT/, { timeout: 3_000 }) | ||
| await page.getByRole('button', { name: 'Create External Account' }).click() | ||
| await expect(page.getByRole('button', { name: 'Create Quote' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Step 3: Create Quote | ||
| await page.getByRole('button', { name: 'Create Quote' }).click() | ||
| await expect(page.getByRole('button', { name: 'Send Sandbox Funds' })).toBeEnabled({ timeout: 15_000 }) | ||
| }) | ||
|
|
||
| test('source currency dropdown updates quote body', async ({ page }) => { | ||
| // Step 1 + 2: Get to quote step | ||
| await page.getByRole('button', { name: 'Create Customer' }).click() | ||
| await expect(page.getByRole('button', { name: 'Create External Account' })).toBeEnabled({ timeout: 15_000 }) | ||
| await page.getByRole('button', { name: 'Create External Account' }).click() | ||
| await expect(page.getByRole('button', { name: 'Create Quote' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Default should be USD | ||
| const quoteTextarea = page.locator('textarea').last() | ||
| await expect(quoteTextarea).toHaveValue(/"currency": "USD"/) | ||
|
|
||
| // Switch to USDC | ||
| await page.locator('#source-currency').selectOption('USDC') | ||
| await expect(quoteTextarea).toHaveValue(/"currency": "USDC"/, { timeout: 3_000 }) | ||
|
|
||
| // Description text should update | ||
| await expect(page.getByText('USDC →')).toBeVisible() | ||
| }) | ||
|
|
||
| test('Start New Payment resets to step 2', async ({ page }) => { | ||
| // Step 1: Create Customer | ||
| await page.getByRole('button', { name: 'Create Customer' }).click() | ||
| await expect(page.getByRole('button', { name: 'Create External Account' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Step 2: Create External Account | ||
| await page.getByRole('button', { name: 'Create External Account' }).click() | ||
| await expect(page.getByRole('button', { name: 'Create Quote' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Click Start New Payment | ||
| await page.getByRole('button', { name: 'Start New Payment' }).click() | ||
|
|
||
| // Should be back at step 2 with external account button enabled | ||
| await expect(page.getByRole('button', { name: 'Create External Account' })).toBeEnabled() | ||
|
|
||
| // Step 3 should be future (dimmed), quote button should not be visible | ||
| await expect(page.getByRole('button', { name: 'Create Quote' })).not.toBeVisible() | ||
| }) | ||
|
|
||
| test('full payout flow including sandbox funding', async ({ page }) => { | ||
| // Step 1: Create Customer | ||
| await page.getByRole('button', { name: 'Create Customer' }).click() | ||
| await expect(page.getByRole('button', { name: 'Create External Account' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Step 2: Create External Account (default country) | ||
| await page.getByRole('button', { name: 'Create External Account' }).click() | ||
| await expect(page.getByRole('button', { name: 'Create Quote' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Step 3: Create Quote | ||
| await page.getByRole('button', { name: 'Create Quote' }).click() | ||
| await expect(page.getByRole('button', { name: 'Send Sandbox Funds' })).toBeEnabled({ timeout: 15_000 }) | ||
|
|
||
| // Step 4: Send Sandbox Funds | ||
| await page.getByRole('button', { name: 'Send Sandbox Funds' }).click() | ||
|
|
||
| // After funding, all 4 steps should be completed (4 green checkmarks) | ||
| const checkmarks = page.locator('text=✓') | ||
| await expect(checkmarks).toHaveCount(4, { timeout: 15_000 }) | ||
| }) | ||
| }) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { defineConfig } from '@playwright/test' | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './e2e', | ||
| timeout: 60_000, | ||
| expect: { timeout: 15_000 }, | ||
| use: { | ||
| baseURL: 'http://localhost:8080', | ||
| trace: 'on-first-retry', | ||
| }, | ||
| retries: 0, | ||
| projects: [ | ||
| { name: 'chromium', use: { browserName: 'chromium' } }, | ||
| ], | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.