Skip to content

Commit

Permalink
Merge pull request #448 from ForgeRock/davinci-client
Browse files Browse the repository at this point in the history
chore: initial-setup-for-davinci-client
  • Loading branch information
ryanbas21 authored Oct 25, 2024
2 parents 299a14d + 831c13c commit 8a3e87e
Show file tree
Hide file tree
Showing 69 changed files with 3,590 additions and 67 deletions.
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
link-workspace-packages=false
strict-peer-dependencies=false
save-workspace-protocol=rolling
save-prefix=""
2 changes: 1 addition & 1 deletion e2e/autoscript-apps/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"tags": ["scope:app"],
"targets": {
"build": {
"dependsOn": ["javascript-sdk:build", "ping-protect:build", "^build"],
"dependsOn": ["^build"],
"inputs": ["default", "^default"],
"outputs": ["{projectRoot}/dist"],
"options": {
Expand Down
14 changes: 14 additions & 0 deletions e2e/autoscript-suites/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as os from 'os';
import { PlaywrightTestConfig } from '@playwright/test';
import { nxE2EPreset } from '@nx/playwright/preset';
import { workspaceRoot } from '@nx/devkit';
Expand All @@ -23,6 +24,19 @@ const config: PlaywrightTestConfig = {
bypassCSP: true,
trace: process.env.CI ? 'retry-with-trace' : 'retain-on-failure',
},
projects: [
{
name: 'Chromium',
},
{
name: 'Firefox',
},
os.type() === 'Darwin'
? {
name: 'Safari',
}
: undefined,
].filter(Boolean),
webServer: [
{
command: 'pnpm nx serve mock-api',
Expand Down
3 changes: 3 additions & 0 deletions e2e/autoscript-suites/src/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ const oauth = {
client: 'WebOAuthClient',
scope: 'openid profile me.read',
};

const origins = {
// Ensure all domains are added to the security cert creation
app: process.env.LIVE ? 'https://sdkapp.petrov.ca' : 'http://localhost',
forgeops: 'https://default.forgeops.petrov.ca',
mock: 'http://localhost',
resource: 'http://localhost',
};

const paths = {
am: '/am',
};

const ports = {
app: '8443',
forgeops: '443',
Expand Down
15 changes: 0 additions & 15 deletions e2e/autoscript-suites/src/env.teardown.ts

This file was deleted.

7 changes: 4 additions & 3 deletions e2e/autoscript-suites/src/utilities/setup-and-go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function setupAndGo(
});

page.on('request', async (req) => {
const headers = await req.headers();
const headers = req.headers();

headerArray.push(new Headers(headers));
});
Expand All @@ -101,9 +101,10 @@ export async function setupAndGo(
await page.goto(url.toString());

// Test script complete
await page.waitForSelector('.Test_Complete', { state: 'attached' });
const locator = page.locator('.Test_Complete');
await locator.waitFor({ state: 'visible' });

await page.removeListener('console', (msg) => console.log(msg.text()));
page.removeListener('console', (msg) => console.log(msg.text()));

return { headerArray, messageArray, networkArray };
}
2 changes: 1 addition & 1 deletion e2e/autoscript-suites/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"sourceMap": false,
"allowJs": true,
"types": ["jest", "node"],
"types": ["node"],
"outDir": "dist",
"module": "ES2020",
"moduleResolution": "NodeNext",
Expand Down
14 changes: 14 additions & 0 deletions e2e/davinci-app/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
node_modules
*.md
LICENSE
.babelrc
.env*
.bin
dist
.eslintignore
*.html
*.svg
*.css
public
*.json
*.d.ts
21 changes: 21 additions & 0 deletions e2e/davinci-app/components/flow-link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ActionCollector } from '@forgerock/davinci-client/types';

export default function flowLinkComponent(
formEl: HTMLFormElement,
collector: ActionCollector,
flow: (action: string) => void,
renderForm: () => void,
) {
const button = document.createElement('button');

button.classList.add('flow-link');
button.type = 'button';
button.innerText = collector.output.label;

formEl?.appendChild(button);

button.addEventListener('click', async () => {
await flow(collector.output.key);
renderForm();
});
}
23 changes: 23 additions & 0 deletions e2e/davinci-app/components/password.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { SingleValueCollector } from '@forgerock/davinci-client/types';

export default function passwordComponent(
formEl: HTMLFormElement,
collector: SingleValueCollector,
updater: (value: string, index?: number) => void,
) {
const label = document.createElement('label');
const input = document.createElement('input');

label.htmlFor = collector.output.key;
label.innerText = collector.output.label;
input.type = 'password';
input.id = collector.output.key;
input.name = collector.output.key;

formEl?.appendChild(label);
formEl?.appendChild(input);

formEl?.querySelector(`#${collector.output.key}`)?.addEventListener('blur', (event: Event) => {
updater((event.target as HTMLInputElement).value);
});
}
15 changes: 15 additions & 0 deletions e2e/davinci-app/components/protect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { SingleValueCollector } from '@forgerock/davinci-client/types';

export default function (
formEl: HTMLFormElement,
collector: SingleValueCollector,
updater: (value: string, index?: number) => void,
) {
// create paragraph element with text of "Loading ... "
const p = document.createElement('p');

p.innerText = collector.output.label;
formEl?.appendChild(p);

updater('fakeprofile');
}
10 changes: 10 additions & 0 deletions e2e/davinci-app/components/social-login-button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ActionCollector } from '@forgerock/davinci-client/types';

export default function submitButtonComponent(formEl: HTMLFormElement, collector: ActionCollector) {
const link = document.createElement('a');

link.innerText = collector.output.label;
link.href = collector.output?.url || '';

formEl?.appendChild(link);
}
10 changes: 10 additions & 0 deletions e2e/davinci-app/components/submit-button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ActionCollector } from '@forgerock/davinci-client/types';

export default function submitButtonComponent(formEl: HTMLFormElement, collector: ActionCollector) {
const button = document.createElement('button');

button.type = 'submit';
button.innerText = collector.output.label;

formEl?.appendChild(button);
}
24 changes: 24 additions & 0 deletions e2e/davinci-app/components/text.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { SingleValueCollector } from '@forgerock/davinci-client/types';

export default function usernameComponent(
formEl: HTMLFormElement,
collector: SingleValueCollector,
updater: (value: string, index?: number) => void,
) {
const collectorKey = collector.output.key;
const label = document.createElement('label');
const input = document.createElement('input');

label.htmlFor = collectorKey;
label.innerText = collector.output.label;
input.type = 'text';
input.id = collectorKey;
input.name = collectorKey;

formEl?.appendChild(label);
formEl?.appendChild(input);

formEl?.querySelector(`#${collectorKey}`)?.addEventListener('input', (event) => {
updater((event.target as HTMLInputElement).value);
});
}
23 changes: 23 additions & 0 deletions e2e/davinci-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
</head>
<body>
<div id="app">
<div id="section">
<a href="https://vitejs.dev" target="_blank">
<img src="./public/vite.svg" class="logo" alt="Vite logo" />
</a>
<a href="https://www.typescriptlang.org/" target="_blank">
<img src="./public/typescript.svg" class="logo vanilla" alt="TypeScript logo" />
</a>
<form id="form"></form>
</div>
</div>
<script type="module" src="main.ts"></script>
</body>
</html>
Loading

0 comments on commit 8a3e87e

Please sign in to comment.