diff --git a/client/src/app.html b/client/src/app.html index 7124ef85..1e0a277c 100644 --- a/client/src/app.html +++ b/client/src/app.html @@ -1,12 +1,15 @@ - +
- - - - + + + + %sveltekit.head% diff --git a/client/src/lib/utils/networkData.ts b/client/src/lib/utils/networkData.ts index f885aa11..661cdb71 100644 --- a/client/src/lib/utils/networkData.ts +++ b/client/src/lib/utils/networkData.ts @@ -39,8 +39,8 @@ export const Paseo: NetworkData = { }; export const Networks: { network: NetworkData; url: string }[] = [ - { network: Frequency, url: "/" }, - { network: Paseo, url: "https://faucet.polkadot.io/paseo" }, + { network: Frequency, url: "/" }, + { network: Paseo, url: "https://faucet.polkadot.io/paseo" } ]; export function getChainName(network: NetworkData, id: number): string | null { diff --git a/client/tests/faucet.ts b/client/tests/faucet.ts index cce0e365..1dfff5e1 100644 --- a/client/tests/faucet.ts +++ b/client/tests/faucet.ts @@ -1,10 +1,12 @@ import { - type Frame, - type FullConfig, - type Locator, - type Page, - expect, - test, type ElementHandle, type Route + type Frame, + type FullConfig, + type Locator, + type Page, + expect, + test, + type ElementHandle, + type Route } from "@playwright/test"; type FormSubmit = { @@ -17,8 +19,10 @@ const getFormElements = async (page: Page, getCaptcha = false) => { // eslint-disable-next-line @typescript-eslint/consistent-type-assertions let captcha: Locator = {} as Locator; if (getCaptcha) { - const iframe = await page.locator('iframe[title="Widget containing checkbox for hCaptcha security challenge"]'); - captcha = iframe.contentFrame().getByLabel('hCaptcha checkbox with text'); + const iframe = await page.locator( + 'iframe[title="Widget containing checkbox for hCaptcha security challenge"]' + ); + captcha = iframe.contentFrame().getByLabel("hCaptcha checkbox with text"); } return { address: page.getByTestId("address"), @@ -67,7 +71,7 @@ export class FaucetTests { }; runTests(): void { - const validAddress = '5G3r2K1cEi4vtdBjMNHpjWCofRdyg2AFSdVVxMGkDGvuJgaG'; + const validAddress = "5G3r2K1cEi4vtdBjMNHpjWCofRdyg2AFSdVVxMGkDGvuJgaG"; test.describe(`${this.faucetName} tests`, () => { test.describe("on page load", () => { @@ -172,27 +176,29 @@ export class FaucetTests { await expect(submit).toBeEnabled(); }); - test("submit form becomes valid when click captcha first", async ({ page }) => { - await page.goto(this.url); - const { address, captcha, submit } = await getFormElements(page, true); - await expect(submit).toBeDisabled(); - await captcha.click(); - // simulate the captcha check / human wait - await page.waitForTimeout(500); - await address.fill(validAddress); - await expect(submit).toBeEnabled(); - }); - - test("Shows address invalid message when invalid address is entered", async ({page}, {config}) => { - await page.goto(this.url); - const { address, captcha, submit } = await getFormElements(page, true); - const expectedErrorMessage = "Address is invalid"; - await address.fill('garbage'); - await captcha.click(); - const errorMessage = page.getByTestId("error"); - await expect(errorMessage).toBeVisible(); - expect((await errorMessage.allInnerTexts())[0]).toContain(expectedErrorMessage); - }) + test("submit form becomes valid when click captcha first", async ({ page }) => { + await page.goto(this.url); + const { address, captcha, submit } = await getFormElements(page, true); + await expect(submit).toBeDisabled(); + await captcha.click(); + // simulate the captcha check / human wait + await page.waitForTimeout(500); + await address.fill(validAddress); + await expect(submit).toBeEnabled(); + }); + + test("Shows address invalid message when invalid address is entered", async ({ page }, { + config + }) => { + await page.goto(this.url); + const { address, captcha, submit } = await getFormElements(page, true); + const expectedErrorMessage = "Address is invalid"; + await address.fill("garbage"); + await captcha.click(); + const errorMessage = page.getByTestId("error"); + await expect(errorMessage).toBeVisible(); + expect((await errorMessage.allInnerTexts())[0]).toContain(expectedErrorMessage); + }); test("sends data on submit", async ({ page }, { config }) => { await page.goto(this.url); diff --git a/client/tests/test.ts b/client/tests/test.ts index d08a37f3..2ad94fed 100644 --- a/client/tests/test.ts +++ b/client/tests/test.ts @@ -15,14 +15,16 @@ type FormSubmit = { parachain_id?: string; }; -const testAddress = '5G3r2K1cEi4vtdBjMNHpjWCofRdyg2AFSdVVxMGkDGvuJgaG'; +const testAddress = "5G3r2K1cEi4vtdBjMNHpjWCofRdyg2AFSdVVxMGkDGvuJgaG"; const getFormElements = async (page: Page, getCaptcha = false) => { let captcha: Locator = {} as Locator; - let captchaFrame: Locator = {} as Locator; + let captchaFrame: Locator = {} as Locator; if (getCaptcha) { - captchaFrame = await page.locator('iframe[title="Widget containing checkbox for hCaptcha security challenge"]'); - captcha = await captchaFrame.locator("#anchor") + captchaFrame = await page.locator( + 'iframe[title="Widget containing checkbox for hCaptcha security challenge"]' + ); + captcha = await captchaFrame.locator("#anchor"); } return { address: page.getByTestId("address"), @@ -100,7 +102,7 @@ test.describe("form interaction", () => { const { address, captcha, submit } = await getFormElements(page, true); await expect(submit).toBeDisabled(); await address.fill(testAddress); - await captcha.click(); + await captcha.click(); await expect(submit).toBeEnabled(); }); @@ -110,7 +112,7 @@ test.describe("form interaction", () => { await expect(submit).toBeDisabled(); const myAddress = "0x000000001"; await address.fill(myAddress); - await captcha.click(); + await captcha.click(); const url = getFaucetUrl(config); await page.route(url, (route) => route.fulfill({ @@ -156,7 +158,7 @@ test.describe("form interaction", () => { const { address, captcha, submit } = await getFormElements(page, true); await expect(submit).toBeDisabled(); await address.fill("0x123"); - await captcha.click(); + await captcha.click(); await page.route(getFaucetUrl(config), (route) => route.fulfill({ body: JSON.stringify({ error })