generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from FernandVEYRIER/feat/readme
feat: added instructions and Cypress test
- Loading branch information
Showing
17 changed files
with
1,659 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# your Supabase url, e.g. https://wfzpewmlyiozupulbuur.supabase.co | ||
SUPABASE_URL="" | ||
SUPBASE_ANON_KEY="" | ||
# your Supabase Anon Key that you can find under settings/api, e.g eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndmenBld21seWlvenVwdWxidXVyIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTU2NzQzMzksImV4cCI6MjAxMTI1MDMzOX0.SKIL3Q0NOBaMehH0ekFspwgcu3afp3Dl9EDzPqs1nKs | ||
SUPABASE_ANON_KEY="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Run Cypress testing suite | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
cypress-run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.10.0 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Cypress run | ||
uses: cypress-io/github-action@v6 | ||
with: | ||
build: yarn run build | ||
start: yarn start | ||
env: | ||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SUPABASE_URL: "https://wfzpewmlyiozupulbuur.supabase.co" | ||
SUPABASE_ANON_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndmenBld21seWlvenVwdWxidXVyIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTU2NzQzMzksImV4cCI6MjAxMTI1MDMzOX0.SKIL3Q0NOBaMehH0ekFspwgcu3afp3Dl9EDzPqs1nKs | ||
- uses: actions/upload-artifact@v4 | ||
if: failure() | ||
with: | ||
name: cypress-screenshots | ||
path: cypress/screenshots | ||
if-no-files-found: ignore | ||
- uses: actions/upload-artifact@v4 | ||
if: failure() | ||
with: | ||
name: cypress-videos | ||
path: cypress/videos | ||
if-no-files-found: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ node_modules | |
.pnp.cjs | ||
.pnp.loader.mjs | ||
.env | ||
static/dist | ||
static/dist | ||
metamask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,35 @@ | ||
# `@ubiquity/onboard.ubq.fi` | ||
|
||
Generates config for organizations | ||
Generates the configuration for organizations, by creating a default configuration and creating a repository under the | ||
given Organization. | ||
|
||
## Requirements | ||
|
||
Copy the `env.example` to `.env` and fill the required variables. | ||
|
||
## Run | ||
|
||
```shell | ||
yarn start | ||
``` | ||
Should make the front-end page available at [http://localhost:8080](http://localhost:8080). | ||
|
||
### Required fields | ||
- `CHAIN_ID`: the id of the network you want to use for the transactions | ||
- `WALLET_PRIVATE_KEY`: the [64 digits](https://www.browserling.com/tools/random-hex) crypto wallet key that will be used for transactions | ||
- `GITHUB_PAT`: a [GitHub Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) | ||
- `ORG_NAME`: the name of the [organization](https://github.com/settings/organizations) where you want to add the bot | ||
|
||
## Testing | ||
To test with Cypress Studio UI, run | ||
```shell | ||
yarn cy:open | ||
``` | ||
|
||
Otherwise to simply run the tests through the console, run | ||
```shell | ||
yarn cy:run | ||
``` | ||
|
||
To test in a real-world scenario, you will need to create an Organization under your GitHub account, and use it as a | ||
dummy. If the operation is successful, you will see a new repository appear with the Ubiquibot configuration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { defineConfig } from "cypress"; | ||
import path from "node:path"; | ||
import AdmZip from "adm-zip"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
setupNodeEvents(on) { | ||
on("before:browser:launch", (browser, launchOptions) => { | ||
// absolute path to the unpacked extension's folder | ||
// NOTE: extensions cannot be loaded in headless Chrome | ||
const extensionPath = path.resolve(__dirname, "./cypress/fixtures"); | ||
const unzippedPath = `${extensionPath}/metamask`; | ||
const zip = new AdmZip(`${extensionPath}/metamask-chrome.zip`); | ||
zip.extractAllTo(unzippedPath); | ||
launchOptions.extensions.push(unzippedPath); | ||
|
||
return launchOptions; | ||
}); | ||
}, | ||
experimentalStudio: true, | ||
baseUrl: "http://localhost:8080", | ||
watchForFileChanges: false, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
describe("Homepage tests", () => { | ||
const ORG_NAME = "Ubiquity"; | ||
|
||
beforeEach(() => { | ||
cy.fixture("get-user.json").then((file) => { | ||
cy.intercept("GET", `https://api.github.com/users/${ORG_NAME}`, (req) => { | ||
req.reply(file); | ||
}).as("githubGetUser"); | ||
}); | ||
cy.fixture("get-ubiquibot-config.json").then((file) => { | ||
cy.intercept("GET", `https://api.github.com/repos/${ORG_NAME}/ubiquibot-config`, (req) => { | ||
req.reply(file); | ||
}).as("githubGetUbiquibotConfig"); | ||
}); | ||
cy.fixture("get-repos.json").then((file) => { | ||
cy.intercept("GET", `https://api.github.com/orgs/${ORG_NAME}/repos`, (req) => { | ||
req.reply(file); | ||
}).as("githubGetRepos"); | ||
}); | ||
cy.fixture("get-installations.json").then((file) => { | ||
cy.intercept("GET", `https://api.github.com/orgs/${ORG_NAME}/installations**`, (req) => { | ||
req.reply(file); | ||
}).as("githubGetInstallations"); | ||
}); | ||
cy.fixture("get-installation-repositories.json").then((file) => { | ||
cy.intercept("GET", `https://api.github.com/user/installations/47252474/repositories`, (req) => { | ||
req.reply(file); | ||
}).as("githubGetInstallationRepositories"); | ||
}); | ||
cy.fixture("put-file.json").then((file) => { | ||
cy.intercept("PUT", `https://api.github.com/user/installations/47252474/repositories/641336624`, (req) => { | ||
req.reply(file); | ||
}).as("githubPutInstallation"); | ||
}); | ||
cy.fixture("put-file.json").then((file) => { | ||
cy.intercept("PUT", `https://api.github.com/repos/${ORG_NAME}/ubiquibot-config/contents/.github%2Fubiquibot-config.yml`, (req) => { | ||
req.reply(file); | ||
}).as("githubPutConfigFile"); | ||
}); | ||
}); | ||
|
||
it("Console is cleared of errors and warnings", () => { | ||
cy.visit("/", { | ||
onBeforeLoad(win) { | ||
cy.stub(win.console, "error").as("consoleError"); | ||
}, | ||
}); | ||
cy.get("@consoleError").should("not.be.called"); | ||
cy.get("body").should("exist"); | ||
}); | ||
|
||
it("Create onboarding repository", () => { | ||
cy.visit("/"); | ||
cy.get("#setBtn").click(); | ||
cy.log("Display warning on empty WALLET_PRIVATE_KEY"); | ||
cy.get(":nth-child(2) > .status-log.warn").contains(/.+/); | ||
cy.get("#walletPrivateKey").type("deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); | ||
cy.get("#setBtn").click(); | ||
cy.log("Display warning on empty ORG_NAME"); | ||
cy.get(":nth-child(4) > .status-log.warn").contains(/.+/); | ||
cy.get("#orgName").type(ORG_NAME); | ||
cy.get("#setBtn").click(); | ||
cy.log("Display warning on empty GITHUB_PAT"); | ||
cy.get(":nth-child(3) > .status-log.warn").contains(/.+/); | ||
cy.get("#githubPat").type("ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); | ||
cy.get("#setBtn").click(); | ||
cy.get("#outKey").then((e) => { | ||
expect(e.val()).not.to.be.empty; | ||
}); | ||
cy.log("Expected to be a step 2 of the form"); | ||
cy.get("#stepper > :nth-child(2)").should("have.class", "active"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
{ | ||
"total_count": 1, | ||
"repositories": [ | ||
{ | ||
"id": 767829567, | ||
"node_id": "R_kgDOLcQmPw", | ||
"name": "ubiquibot-config", | ||
"full_name": "Ubiquity/ubiquibot-config", | ||
"private": true, | ||
"owner": { | ||
"login": "Ubiquity", | ||
"id": 159901852, | ||
"node_id": "O_kgDOCYfonA", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/159901852?v=4", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/Ubiquity", | ||
"html_url": "https://github.com/Ubiquity", | ||
"followers_url": "https://api.github.com/users/Ubiquity/followers", | ||
"following_url": "https://api.github.com/users/Ubiquity/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/Ubiquity/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/Ubiquity/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/Ubiquity/subscriptions", | ||
"organizations_url": "https://api.github.com/users/Ubiquity/orgs", | ||
"repos_url": "https://api.github.com/users/Ubiquity/repos", | ||
"events_url": "https://api.github.com/users/Ubiquity/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/Ubiquity/received_events", | ||
"type": "Organization", | ||
"site_admin": false | ||
}, | ||
"html_url": "https://github.com/Ubiquity/ubiquibot-config", | ||
"description": null, | ||
"fork": false, | ||
"url": "https://api.github.com/repos/Ubiquity/ubiquibot-config", | ||
"forks_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/forks", | ||
"keys_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/keys{/key_id}", | ||
"collaborators_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/collaborators{/collaborator}", | ||
"teams_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/teams", | ||
"hooks_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/hooks", | ||
"issue_events_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/issues/events{/number}", | ||
"events_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/events", | ||
"assignees_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/assignees{/user}", | ||
"branches_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/branches{/branch}", | ||
"tags_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/tags", | ||
"blobs_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/git/blobs{/sha}", | ||
"git_tags_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/git/tags{/sha}", | ||
"git_refs_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/git/refs{/sha}", | ||
"trees_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/git/trees{/sha}", | ||
"statuses_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/statuses/{sha}", | ||
"languages_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/languages", | ||
"stargazers_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/stargazers", | ||
"contributors_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/contributors", | ||
"subscribers_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/subscribers", | ||
"subscription_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/subscription", | ||
"commits_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/commits{/sha}", | ||
"git_commits_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/git/commits{/sha}", | ||
"comments_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/comments{/number}", | ||
"issue_comment_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/issues/comments{/number}", | ||
"contents_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/contents/{+path}", | ||
"compare_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/compare/{base}...{head}", | ||
"merges_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/merges", | ||
"archive_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/{archive_format}{/ref}", | ||
"downloads_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/downloads", | ||
"issues_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/issues{/number}", | ||
"pulls_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/pulls{/number}", | ||
"milestones_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/milestones{/number}", | ||
"notifications_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/notifications{?since,all,participating}", | ||
"labels_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/labels{/name}", | ||
"releases_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/releases{/id}", | ||
"deployments_url": "https://api.github.com/repos/Ubiquity/ubiquibot-config/deployments", | ||
"created_at": "2024-03-06T01:00:06Z", | ||
"updated_at": "2024-03-06T01:00:07Z", | ||
"pushed_at": "2024-03-06T01:00:07Z", | ||
"git_url": "git://github.com/Ubiquity/ubiquibot-config.git", | ||
"ssh_url": "git@github.com:Ubiquity/ubiquibot-config.git", | ||
"clone_url": "https://github.com/Ubiquity/ubiquibot-config.git", | ||
"svn_url": "https://github.com/Ubiquity/ubiquibot-config", | ||
"homepage": null, | ||
"size": 0, | ||
"stargazers_count": 0, | ||
"watchers_count": 0, | ||
"language": null, | ||
"has_issues": true, | ||
"has_projects": true, | ||
"has_downloads": true, | ||
"has_wiki": false, | ||
"has_pages": false, | ||
"has_discussions": false, | ||
"forks_count": 0, | ||
"mirror_url": null, | ||
"archived": false, | ||
"disabled": false, | ||
"open_issues_count": 0, | ||
"license": null, | ||
"allow_forking": false, | ||
"is_template": false, | ||
"web_commit_signoff_required": false, | ||
"topics": [ | ||
|
||
], | ||
"visibility": "private", | ||
"forks": 0, | ||
"open_issues": 0, | ||
"watchers": 0, | ||
"default_branch": "main", | ||
"permissions": { | ||
"admin": true, | ||
"maintain": true, | ||
"push": true, | ||
"triage": true, | ||
"pull": true | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.