Skip to content

Commit

Permalink
Added a copy of the initial project version to a test folder (#135)
Browse files Browse the repository at this point in the history
# Pull Request

## 📖 Description

<!--- Provide some background and a description of your work. -->
This adds a static copy of the current project for the purposes of testing the `migrate` command.

### 🎫 Issues

<!---
List and link relevant issues here using the keyword "closes"
if this PR will close an issue, eg. closes #411
-->
Continues work on #41

## 👩‍💻 Reviewer Notes

<!---
Provide some notes for reviewers to help them provide targeted feedback and testing.
-->
This is just a static copy, it's purposefully not up-to-date with the latest from `@microsoft/fast-element` and `@microsoft/fast-foundation`, that step will occur after the migrate command is completed.

## ✅ Checklist

### General

<!--- Review the list and put an x in the boxes that apply. -->

- [ ] I have added tests for my changes.
- [ ] I have tested my changes.
- [x] I have updated the project documentation to reflect my changes.
  • Loading branch information
janechu committed Oct 14, 2022
1 parent da7df70 commit 2b18ae2
Show file tree
Hide file tree
Showing 29 changed files with 693 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Added a copy of the initial project version to a test folder",
"packageName": "@microsoft/fast-cli",
"email": "7559015+janechu@users.noreply.github.com",
"dependentChangeType": "none"
}
3 changes: 3 additions & 0 deletions packages/fast-cli/test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Test

This folder contains files that are part of tests. These are not intended to be compiled but used as reference material.
14 changes: 14 additions & 0 deletions packages/fast-cli/test/version/1.0.0-alpha.1/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Never lint playwright config
playwright.*.ts

# Never lint test files
*.spec.ts

# Never lint node_modules
node_modules

# Never lint build output
dist

# Never lint coverage output
coverage
74 changes: 74 additions & 0 deletions packages/fast-cli/test/version/1.0.0-alpha.1/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "import"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
rules: {
"@typescript-eslint/no-empty-interface": [
"error",
{
allowSingleExtends: true,
},
],
"import/order": "error",
"sort-imports": [
"error",
{
ignoreCase: true,
ignoreDeclarationSort: true,
},
],
"import/extensions": ["error", "always"],
"comma-dangle": "off",
"@typescript-eslint/typedef": [
"error",
{
arrowParameter: false,
arrayDestructuring: true,
parameter: true,
propertyDeclaration: true,
memberVariableDeclaration: true,
variableDeclarationIgnoreFunction: true,
variableDeclaration: false,
},
],
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/naming-convention": [
"error",
{
selector: "default",
format: ["UPPER_CASE", "camelCase", "PascalCase"],
leadingUnderscore: "allow",
},
{
selector: "property",
format: null, // disable for property names because of our foo__expanded convention for JSS
// TODO: I think we can come up with a regex that ignores variables with __ in them
},
{
selector: "variable",
format: null, // disable for variable names because of our foo__expanded convention for JSS
// TODO: I think we can come up with a regex that ignores variables with __ in them
},
],
"@typescript-eslint/no-inferrable-types": "off",
"no-prototype-builtins": "off",
"no-fallthrough": "off",
"no-unexpected-multiline": "off",
"@typescript-eslint/no-unused-vars": ["warn", { args: "none" }],
"@typescript-eslint/no-explicit-any": "off",
},
settings: {
"import/resolver": {
node: {
extensions: [".js", ".ts"]
}
}
},
};
39 changes: 39 additions & 0 deletions packages/fast-cli/test/version/1.0.0-alpha.1/.storybook/main.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const ResolveTypescriptPlugin = require("resolve-typescript-plugin");
const path = require("path");

module.exports = {
features: {
babelModeV7: true,
},
framework: "@storybook/html",
stories: ["../src/**/*.stories.ts"],
core: {
disableTelemetry: true,
builder: "webpack5",
},
webpackFinal: async config => {
config.resolve.plugins = [
...(config.resolve.plugins || []),
new ResolveTypescriptPlugin({
includeNodeModules: true,
}),
];
config.module.rules = [
{
test: /\.ts$/,
loader: "ts-loader",
sideEffects: true,
options: {
configFile: path.resolve("./tsconfig.json"),
transpileOnly: true,
},
},
{
test: /\.html$/,
use: "html-loader",
},
];

return config;
},
};
30 changes: 30 additions & 0 deletions packages/fast-cli/test/version/1.0.0-alpha.1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Introduction

