chore: add-tests#15
Conversation
🦋 Changeset detectedLatest commit: 194133a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
View your CI Pipeline Execution ↗ for commit 194133a.
☁️ Nx Cloud last updated this comment at |
|
Deployed eb19543 to https://ForgeRock.github.io/ping-javascript-sdk/pr-15/eb195434f2a94373d5644417ee57680979364276 branch gh-pages in ForgeRock/ping-javascript-sdk |
6012e48 to
b1e4f40
Compare
| CollectorType extends SingleValueCollectorTypes = 'SingleValueCollector', | ||
| >(field: Field, idx: number, collectorType: CollectorType, data?: string) { | ||
| let error = ''; | ||
| console.log('the field ', field); |
There was a problem hiding this comment.
debugging because label was resolving to an error during normalization.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15 +/- ##
==========================================
+ Coverage 50.00% 50.23% +0.23%
==========================================
Files 21 21
Lines 1232 1256 +24
Branches 163 166 +3
==========================================
+ Hits 616 631 +15
- Misses 616 625 +9
🚀 New features to boost your workflow:
|
cae1356 to
72b3ce5
Compare
| @@ -1,6 +1,5 @@ | |||
| name: ForgeRock Pull Request CI | |||
| on: | |||
| pull_request_target: | |||
There was a problem hiding this comment.
this was a mistake to add. sorry. its not what i thought it would do.
| const config: DaVinciConfig = { | ||
| clientId: '724ec718-c41c-4d51-98b0-84a583f450f9', | ||
| redirectUri: window.location.origin + '/', | ||
| const qs = window.location.search; |
There was a problem hiding this comment.
added logic to add clientId param to tests for variability of flows.
| const loginBtn = document.getElementById('logoutButton') as HTMLButtonElement; | ||
| loginBtn.addEventListener('click', async () => { | ||
| await FRUser.logout({ logoutRedirectUri: window.location.href }); | ||
| await FRUser.logout({ logoutRedirectUri: `${window.location.origin}/` }); |
There was a problem hiding this comment.
because of the above changes , fixed this to use origin so it doesnt include the clientId param
| return true; | ||
| } | ||
| }); | ||
| await logoutButton.click(); |
There was a problem hiding this comment.
extended this test to include logout for my own sanity.
9424cab to
e89b4e4
Compare
There was a problem hiding this comment.
this is why i'm adding a changeset.
cerebrl
left a comment
There was a problem hiding this comment.
Got some questions and some suggestions. The biggest concern I have is the test suite code that seems like to have quite a bit of redundancy that doesn't provide any value that I can see.
| await expect(page.getByRole('link', { name: 'Vite logo' })).toBeVisible(); | ||
| await expect(page.getByRole('button', { name: 'Form Validation' })).toBeVisible(); | ||
| await expect(page.locator('#form')).toContainText('Form Validation'); | ||
| await page.getByRole('button', { name: 'Form Validation' }).click(); |
There was a problem hiding this comment.
Why is there a button called "Form Validation"?
There was a problem hiding this comment.
the way the connector is it renders two buttons, one is form validation and one is form fields and then we render those fields out.
| await page.getByRole('textbox', { name: 'Username' }).click(); | ||
| await page.getByRole('textbox', { name: 'Username' }).fill('sdk-user'); |
There was a problem hiding this comment.
I feel like the clicking is not really doing anything, since your reselecting the element to .fill it. We probably should just remove these unneeded .click calls.
| await expect(page.getByText('Username')).toBeVisible(); | ||
| await expect(page.getByRole('textbox', { name: 'Username' })).toBeVisible(); |
There was a problem hiding this comment.
Couldn't these two lines be collapsed into a .getByLabel selector?
| await page.getByRole('textbox', { name: 'Username' }).fill('sdk-user'); | ||
| await expect(page.getByRole('textbox', { name: 'Username' })).toHaveValue('sdk-user'); | ||
| await page.getByRole('textbox', { name: 'Email Address' }).click(); | ||
| await page.getByRole('textbox', { name: 'Email Address' }).fill('sdk-user@user.com'); |
There was a problem hiding this comment.
I feel like this is quite redundant. I personally feel this could be reduced to a page.getByLabel('Username').fill('demouser');. That would, how I understand it, reproduce the same result with no loss of testing.
| await page.getByRole('heading', { name: 'Select Test Form' }).click(); | ||
| await page.getByRole('button', { name: 'Form Fields' }).click(); | ||
| await page.getByRole('textbox', { name: 'Text Input Label' }).click(); | ||
| await page.getByRole('textbox', { name: 'Text Input Label' }).click(); | ||
|
|
||
| const txtInput = page.getByRole('textbox', { name: 'Text Input Label' }); | ||
| await txtInput.fill('This is some text'); | ||
| expect(txtInput).toHaveValue('This is some text'); | ||
|
|
||
| const flowLink = page.getByRole('button', { name: 'Flow Link' }); | ||
| await flowLink.click(); | ||
|
|
||
| const flowButton = page.getByRole('button', { name: 'Flow Button' }); | ||
| await flowButton.click(); | ||
|
|
||
| const requestPromise = page.waitForRequest((request) => request.url().includes('/customForm')); | ||
| await page.getByRole('button', { name: 'Submit' }).click(); | ||
| const request = await requestPromise; | ||
| const parsedData = JSON.parse(request.postData()); | ||
| const data = parsedData.parameters.data; | ||
| expect(data.actionKey).toBe('submit'); | ||
| expect(data.formData).toEqual({ | ||
| // leaving this here because it should be fixed and we would have a failing test when we do fix import { } from "// to remind us to update the test" | ||
| ['undefined']: '', | ||
| ['text-input-key']: 'This is some text', | ||
| ['dropdown-field-key']: '', | ||
| ['radio-group-key']: '', | ||
| }); | ||
| }); |
There was a problem hiding this comment.
I can't figure out what this is actually doing/testing. Can you elaborate?
There was a problem hiding this comment.
well we are going to test that when we click to send off the customForm request, we are sending the data correctly in the actual request.
| expect(data.formData).toEqual({ | ||
| ['undefined']: '', | ||
| 'user.username': '', | ||
| 'user.password': '', | ||
| 'user.email': '', | ||
| }); |
There was a problem hiding this comment.
Why are we expecting these values to be empty strings?
There was a problem hiding this comment.
Because i was leaving this here so the test would fail once your PR was merged. which happened
| const hasNextUrl = () => { | ||
| const data = cacheEntry.data; | ||
|
|
||
| if ('_links' in data) { | ||
| if ('next' in data._links) { | ||
| if ('href' in data._links.next) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
| }; |
There was a problem hiding this comment.
I feel like this should be a pure, stateless utility that could be used for fetching any property within _links. This could be reused in other portions of the project.
7857a22 to
d495187
Compare
d495187 to
d430d9e
Compare
|
|
||
| return function (value: string, index?: number) { | ||
| try { | ||
| console.log('the value', value); |
There was a problem hiding this comment.
We should probably remove this.
| if ( | ||
| collectorToUpdate.category !== 'SingleValueCollector' && | ||
| collectorToUpdate.category !== 'ValidatedSingleValueCollector' | ||
| ) { |
There was a problem hiding this comment.
Did I miss checking for MultiValueCollectors as well?
d430d9e to
c3d1da1
Compare
form-field validations were not being sent in requests.
c3d1da1 to
33d3bb3
Compare
33d3bb3 to
194133a
Compare
JIRA Ticket
https://pingidentity.atlassian.net/browse/SDKS-3677
Description
Adds some testing, added a test to the "basic" suite because i wanted to make sure logout worked.
This is probably dependent on a WIP story because the fields flow uses things like password verify and label which im purposefully asserting as undefined.
When that work is done and this gets rebased, i'd expect these tests to fail