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.
feat: added instructions and Cypress test
- Loading branch information
1 parent
93bf89a
commit 4210087
Showing
15 changed files
with
1,625 additions
and
18 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="" | ||
# your Supabase Anon Key that you can find under settings/api, e.g eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndmenBld21seWlvenVwdWxidXVyIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTU2NzQzMzksImV4cCI6MjAxMTI1MDMzOX0.SKIL3Q0NOBaMehH0ekFspwgcu3afp3Dl9EDzPqs1nKs | ||
SUPBASE_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,35 @@ | ||
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 }} | ||
- 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 |
---|---|---|
@@ -1,4 +1,32 @@ | ||
# `@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 the Studio open, run | ||
```shell | ||
yarn cy:open | ||
``` | ||
|
||
Otherwise to simply run the tests through the console, run | ||
```shell | ||
yarn cy:run | ||
``` |
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,12 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
setupNodeEvents() { | ||
// implement node event listeners here | ||
}, | ||
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"; | ||
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.only("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.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": "[email protected]: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.