Welcome to the default starter template provided by the [FAST CLI](https://microsoft.github.io/fast-cli).

This template can be used as a starting point for your project.

## Setup

### Testing

Before tests can be run the playwright browsers will need to be installed, use `npx playwright install`.

## Available commands

- **Start**: `npm start`
- **Test**: `npm run test`
- **Build**: `npm run build`

## Resources

You may find the following documentation helpful in completing your project.

- [Introduction to FAST](https://www.fast.design/docs/introduction)
- [Getting started creating your own custom elements with FAST element](https://www.fast.design/docs/fast-element/getting-started)
- [Getting started with FAST components](https://www.fast.design/docs/components/getting-started)
- [State management with Dependency Injection](https://www.fast.design/docs/apps-and-experiences/dependency-injection)

## Feedback

We're always looking for feedback and there are a couple ways you can do this. If you would like to ask us and the FAST community, we have a [discord server](https://discord.gg/FcSNfg4) available. If you find a bug in any of our packages, would like to request a feature, or have a suggestion to improve our documentation, feel free to file an [issue](https://github.com/microsoft/fast/issues/new/choose).
5 changes: 5 additions & 0 deletions packages/fast-cli/test/version/1.0.0-alpha.1/fast.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rootDir": "./src",
"componentPath": "./components",
"componentPrefix": "fast"
}
47 changes: 47 additions & 0 deletions packages/fast-cli/test/version/1.0.0-alpha.1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "fast-project",
"description": "A FAST project",
"private": true,
"type": "module",
"version": "0.1.0",
"author": "",
"license": "ISC",
"repository": "",
"scripts": {
"build": "webpack --config=./webpack.prod.cjs",
"eslint": "eslint . --ext .ts",
"eslint:fix": "eslint . --ext .ts --fix",
"start": "webpack-dev-server --config=./webpack.dev.cjs --history-api-fallback --progress",
"start:storybook": "start-storybook -p 3000 -h localhost",
"test": "npm run eslint && npx playwright test",
"test:serve": "node ./test-server.cjs",
"fast:postinstall": "==========================================\n\n Your project has been initialized!\n You have access to the following commands:\n\n Start: npm start\n Test: npm run test\n Build: npm run build\n\n=========================================="
},
"dependencies": {
"@microsoft/fast-element": "2.0.0-beta.3",
"@microsoft/fast-foundation": "3.0.0-alpha.4"
},
"devDependencies": {
"@playwright/test": "^1.26.0",
"@storybook/builder-webpack5": "6.5.9",
"@storybook/html": "6.5.9",
"@storybook/manager-webpack5": "6.5.9",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-plugin-import": "^2.25.4",
"express": "^4.17.3",
"html-loader": "^3.1.2",
"html-webpack-plugin": "5.5.0",
"resolve-typescript-plugin": "^1.2.0",
"ts-loader": "^9.3.0",
"typescript": "^4.7.3",
"webpack": "^5.71.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.8.1",
"webpack-merge": "^4.2.2"
}
}
19 changes: 19 additions & 0 deletions packages/fast-cli/test/version/1.0.0-alpha.1/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { PlaywrightTestConfig } from "@playwright/test";

const config: PlaywrightTestConfig = {
projects: [
{
name: "Desktop Chromium",
use: {
browserName: "chromium",
},
},
],
webServer: {
command: "npm run serve",
port: 3000,
reuseExistingServer: !process.env.CI,
},
};

export default config;
12 changes: 12 additions & 0 deletions packages/fast-cli/test/version/1.0.0-alpha.1/server.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var express = require("express");
var app = express();
var path = require("path");
var PORT = 3000;

app.use(express.static(path.join(__dirname, "www")));

app.listen(PORT, err => {
if (err) {
throw err;
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { welcome } from "./welcome/define.js";

export default [
welcome()
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Welcome } from "./welcome.js";
import { definition } from "./welcome.definition.js";

export const welcome = Welcome.compose(definition);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>Welcome</h1>

<fast-welcome></fast-welcome>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { template } from "./welcome.template.js";
import { styles } from "./welcome.styles.js";

export const definition = {
baseName: "welcome",
template,
styles
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect, test } from "@playwright/test";

test.describe("fast-welcome", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/");
});

test("should contain a div element", async ({ page }) => {
const element = page.locator("fast-welcome > div");

await expect(element).not.toBeNull();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { DesignSystem } from "@microsoft/fast-foundation";
import { designSystem } from "../../design-system.js";
import Template from "./fixtures/base.html";
import "./define.js";
import { welcome } from "./define.js";

DesignSystem.getOrCreate().withPrefix(
designSystem.prefix
).register(
welcome()
);

export default {
title: "welcome",
};

export const Welcome: () => "*.html" = () => Template;

0 comments on commit 2b18ae2

Please sign in to comment.