Skip to content

Commit e600c7e

Browse files
committed
chore: pr-comments
1 parent 63e94aa commit e600c7e

9 files changed

Lines changed: 71 additions & 31 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ runs:
3131
registry-url: 'https://registry.npmjs.org'
3232

3333
- name: Update npm
34-
run: npm install -g npm@latest
34+
run: |
35+
corepack enable
36+
corepack install -g npm@latest
3537
shell: bash
3638

3739
- name: Install dependencies

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
with:
3333
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3434

35-
- run: npx nx-cloud fix-ci
35+
- run: pnpm nx fix-ci
3636
if: always()
3737

3838
- uses: codecov/codecov-action@v5

e2e/davinci-app/components/qr-code.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export default function (formEl: HTMLFormElement, collector: QrCodeCollector) {
2222
img.setAttribute('data-testid', 'qr-code-image');
2323
container.appendChild(img);
2424

25-
if (collector.output.fallbackText) {
25+
if (collector.output.label) {
2626
const fallback = document.createElement('p');
27-
fallback.innerText = `Manual code: ${collector.output.fallbackText}`;
27+
fallback.innerText = `Manual code: ${collector.output.label}`;
2828
fallback.setAttribute('data-testid', 'qr-code-fallback');
2929
container.appendChild(fallback);
3030
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
3+
*
4+
* This software may be modified and distributed under the terms
5+
* of the MIT license. See the LICENSE file for details.
6+
*/
7+
import { expect, test } from '@playwright/test';
8+
import { asyncEvents } from './utils/async-events.js';
9+
import { password, username } from './utils/demo-user.js';
10+
11+
const qrCodeUrl =
12+
'/?clientId=c12743f9-08e8-4420-a624-71bbb08e9fe1&acr_values=9da1b93991bcd577947da228ad4c741f';
13+
14+
test('QR code renders after navigating through device registration flow', async ({ page }) => {
15+
const { navigate } = asyncEvents(page);
16+
17+
await navigate(qrCodeUrl);
18+
19+
// Step 1: Login
20+
await page.getByRole('button', { name: 'USER_LOGIN' }).click();
21+
await page.waitForEvent('requestfinished');
22+
23+
await page.getByLabel('Username').fill(username);
24+
await page.getByLabel('Password').fill(password);
25+
await page.getByRole('button', { name: 'Sign On' }).click();
26+
await page.waitForEvent('requestfinished');
27+
28+
// Step 2: Select device registration
29+
await page.getByRole('button', { name: 'DEVICE_REGISTRATION' }).click();
30+
await page.waitForEvent('requestfinished');
31+
32+
// Step 3: Choose "Mobile App" from the device selection screen
33+
await expect(page.getByText('MFA Device Selection - Registration')).toBeVisible();
34+
await page.getByRole('button', { name: 'Mobile App' }).click();
35+
await page.waitForEvent('requestfinished');
36+
37+
// Step 4: QR code should now be visible
38+
const qrImage = page.locator('[data-testid="qr-code-image"]');
39+
await expect(qrImage).toBeVisible({ timeout: 10000 });
40+
41+
// Verify the image has a base64-encoded src
42+
const src = await qrImage.getAttribute('src');
43+
expect(src).toBeTruthy();
44+
expect(src).toContain('data:image/png;base64,');
45+
46+
// Verify fallback text is displayed if present
47+
const fallback = page.locator('[data-testid="qr-code-fallback"]');
48+
const fallbackVisible = await fallback.isVisible();
49+
if (fallbackVisible) {
50+
const fallbackText = await fallback.textContent();
51+
expect(fallbackText).toBeTruthy();
52+
}
53+
});

packages/davinci-client/src/lib/collector.types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@ export interface QrCodeCollectorBase {
508508
label: string;
509509
type: string;
510510
src: string;
511-
fallbackText: string;
512511
};
513512
}
514513

packages/davinci-client/src/lib/collector.utils.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ describe('No Value Collectors', () => {
812812
});
813813

814814
describe('returnQrCodeCollector', () => {
815-
it('should return a valid QrCodeCollector with src and fallbackText', () => {
815+
it('should return a valid QrCodeCollector with src and label from fallbackText', () => {
816816
const mockField: QrCodeField = {
817817
type: 'QR_CODE',
818818
key: 'qr-code-field',
@@ -828,10 +828,9 @@ describe('returnQrCodeCollector', () => {
828828
name: 'qr-code-field-2',
829829
output: {
830830
key: 'qr-code-field-2',
831-
label: 'data:image/png;base64,abc123',
831+
label: '04ZKS2KCIWKXT8FHRX',
832832
type: 'QR_CODE',
833833
src: 'data:image/png;base64,abc123',
834-
fallbackText: '04ZKS2KCIWKXT8FHRX',
835834
},
836835
});
837836
});
@@ -851,10 +850,9 @@ describe('returnQrCodeCollector', () => {
851850
name: 'qr-code-field-0',
852851
output: {
853852
key: 'qr-code-field-0',
854-
label: 'data:image/png;base64,abc123',
853+
label: '',
855854
type: 'QR_CODE',
856855
src: 'data:image/png;base64,abc123',
857-
fallbackText: '',
858856
},
859857
});
860858
});

packages/davinci-client/src/lib/collector.utils.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ export function returnObjectValueCollector(
680680
* @returns {NoValueCollector} The constructed NoValueCollector object.
681681
*/
682682
export function returnNoValueCollector<
683-
Field extends ReadOnlyField,
683+
Field extends ReadOnlyField | QrCodeField,
684684
CollectorType extends NoValueCollectorTypes = 'NoValueCollector',
685685
>(field: Field, idx: number, collectorType: CollectorType) {
686686
let error = '';
@@ -722,31 +722,20 @@ export function returnReadOnlyCollector(field: ReadOnlyField, idx: number) {
722722
* @returns {QrCodeCollectorBase} The constructed QrCodeCollector object.
723723
*/
724724
export function returnQrCodeCollector(field: QrCodeField, idx: number): QrCodeCollectorBase {
725-
let error = '';
726-
if (!('content' in field) || !field.content) {
727-
error = `${error}Content is not found in the field object. `;
728-
}
725+
const base = returnNoValueCollector(field, idx, 'QrCodeCollector');
726+
727+
let error = base.error || '';
729728
if (!('key' in field) || !field.key) {
730729
error = `${error}Key is not found in the field object. `;
731730
}
732-
if (!('type' in field)) {
733-
error = `${error}Type is not found in the field object. `;
734-
}
735-
736-
const key = field.key || field.type;
737731

738732
return {
739-
category: 'NoValueCollector',
733+
...base,
740734
error: error || null,
741-
type: 'QrCodeCollector',
742-
id: `${key}-${idx}`,
743-
name: `${key}-${idx}`,
744735
output: {
745-
key: `${key}-${idx}`,
746-
label: field.content || '',
747-
type: field.type,
736+
...base.output,
737+
label: field.fallbackText || '',
748738
src: field.content || '',
749-
fallbackText: field.fallbackText || '',
750739
},
751740
};
752741
}

packages/davinci-client/src/lib/node.reducer.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,9 @@ describe('The node collector reducer', () => {
442442
name: 'qr-code-field-0',
443443
output: {
444444
key: 'qr-code-field-0',
445-
label: 'data:image/png;base64,abc123',
445+
label: '04ZKS2KCIWKXT8FHRX',
446446
type: 'QR_CODE',
447447
src: 'data:image/png;base64,abc123',
448-
fallbackText: '04ZKS2KCIWKXT8FHRX',
449448
},
450449
} satisfies QrCodeCollector,
451450
]);

packages/davinci-client/tsconfig.lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"noImplicitOverride": true,
1414
"declaration": true,
1515
"declarationMap": true,
16-
"skipLibCheck": false,
16+
"skipLibCheck": true,
1717
"sourceMap": true,
1818
"lib": ["es2022", "dom", "dom.iterable"]
1919
},

0 commit comments

Comments
 (0)