Skip to content

Commit

Permalink
Fixing CI:
Browse files Browse the repository at this point in the history
* ignore test-results
* add env.sample
* fix faucet tests
* put back order of verify-pr commands
* updated client yarn
* add the postcss preprocessor package
  • Loading branch information
shannonwells committed Sep 18, 2024
1 parent 409e959 commit f51b9e9
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 19 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/verify-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn run check
- name: Install Playwright
run: npx playwright install
- run: yarn run test
- run: yarn run build
env:
PUBLIC_CAPTCHA_KEY: 6LesXHomAAAAAGVVTCgc467t8hvBbmK7IlYZCc8O
Expand All @@ -35,16 +39,11 @@ jobs:
PUBLIC_DEMO_MODE: false
GITHUB_PAGES: "/${{ github.event.repository.name }}"
STATIC: true
- run: yarn run check
- name: Install Playwright
run: npx playwright install
- run: yarn run test
- uses: actions/upload-artifact@master
with:
name: faucet
path: ./client/build
if-no-files-found: error
- run: yarn run check
test-image:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.idea
.last-run.json
test-results
.env
node_modules
.yarn
Expand Down
4 changes: 4 additions & 0 deletions client/env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PUBLIC_DEMO_MODE=false
PUBLIC_CAPTCHA_KEY=6LesXHomAAAAAGVVTCgc467t8hvBbmK7IlYZCc8O
PUBLIC_FORUM=""
PUBLIC_FAUCET_URL=""
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"autoprefixer": "^10.4.16",
"daisyui": "^4.4.4",
"postcss": "^8.4.47",
"postcss-load-config": "^6.0.1",
"svelte": "^4.2.19",
"svelte-check": "^4.0.2",
"svelte-markdown": "^0.4.1",
Expand Down
35 changes: 22 additions & 13 deletions client/tests/faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export class FaucetTests {
};

runTests(): void {
const validAddress = '5G3r2K1cEi4vtdBjMNHpjWCofRdyg2AFSdVVxMGkDGvuJgaG';

test.describe(`${this.faucetName} tests`, () => {
test.describe("on page load", () => {
test("page has expected header", async ({ page }) => {
Expand Down Expand Up @@ -199,17 +201,27 @@ export class FaucetTests {
await page.goto(this.url);
const { address, captcha, submit } = await getFormElements(page, true);
await expect(submit).toBeDisabled();
await address.fill("address");
await address.fill(validAddress);
await captcha.click();
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);
const { address, captcha, submit } = await getFormElements(page, true);
await expect(submit).toBeDisabled();
const myAddress = "0x000000001";
await address.fill(myAddress);
await address.fill(validAddress);
await captcha.click();
const faucetUrl = this.getFaucetUrl(config);

Expand All @@ -220,7 +232,7 @@ export class FaucetTests {
const request = page.waitForRequest((req) => {
if (req.url() === faucetUrl) {
const data = req.postDataJSON() as FormSubmit;
expect(data.address).toEqual(myAddress);
expect(data.address).toEqual(validAddress);
return !!data.recaptcha;
}
return false;
Expand All @@ -237,8 +249,7 @@ export class FaucetTests {
const { address, captcha, submit } = await getFormElements(page, true);
const dropdown = page.getByTestId(this.dropdownId);
await expect(submit).toBeDisabled();
const myAddress = "0x000000002";
await address.fill(myAddress);
await address.fill(validAddress);
await dropdown.click();
const networkBtn = page.getByTestId(`network-${i}`);
await expect(networkBtn).toBeVisible();
Expand All @@ -254,7 +265,7 @@ export class FaucetTests {
if (req.url() === faucetUrl) {
const data = req.postDataJSON() as FormSubmit;
const parachain_id = chain.id > 0 ? chain.id.toString() : undefined;
expect(data).toMatchObject({ address: myAddress, parachain_id });
expect(data).toMatchObject({ address: validAddress, parachain_id });
return !!data.recaptcha;
}
return false;
Expand All @@ -269,8 +280,7 @@ export class FaucetTests {
await page.goto(this.url);
const { address, network, captcha, submit } = await getFormElements(page, true);
await expect(submit).toBeDisabled();
const myAddress = "0x000000002";
await address.fill(myAddress);
await address.fill(validAddress);
const customChainDiv = page.getByTestId("custom-network-button");
await customChainDiv.click();
await network.fill("9999");
Expand All @@ -284,7 +294,7 @@ export class FaucetTests {
const request = page.waitForRequest((req) => {
if (req.url() === faucetUrl) {
const data = req.postDataJSON() as FormSubmit;
expect(data).toMatchObject({ address: myAddress, parachain_id: "9999" });
expect(data).toMatchObject({ address: validAddress, parachain_id: "9999" });
return !!data.recaptcha;
}
return false;
Expand All @@ -299,8 +309,7 @@ export class FaucetTests {
const operationHash = "0x0123435423412343214";
const { address, captcha, submit } = await getFormElements(page, true);
await expect(submit).toBeDisabled();
const myAddress = "0x000000001";
await address.fill(myAddress);
await address.fill(validAddress);
await captcha.click();
await page.route(this.getFaucetUrl(config), (route) =>
route.fulfill({ body: JSON.stringify({ hash: operationHash }) })
Expand All @@ -320,7 +329,7 @@ export class FaucetTests {
const error = "Things failed because you are a naughty boy!";
const { address, captcha, submit } = await getFormElements(page, true);
await expect(submit).toBeDisabled();
await address.fill("0x123");
await address.fill(validAddress);
await captcha.click();
await page.route(this.getFaucetUrl(config), (route) =>
route.fulfill({ body: JSON.stringify({ error }) })
Expand Down
4 changes: 3 additions & 1 deletion client/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type FormSubmit = {
parachain_id?: string;
};

const testAddress = '5G3r2K1cEi4vtdBjMNHpjWCofRdyg2AFSdVVxMGkDGvuJgaG';

const getFormElements = async (page: Page, getCaptcha = false) => {
let captcha: Locator = {} as Locator;
if (getCaptcha) {
Expand Down Expand Up @@ -115,7 +117,7 @@ test.describe("form interaction", () => {
await page.goto("/");
const { address, captcha, submit } = await getFormElements(page, true);
await expect(submit).toBeDisabled();
await address.fill("address");
await address.fill(testAddress);
await captcha.click();
await expect(submit).toBeEnabled();
});
Expand Down
12 changes: 12 additions & 0 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,11 @@ lilconfig@^3.0.0:
resolved "https://registry.npmjs.org/lilconfig/-/lilconfig-3.0.0.tgz"
integrity sha512-K2U4W2Ff5ibV7j7ydLr+zLAkIg5JJ4lPn1Ltsdt+Tz/IjQ8buJ55pZAxoP34lqIiwtF9iAvtLv3JGv7CAyAg+g==

lilconfig@^3.1.1:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-3.1.2.tgz#e4a7c3cb549e3a606c8dcc32e5ae1005e62c05cb"
integrity sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==

lines-and-columns@^1.1.6:
version "1.2.4"
resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz"
Expand Down Expand Up @@ -1438,6 +1443,13 @@ postcss-load-config@^4.0.1:
lilconfig "^3.0.0"
yaml "^2.3.4"

postcss-load-config@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-6.0.1.tgz#6fd7dcd8ae89badcf1b2d644489cbabf83aa8096"
integrity sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==
dependencies:
lilconfig "^3.1.1"

postcss-nested@^6.0.1:
version "6.0.1"
resolved "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.0.1.tgz"
Expand Down

0 comments on commit f51b9e9

Please sign in to comment.