generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
205cc73
commit 681b43d
Showing
17 changed files
with
2,867 additions
and
800 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
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,11 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
setupNodeEvents() { | ||
// implement node event listeners here | ||
}, | ||
experimentalStudio: true, | ||
baseUrl: "http://localhost:8080", | ||
}, | ||
}); |
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 @@ | ||
describe("Homepage tests", () => { | ||
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"); | ||
cy.get("h1").should("exist"); | ||
}); | ||
}); |
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,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "hello@cypress.io", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
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 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************** | ||
// This example commands.ts shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
// | ||
// declare global { | ||
// namespace Cypress { | ||
// interface Chainable { | ||
// login(email: string, password: string): Chainable<void> | ||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element> | ||
// } | ||
// } | ||
// } |
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,20 @@ | ||
// *********************************************************** | ||
// This example support/e2e.ts is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import "./commands"; | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
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,10 @@ | ||
{ | ||
"preset": "ts-jest", | ||
"testEnvironment": "node", | ||
"roots": ["./tests"], | ||
"coveragePathIgnorePatterns": ["node_modules", "mocks"], | ||
"collectCoverage": true, | ||
"coverageReporters": ["json", "lcov", "text", "clover", "json-summary"], | ||
"reporters": ["default", "jest-junit", "jest-md-dashboard"], | ||
"coverageDirectory": "coverage" | ||
} |
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
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,63 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Audit report</title> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link href="out/styles/audit-report/audit.css" rel="stylesheet" /> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Ubiquity TypeScript Template</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h1 class="audit-tag">Audit report</h1> | ||
<!-- params --> | ||
<div class="mb-3"> | ||
<label for="repoURLs" class="form-label">Repository URLs</label> | ||
<input type="text" class="form-control" id="repoURLs" /> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="githubPAT" class="form-label">Github Personal Access Token</label> | ||
<input type="text" class="form-control" id="githubPAT" /> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="quickName" class="form-label">Quick Import</label> | ||
<textarea | ||
type="text" | ||
class="form-control" | ||
id="quickName" | ||
placeholder=' | ||
{ | ||
"REPO": "", | ||
"PAT": "" | ||
}' | ||
></textarea> | ||
</div> | ||
<div class="btn-container"> | ||
<button type="button" class="btn btn-primary mb-3" id="getReport"> | ||
<span class="btn-loader" id="report-loader"></span> | ||
<span>Get report</span> | ||
</button> | ||
</div> | ||
<!-- result table --> | ||
<div class="resultContainer"> | ||
<input type="text" id="searchInput" placeholder="Filter Result" /> | ||
<table id="resultTable" class="table" style="display: none"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Organization/Repo Name</th> | ||
<th scope="col">Issue URL</th> | ||
<th scope="col">Bounty Hunter</th> | ||
<th scope="col" id="amountHeader">Amount <span id="sortArrow">↓</span></th> | ||
<th scope="col">TX URL</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<!-- table content --> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<ul class="notifications"></ul> | ||
<script src="out/scripts/audit-report/audit.js" type="application/javascript"></script> | ||
<h1>Ubiquity TypeScript Template</h1> | ||
<script type="module" src="dist/main.js"></script> | ||
</body> | ||
</html> |
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
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 @@ | ||
// cSpell:disable | ||
import { factory, primaryKey } from "@mswjs/data"; | ||
|
||
/** | ||
* Creates an object that can be used as a db to persist data within tests | ||
*/ | ||
export const db = factory({ | ||
users: { | ||
id: primaryKey(Number), | ||
name: String, | ||
}, | ||
}); |
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,11 @@ | ||
import { http, HttpResponse } from "msw"; | ||
import { db } from "./db"; | ||
|
||
/** | ||
* Intercepts the routes and returns a custom payload | ||
*/ | ||
export const handlers = [ | ||
http.get("https://api.ubiquity.com/users", () => { | ||
return HttpResponse.json(db.users.getAll()); | ||
}), | ||
]; |
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,4 @@ | ||
import { setupServer } from "msw/node"; | ||
import { handlers } from "./handlers"; | ||
|
||
export const server = setupServer(...handlers); |
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,10 @@ | ||
[ | ||
{ | ||
"id": 1, | ||
"name": "user1" | ||
}, | ||
{ | ||
"id": 2, | ||
"name": "user2" | ||
} | ||
] |
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 { mainModule } from "../static/main"; | ||
import { db } from "./__mocks__/db"; | ||
import { server } from "./__mocks__/node"; | ||
import usersGet from "./__mocks__/users-get.json"; | ||
import { expect, describe, beforeAll, beforeEach, afterAll, afterEach, it } from "@jest/globals"; | ||
|
||
beforeAll(() => server.listen()); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); | ||
|
||
describe("User tests", () => { | ||
beforeEach(() => { | ||
for (const item of usersGet) { | ||
db.users.create(item); | ||
} | ||
}); | ||
|
||
it("Should fetch all the users", async () => { | ||
const res = await fetch("https://api.ubiquity.com/users"); | ||
const data = await res.json(); | ||
expect(data).toMatchObject(usersGet); | ||
expect(async () => await mainModule()).not.toThrow(); | ||
}); | ||
}); |
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
Oops, something went wrong.