Skip to content

make route for become-a-provider #188

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

Merged
merged 6 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ vite.config.js.timestamp-*
vite.config.ts.timestamp-*

.idea/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
75 changes: 68 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"test": "vitest",
"test:e2e": "vitest run --dir ./test/e2e",
"test": "vitest run && npx playwright test",
"test:e2e": "vitest run ./test/e2e",
"test:stake": "vitest stake",
"test:ci": "vitest run --dir ./test/unit-and-integration --coverage",
"test:ci": "vitest run ./test/unit-and-integration --coverage",
"test:ui": "vitest --ui",
"test:watch": "vitest src",
"coverage": "vitest run --coverage",
Expand All @@ -23,6 +23,7 @@
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@playwright/test": "^1.48.2",
"@polkadot/types-codec": "^12.4.1",
"@sveltejs/adapter-static": "^3.0.4",
"@sveltejs/kit": "2.5.24",
Expand All @@ -33,6 +34,7 @@
"@testing-library/user-event": "^14.5.2",
"@types/eslint__js": "^8.42.3",
"@types/jest": "^29.5.12",
"@types/node": "^22.8.4",
"@typescript-eslint/eslint-plugin": "^8.2.0",
"@typescript-eslint/parser": "^8.2.0",
"@vitest/coverage-v8": "^2.0.5",
Expand Down
80 changes: 80 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './test/playwright',
testMatch: /.*.test.ts/,
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

// currently failing:
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
//
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },

/* Test against mobile viewports. */
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
},
{
name: 'Mobile Safari',
use: { ...devices['iPhone 12'] },
},

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
webServer: {
command: 'npm run build && npm run preview',
port: 4173,
reuseExistingServer: !process.env.CI,
},
});
5 changes: 5 additions & 0 deletions src/components/BackHomeButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
export let cancelText = 'Cancel';
</script>

<a href="/" class="btn-no-fill {$$restProps}" data-testid="back-home">{cancelText}</a>
9 changes: 2 additions & 7 deletions src/components/BecomeAProvider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
import CreateMsa from './CreateMsa.svelte';
import CreateProvider from './CreateProvider.svelte';
import EmailProviderRequest from './EmailProviderRequest.svelte';
import { pageContent } from '$lib/stores/pageContentStore';
import { NetworkType } from '$lib/stores/networksStore';

// a callback for when the user cancels this action
export let cancelAction = () => {
pageContent.login();
};
import BackHomeButton from '$components/BackHomeButton.svelte';
</script>

<div id="become-a-provider" class="content-block column w-single-block">
Expand All @@ -34,7 +29,7 @@
<CreateProvider />
{/if}
{:else}
<button on:click|preventDefault={cancelAction} class="btn-no-fill text-left">Back</button>
<BackHomeButton cancelText="Back" />
{/if}
</form>
</BlockSection>
Expand Down
8 changes: 2 additions & 6 deletions src/components/CreateMsa.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
import LoadingIcon from '$lib/assets/LoadingIcon.svelte';
import ActivityLogPreviewItem from './ActivityLogPreviewItem.svelte';
import { activityLog } from '$lib/stores/activityLogStore';

// a callback for when the user cancels this action
export let cancelAction = () => {
pageContent.login();
};
import BackToRootButton from '$components/BackHomeButton.svelte';

let recentActivityItem: Activity | undefined;
let recentTxnId: Activity['txnId'] | undefined;
Expand Down Expand Up @@ -66,7 +62,7 @@
Create an MSA
{/if}
</button>
<button on:click|preventDefault={cancelAction} class="btn-no-fill">Cancel</button>
<BackToRootButton />
</form>
</div>
{#if recentActivityItem}
Expand Down
7 changes: 2 additions & 5 deletions src/components/CreateProvider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
import LoadingIcon from '$lib/assets/LoadingIcon.svelte';
import { activityLog } from '$lib/stores/activityLogStore';
import ActivityLogPreviewItem from './ActivityLogPreviewItem.svelte';
import BackHomeButton from '$components/BackHomeButton.svelte';

// a callback for when the user cancels this action
export let cancelAction = () => {
pageContent.login();
};
// a callback for when a transaction hits a final state
let createProviderTxnFinished = async (succeeded: boolean) => {
if (succeeded) {
Expand Down Expand Up @@ -82,7 +79,7 @@
Create Provider
{/if}
</button>
<button on:click|preventDefault={cancelAction} class="btn-no-fill">Cancel</button>
<BackHomeButton />
</div>
</form>
{#if recentActivityItem}
Expand Down
7 changes: 1 addition & 6 deletions src/components/EmailProviderRequest.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<script lang="ts">
import { pageContent } from '$lib/stores/pageContentStore';
import { createMailto } from '$lib/utils';

let mailTo: string = createMailto('[email protected]', 'Request to become a Frequency provider', '');

export let cancelAction = () => {
pageContent.login();
};

function composeEmail() {
window.location.href = mailTo;
}
Expand All @@ -20,6 +15,6 @@
</p>
<form class="flex w-[350px] items-end justify-between">
<button id="email-request-btn" on:click|preventDefault={composeEmail} class="btn-primary">Email Request</button>
<button on:click|preventDefault={cancelAction} class="btn-no-fill">Cancel</button>
<a href="/" class="btn-no-fill">Cancel</a>
</form>
</div>
2 changes: 1 addition & 1 deletion src/components/ProviderLogin.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
>Want to learn more about providers?
</a>
</div>
<Button id="request-2b-provider-btn" title="Become a Provider" action={pageContent.becomeProvider} />
<a href="/become-a-provider" data-testid="become-a-provider" class="btn-primary">Become a Provider</a>
</BlockSection>
<BlockSection title="Need tokens?">
<HowToTransact additionalStyles="text-sm" />
Expand Down
3 changes: 1 addition & 2 deletions src/components/RequestToBeProvider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
let localDotApi: DotApi = defaultDotApi;
let mailTo = createMailto('[email protected]', 'Request to be a Provider', '');
// a callback for when the user cancels this action
export let cancelAction = () => {};

dotApi.subscribe((api) => (localDotApi = api));

Expand Down Expand Up @@ -64,7 +63,7 @@
<button on:click|preventDefault={doProposeToBeProvider} id="request-2b-provider-btn" class="btn-primary">
Submit Request To Be Provider</button
>
<button on:click|preventDefault={cancelAction} class="btn-cancel">Cancel</button>
<a href="/" class="btn-cancel">Cancel</a>
</div>
</form>
</div>
Expand Down
5 changes: 1 addition & 4 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<script lang="ts">
import Dashboard from '$components/Dashboard.svelte';
import BecomeAProvider from '$components/BecomeAProvider.svelte';
import ProviderLogin from '$components/ProviderLogin.svelte';
import { pageContent, PageContent } from '$lib/stores/pageContentStore';
</script>

{#if $pageContent === PageContent.Dashboard}
<Dashboard />
{:else if $pageContent === PageContent.Login}
{:else}
<ProviderLogin />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's just a link now we don't need 3 conditions.

{:else if $pageContent === PageContent.BecomeProvider}
<BecomeAProvider />
{/if}
5 changes: 5 additions & 0 deletions src/routes/become-a-provider/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script lang="ts">
import BecomeAProvider from '$components/BecomeAProvider.svelte';
</script>

<BecomeAProvider />
Loading