Skip to content

Commit 9b652aa

Browse files
Merge pull request #286 from topcoder-platform/dev
TCA-379 TCA Follow-up & Misc Release 2022-09-01 -> master
2 parents df70dab + 51f0762 commit 9b652aa

File tree

304 files changed

+8349
-2103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

304 files changed

+8349
-2103
lines changed

.circleci/config.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ build_configuration_fetch: &build_configuration_fetch
6363
command: |
6464
./awsconfiguration.sh $DEPLOY_ENV
6565
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-buildvar
66+
aws s3 cp s3://tc-platform-${LOGICAL_ENV}/securitymanager/${LOGICAL_ENV}-platform-ui.env ./.env
6667
6768
lint_steps: &lint_steps
6869
# Initialization.
@@ -146,6 +147,35 @@ jobs:
146147
APPNAME: "platform-ui-mvp"
147148
steps: *deploy_steps
148149

150+
# Test job for the cases when we don not need deployment.
151+
e2e-test:
152+
docker:
153+
- image: cypress/browsers:node16.14.2-slim-chrome100-ff99-edge
154+
steps:
155+
- checkout
156+
- restore_cache:
157+
key: test-node-modules-{{ checksum "yarn.lock" }}
158+
- run:
159+
name: Config Git
160+
command: git config --global url."https://git@".insteadOf git://
161+
- run:
162+
name: Install Dependencies
163+
command: yarn install
164+
no_output_timeout: 20m
165+
- run:
166+
name: Install Cypress Binary
167+
command: yarn cypress install
168+
- run:
169+
name: Build the application
170+
command: yarn build
171+
no_output_timeout: 20m
172+
- save_cache:
173+
key: test-node-modules-{{ checksum "yarn.lock" }}
174+
paths:
175+
- node_modules
176+
- /root/.cache/Cypress
177+
- run: yarn cy:ci
178+
149179
workflows:
150180
version: 2
151181
build:
@@ -171,6 +201,9 @@ workflows:
171201
ignore:
172202
- master
173203

204+
- e2e-test:
205+
context : org-global
206+
174207
- build-prod:
175208
context : org-global
176209
filters:
@@ -182,6 +215,7 @@ workflows:
182215
context : org-global
183216
requires:
184217
- build-dev
218+
- e2e-test
185219
filters:
186220
branches:
187221
only:

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# testing
99
/coverage
10+
.nyc_output
1011

1112
# production
1213
/build
@@ -17,7 +18,12 @@
1718
.env.development.local
1819
.env.test.local
1920
.env.production.local
21+
.env
2022

2123
npm-debug.log*
2224
yarn-debug.log*
2325
yarn-error.log*
26+
27+
# Editors
28+
.editorconfig
29+
.prettierrc

README.md

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
The Platform UI is the official Topcoder web app to host all modern user interfaces to be used by all users.
44

5-
All future user interfaces at Topcoder will be implemented here.
6-
Pre-existing user interfaces will be ported to here over time until this is the only user interface any user sees when interacting with Topcoder.
5+
All future user interfaces at Topcoder will be implemented here. Pre-existing user interfaces will be ported to here over time until this is the only user interface any user sees when interacting with Topcoder.
76

87
>**NOTE:** The information in this file describes our coding standards and best practices. All new code should follow these guidelines both when coding new features as well as porting old features. Please take the time to read through this file in detail.
98
109
# Getting started with local development
1110

