Skip to content

Commit

Permalink
update whole project
Browse files Browse the repository at this point in the history
  • Loading branch information
narr committed Aug 14, 2020
1 parent 4adff34 commit 52adf10
Show file tree
Hide file tree
Showing 47 changed files with 13,950 additions and 15,489 deletions.
10 changes: 6 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
!.storybook
.history
.next
.nyc_output
coverage
tmp
*.min.js

build
out

docs
cypress/integration/examples
cypress/fixtures/example.json
9 changes: 2 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@ module.exports = {
plugins: ['react-hooks'],
env: {
browser: true,
es2020: true,
node: true,
},
globals: {
jest: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
settings: {
react: {
// Tells eslint-plugin-react to automatically detect the version of React to use
Expand All @@ -41,6 +35,7 @@ module.exports = {
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ ignoreRestSiblings: true },
Expand Down
31 changes: 7 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,13 @@ jobs:
run: |
node -v
npm -v
yarn -v
- name: Run npm install
run: npm install
- name: Install
run: yarn

- name: Run lint
run: npm run lint
- name: Lint
run: yarn lint

- name: Run unit tests
run: npm run test:ci:unit

e2e:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '*'

- name: Run npm install
run: npm install

- name: Run build
run: npm run build:coverage

- name: Run e2e test
run: npm run ci:test:e2e
- name: Test
run: yarn test:ci
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ yarn-error.log*

# cypress
cypress/integration/examples
cypress/fixtures/example.json
cypress/screenshots
7 changes: 7 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
webpackFinal: async baseConfig => {
return { ...baseConfig };
},
};
5 changes: 5 additions & 0 deletions .storybook/middleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const setRoutes = require('../server/routes');

module.exports = function expressMiddleware(router) {
setRoutes(router);
};
24 changes: 24 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<style>
html {
height: 100%;
overflow: hidden;
font-family: sans-serif;
}

body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}

* {
box-sizing: border-box;
}

#root,
#docs-root {
height: 100%;
overflow: auto;
}
</style>
28 changes: 28 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import { RouterContext } from 'next/dist/next-server/lib/router-context';
// NOTE: can add a global CSS

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
};

export const decorators = [
Story => (
// https://github.com/vercel/next.js/issues/15543#issuecomment-664955766
<RouterContext.Provider
value={{
prefetch: () => {
return Promise.resolve();
},
push: () => {
return Promise.resolve();
},
replace: () => {
return Promise.resolve();
},
}}
>
<Story />
</RouterContext.Provider>
),
];
16 changes: 5 additions & 11 deletions cypress/support/index.d.ts → @types/cypress/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// in cypress/support/index.d.ts
// load type definitions that come with Cypress module
/// <reference types="cypress" />

declare namespace Cypress {
interface ConfigOptions {
interface ResolvedConfigOptions {
custom: {
pages: {
default: string;
posts: string;
components: {
[k: string]: string;
};
mockServerPort: number;
waitTime: number;
logWaitTime: number;
};
}

Expand All @@ -22,7 +16,7 @@ declare namespace Cypress {
selectorToCheckUiRenderDone,
}: {
url: string;
reqBeforeCallback?: (request: any, proxy: VoidFunction) => void;
reqBeforeCallback?: (request: any) => void;
reqAfterCallback?: (request: any, response: any) => void;
selectorToCheckUiRenderDone?: any[];
}): VoidFunction;
Expand Down
34 changes: 0 additions & 34 deletions assets/mocks/getAllPosts.js

This file was deleted.

14 changes: 0 additions & 14 deletions assets/mocks/mockConfigs.json

This file was deleted.

22 changes: 19 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,27 @@ module.exports = function (api) {
api.cache(true);

const plugins = [];
if (process.env.CYPRESS_coverage) {
plugins.push('istanbul');
if (process.env.COVERAGE) {
plugins.push([
'istanbul',
{
exclude: ['**/.storybook', '**/*.stories.*', '**/*.cspec.*'],
},
]);
}
return {
presets: ['next/babel'],
presets: [
[
'next/babel',
{
'preset-env': {
targets: {
browsers: ['last 2 Chrome versions'],
},
},
},
],
],
plugins,
};
};
25 changes: 11 additions & 14 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
{
"baseUrl": "http://localhost:6006",
"custom": {
"mockServerPort": 3030,
"pages": {
"default": "/",
"posts": "/posts"
"components": {
"example-button--primary": "/iframe.html?id=example-button--primary&viewMode=story",
"test-homepage--base": "/iframe.html?id=test-homepage--base&viewMode=story",
"test-postspage--base": "/iframe.html?id=test-postspage--base&viewMode=story",
"components-card--base": "/iframe.html?id=components-card--base&viewMode=story"
},
"waitTime": 0
"logWaitTime": 0
},
"fixturesFolder": "assets",
"ignoreTestFiles": [
"**/examples/*.spec.*",
"**/node_modules/**",
"**/coverage/**",
"**/out/**"
],
"integrationFolder": "cypress/integration",
"testFiles": ["**/*.cspec.*"],
"defaultCommandTimeout": 10000,
"ignoreTestFiles": ["**/examples/*.spec.*", "**/node_modules/**"],
"integrationFolder": ".",
"testFiles": ["./cypress/integration/**/*.cspec.*", "./src/**/*.cspec.*"],
"video": false,
"viewportHeight": 1080,
"viewportWidth": 1920
Expand Down
44 changes: 0 additions & 44 deletions cypress/integration/onLoad/posts.cspec.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ describe('/ - on load', () => {

it(`should show UIs correctly after initial loading`, () => {
cy.waitForInitialUIRenderDone({
url: customConfigs.pages.default,
url: customConfigs.components['test-homepage--base'],
selectorToCheckUiRenderDone: ['Welcome to Next.js!'],
});

cy.log(`**should show all link titles below**`);
cy.log(`**should show all link titles below**`).wait(
customConfigs.logWaitTime
);
cy.contains('h3', 'Documentation').should('be.visible');
cy.contains('h3', 'Learn').should('be.visible');
cy.contains('h3', 'Modal').should('be.visible');
Expand Down
Loading

0 comments on commit 52adf10

Please sign in to comment.