1211
- [Local Environment Setup](#local-environment-setup)
1312
- [Deployments](#deployments)
13+
- [Developer Center specific setup](#developer-center-contentful-api-key-and-space-id)
1414
- [Yarn Commands](#yarn-commands)
1515

1616
# Application structure
@@ -81,29 +81,37 @@ You will need to add the following line to your hosts file. The hosts file is no
8181
8282
>% yarn start
8383
84-
3. Go to https://local.topcoder-dev.com:3003/
84+
3. Go to https://local.topcoder-dev.com:3000
85+
86+
>**NOTE**: The default port is 3000, but you can override it in your [personal config](#personal-config).
8587
8688
### Local SSL
8789

8890
SSL is required for authentication to work properly.
8991

90-
The `yarn start` command serves the site using the cert and key in the /ssl directory.
92+
The `yarn start` command serves the site using the cert and key in the /ssl directory, which authorize the `https://local.topcoder-dev.com`URL.
93+
94+
By overriding the app to use <b>port 443</b>, you can use the authorized URL and trust the root CA to avoid SSL errors in the browser.
95+
96+
>**NOTE:** Mac users will require running the app with elevated permissions in order to use a port lower than 500.
9197
92-
For easier development, it is recommended that you add this certificate to your trusted root authorities and as a trused cert in your browser. Google your browser and OS for more info.
98+
For easier development, it is recommended that you add this certificate to your trusted root authorities and as a trused cert in your browser. Google your browser and OS for more info on how to trust cert authorities.
9399

94100
Otherwise, you will need to override the exception each time you load the site. Firefox users may need to user an incognito browser in order to override the exception.
95101

96102
### Personal Config
97103

98-
1. Add [hostname] to src-ts/config/environments/app-host-environment.enum.ts
99-
2. Copy an existing config from src-ts/config/environments/environment.*.config.ts
100-
3. Rename new config environment.[hostname].config.ts
101-
4. Rename config variable to EnvironmentConfig[HostName]
102-
5. Set the ENV variable to AppHostEnvironment.[hostname]
103-
6. Add the switch case for the host name to src-ts/config/environments/environment.config.ts
104+
1. Add [hostname] to [`/src-ts/config/environments/app-host-environment.type.ts`](/src-ts/config/environments/app-host-environment.type.ts)
105+
2. Copy an existing config from [`/src-ts/config/environments/environment.*.config.ts`](/src-ts/config/environments/environment.bsouza.config.ts)
106+
3. Rename new config `environment.[hostname].config.ts`
107+
4. Rename config variable to `EnvironmentConfig[HostName]`
108+
5. Set the `ENV` variable to `[hostname]`
109+
6. Add the switch case for the host name to [`/src-ts/config/environments/environment.config.ts`](/src-ts/config/environments/environment.config.ts)
104110
7. Prior to starting the server, set your host name:
105111
```% export REACT_APP_HOST_ENV=[hostname]```
106112

113+
>**NOTE:** Individual tools (e.g. [Learn tool](/src-ts/tools/learn/README.md)) can have their own configuration, which can be configured the same way as the global config.
114+
107115
#### For further convenience
108116

109117
1. Copy start-ssl-*.sh
@@ -117,7 +125,22 @@ The app uses CircleCI for CI/CD.
117125

118126
The "dev" branch is auto-deployed to the dev environment: https://platform-mvp.topcoder-dev.com.
119127

120-
The "master" branch is auto-deployed to the production environment: https://platform-mvp.topcoder.com.
128+
The "master" branch is auto-deployed to the production environment: https://platform-ui.topcoder.com.
129+
130+
## Developer Center Contentful API Key and Space Id
131+
132+
The app requires two environment variables, which contain the space id and the key used to access contentful and retrieve Thrive Articles.
133+
134+
You should create a file named `.env` in the root folder, and write inside the following lines:
135+
136+
```sh
137+
REACT_APP_CONTENTFUL_EDU_SPACE_ID=<space-id>
138+
REACT_APP_CONTENTFUL_EDU_CDN_API_KEY=<API Key>
139+
```
140+
141+
We should use the same space ID and API Key as Topcoder Thrive, these are for fetching Thrive articles and videos in the landing page.
142+
143+
See the [Dev Center README](/src-ts/tools/dev-center/README.md) for further instructions on setting up the Dev Center.
121144

122145
## yarn Commands
123146

@@ -132,7 +155,11 @@ The "master" branch is auto-deployed to the production environment: https://plat
132155
| `yarn eslint` | Run eslint against js/x files and outputs report |
133156
| `yarn eslint:fix` | Run eslint against js/x files, fixes auto-fixable issues, and outputs report |
134157
| `yarn test` | Run unit tests, watching for changes and re-running per your specifications |
135-
| `yarn test:no-watch` | Run unit tests once, without watching for changes or re-running |
158+
| `yarn test:no-watch` | Run unit tests once, without watching for changes or re-running |
159+
| `yarn cy:run` | Run e2e tests once in local command with the site is running |
160+
| `yarn cy:ci` | Run e2e tests once by circle ci |
161+
| `yarn report:coverage`| Generate e2e coverage report in html format |
162+
| `yarn report:coverage:text` | Generate e2e coverage report in text format |
136163

137164
## Folder Structure
138165

@@ -247,9 +274,10 @@ The PlatformRoute model has several useful options:
247274
| `element: JSX.Element` | The element property is the JSX element that should appear at the specified URL. |
248275
| `disabled?: boolean` | When a route is marked as disabled, it will not be registered and will the URL will return a 404. |
249276
| `hide?: boolean` | When a route is hidden, it will be registered and the URL will be available through deep-linking but will not be visible in either the Tools or Utils Selectors. This is useful for handling redirects for obsolete routes. |
250-
| `requireAuth?: boolean` | Requiring authentication for a route means that users who are not logged in will be redirected to the Login Form when they try to access the route. |
277+
| `authRequired?: boolean` | Requiring authentication for a route means that users who are not logged in will be redirected to the Login Form when they try to access the route. |
251278
| `route: string` | The route property is the path to the route, relative to its parent(s). |
252279
| `title: string` | The title property is the text that will appear in the Tools or Utils Selectors (this is irrelevant on hidden routes). |
280+
| `rolesRequired: Array<string>` | Requiring roles for a route means that users who do not own the roles will be presented with restricted page when they try to access the route. |
253281

254282
## Git
255283

@@ -465,8 +493,8 @@ e.g.:
465493
```
466494
.logo-link {
467495
svg {
468-
width: calc($pad-xxl + $pad-xxxxl);
469-
height: $pad-xl;
496+
width: calc($space-xxl + $space-xxxxl);
497+
height: $space-xl;
470498
fill: none;
471499

472500
path {

babel.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module.exports = function (api) {
5050
],
5151
],
5252
plugins: [
53+
"istanbul",
5354
[
5455
"module-resolver",
5556
{

cypress.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { defineConfig } from 'cypress'
2+
3+
export default defineConfig({
4+
fixturesFolder: false,
5+
video: false,
6+
screenshotOnRunFailure: false,
7+
defaultCommandTimeout: 10000,
8+
e2e: {
9+
baseUrl: 'http://localhost:3000',
10+
specPattern: "cypress/e2e/**/*.spec.{js,jsx,ts,tsx}",
11+
supportFile: "cypress/support/e2e.ts",
12+
viewportHeight: 1000,
13+
viewportWidth: 1280,
14+
setupNodeEvents(on, config) {
15+
require('@cypress/code-coverage/task')(on, config)
16+
return config;
17+
},
18+
},
19+
})

cypress/.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["plugin:cypress/recommended"]
3+
}

cypress/e2e/home/home.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
describe('Landing Page', () => {
2+
3+
beforeEach(() => cy.visit('/'))
4+
5+
it('loads landing page should be successfully', () => {
6+
cy.get('[data-id="root"]').should('be.visible')
7+
})
8+
})

cypress/support/commands.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference types="cypress" />
2+
3+
Cypress.on('uncaught:exception', () => {
4+
// returning false here prevents Cypress from failing the test
5+
return false
6+
})
7+
8+
export {}

cypress/support/e2e.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@cypress/code-coverage/support'
2+
import './commands'

cypress/tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": ["./**/*.ts"],
4+
"exclude": [],
5+
"compilerOptions": {
6+
"types": ["cypress"],
7+
"lib": ["es2015", "dom"],
8+
"isolatedModules": false,
9+
"allowJs": true,
10+
"noEmit": true
11+
}
12+
}

0 commit comments

Comments
 (0)