Skip to content

Commit

Permalink
Merge pull request #297 from PagerDuty/release/0.10.0-beta.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gsreynolds authored Aug 30, 2023
2 parents d77621a + b467052 commit d5adcd1
Show file tree
Hide file tree
Showing 150 changed files with 3,172 additions and 6,728 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
build
build
src/config/version.js
37 changes: 30 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { OFF, WARN, ERROR } = {
const {
OFF, WARN, ERROR,
} = {
OFF: 0,
WARN: 1,
ERROR: 2,
Expand All @@ -10,27 +12,41 @@ module.exports = {
browser: true,
es2021: true,
},
extends: ['plugin:react/recommended', 'airbnb', 'plugin:cypress/recommended'],
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'airbnb',
'plugin:cypress/recommended',
],
parser: '@babel/eslint-parser',
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: 12,
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['react', 'prettier', 'cypress'],
plugins: [
'react',
'prettier',
'cypress',
'jsx',
'react-refresh',
],
rules: {
'max-len': [WARN, { code: 120, ignorePattern: '^import\\W.*', ignoreTrailingComments: true }],
'object-curly-newline': [
WARN,
{ ObjectPattern: { multiline: true, minProperties: 1 }, ImportDeclaration: 'always' },
],
'react/prop-types': OFF, // To be done in another refactor
'react/react-in-jsx-scope': OFF,
'react/jsx-filename-extension': [ERROR, { extensions: ['.js', '.jsx'] }],
// 'react/jsx-filename-extension': [ERROR, { extensions: ['.js', '.jsx'] }],
'no-param-reassign': [ERROR, { props: true, ignorePropertyModificationsFor: ['draft'] }],
'no-use-before-define': [ERROR, { functions: false }],
'no-plusplus': [ERROR, { allowForLoopAfterthoughts: true }],
'jest/expect-expect': OFF,
'react-refresh/only-export-components': OFF, // To be done in another refactor
'react-hooks/exhaustive-deps': OFF, // To be done in another refactor
'react-hooks/rules-of-hooks': OFF, // To be done in another refactor
},
overrides: [
{
Expand All @@ -46,7 +62,14 @@ module.exports = {
},
],
settings: {
react: { version: '18.2' },
'import/resolver': {
alias: {
map: [
['src', './src'],
],
extensions: ['.ts', '.js', '.jsx', '.json'],
},
node: {
extensions: ['.ts', '.js', '.jsx', '.json'],
paths: ['node_modules/', 'node_modules/@types', 'src/'],
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/cd-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ jobs:
runs-on: ubuntu-latest
env:
CI: false
REACT_APP_PD_ENV: ${{ secrets.PD_ENV }}
REACT_APP_PD_SUBDOMAIN_ALLOW_LIST: '*'
REACT_APP_PD_OAUTH_CLIENT_ID: ${{ secrets.PD_OAUTH_CLIENT_ID }}
REACT_APP_PD_OAUTH_CLIENT_SECRET: ${{ secrets.PD_OAUTH_CLIENT_SECRET }}
REACT_APP_PD_REQUIRED_ABILITY: ${{ secrets.PD_REQUIRED_ABILITY }}
REACT_APP_DD_APPLICATION_ID: ${{ secrets.DD_APPLICATION_ID }}
REACT_APP_DD_CLIENT_TOKEN: ${{ secrets.DD_CLIENT_TOKEN }}
REACT_APP_DD_SITE: ${{ secrets.DD_SITE }}
REACT_APP_DD_SAMPLE_RATE: ${{ secrets.DD_SAMPLE_RATE }}
REACT_APP_DD_TRACK_INTERACTIONS: ${{ secrets.DD_TRACK_INTERACTIONS }}
REACT_APP_DD_DEFAULT_PRIVACY_LEVEL: ${{ secrets.DD_DEFAULT_PRIVACY_LEVEL }}
VITE_PD_ENV: ${{ secrets.PD_ENV }}
VITE_PD_SUBDOMAIN_ALLOW_LIST: '*'
VITE_PD_OAUTH_CLIENT_ID: ${{ secrets.PD_OAUTH_CLIENT_ID }}
VITE_PD_OAUTH_CLIENT_SECRET: ${{ secrets.PD_OAUTH_CLIENT_SECRET }}
VITE_PD_REQUIRED_ABILITY: ${{ secrets.PD_REQUIRED_ABILITY }}
VITE_DD_APPLICATION_ID: ${{ secrets.DD_APPLICATION_ID }}
VITE_DD_CLIENT_TOKEN: ${{ secrets.DD_CLIENT_TOKEN }}
VITE_DD_SITE: ${{ secrets.DD_SITE }}
VITE_DD_SAMPLE_RATE: ${{ secrets.DD_SAMPLE_RATE }}
VITE_DD_TRACK_INTERACTIONS: ${{ secrets.DD_TRACK_INTERACTIONS }}
VITE_DD_DEFAULT_PRIVACY_LEVEL: ${{ secrets.DD_DEFAULT_PRIVACY_LEVEL }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
34 changes: 22 additions & 12 deletions .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .tool-versions
- name: Node Version
run: node -v
- name: Install Yarn
run: npm install -g yarn
# https://github.com/actions/cache/blob/main/examples.md#node---yarn
Expand All @@ -33,6 +38,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .tool-versions
- name: Node Version
run: node -v
- name: Install Yarn
run: npm install -g yarn
- name: Get yarn cache directory path
Expand All @@ -52,7 +62,7 @@ jobs:
needs: install
runs-on: ubuntu-latest
container:
image: cypress/browsers:node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1
image: cypress/browsers:node-20.5.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1
options: --user 1001
strategy:
fail-fast: false
Expand All @@ -64,16 +74,16 @@ jobs:
- Settings/settings.spec.js
- app.spec.js
env:
REACT_APP_PD_ENV: 'github-ci'
REACT_APP_PD_SUBDOMAIN_ALLOW_LIST: '*'
REACT_APP_PD_USER_TOKEN: ${{ secrets.PD_INTEGRATION_USER_TOKEN }}
REACT_APP_PD_REQUIRED_ABILITY: ${{ secrets.PD_REQUIRED_ABILITY }}
REACT_APP_DD_APPLICATION_ID: ${{ secrets.DD_APPLICATION_ID }}
REACT_APP_DD_CLIENT_TOKEN: ${{ secrets.DD_CLIENT_TOKEN }}
REACT_APP_DD_SITE: ${{ secrets.DD_SITE }}
REACT_APP_DD_SAMPLE_RATE: ${{ secrets.DD_SAMPLE_RATE }}
REACT_APP_DD_TRACK_INTERACTIONS: ${{ secrets.DD_TRACK_INTERACTIONS }}
REACT_APP_DD_DEFAULT_PRIVACY_LEVEL: ${{ secrets.DD_DEFAULT_PRIVACY_LEVEL }}
VITE_PD_ENV: 'github-ci'
VITE_PD_SUBDOMAIN_ALLOW_LIST: '*'
VITE_PD_USER_TOKEN: ${{ secrets.PD_INTEGRATION_USER_TOKEN }}
VITE_PD_REQUIRED_ABILITY: ${{ secrets.PD_REQUIRED_ABILITY }}
VITE_DD_APPLICATION_ID: ${{ secrets.DD_APPLICATION_ID }}
VITE_DD_CLIENT_TOKEN: ${{ secrets.DD_CLIENT_TOKEN }}
VITE_DD_SITE: ${{ secrets.DD_SITE }}
VITE_DD_SAMPLE_RATE: ${{ secrets.DD_SAMPLE_RATE }}
VITE_DD_TRACK_INTERACTIONS: ${{ secrets.DD_TRACK_INTERACTIONS }}
VITE_DD_DEFAULT_PRIVACY_LEVEL: ${{ secrets.DD_DEFAULT_PRIVACY_LEVEL }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -87,7 +97,7 @@ jobs:
run: node -v
- name: Cypress run
# Uses the official Cypress GitHub action https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v5
uses: cypress-io/github-action@v6
with:
# Starts web server for E2E tests - replace with your own server invocation
# https://docs.cypress.io/guides/continuous-integration/introduction#Boot-your-server
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# MUST match .node-version
nodejs 18.16.1
nodejs 20.5.1
yarn 1.22.19
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ If you wish to maintain + deploy your own version of PagerDuty Live, we recommen

#### Local Development

1. Install [NodeJS v18.16.1](https://nodejs.org/en/blog/release/v18.16.1) via [`asdf install`](https://github.com/asdf-vm/asdf) / [`nvm`](https://github.com/nvm-sh/nvm)
1. Install [NodeJS v20.5.1](https://nodejs.org/en/blog/release/v20.5.1/) via [`asdf install`](https://github.com/asdf-vm/asdf) / [`nvm`](https://github.com/nvm-sh/nvm)

2. `$ git clone` repo to desired destination and `$ cd pd-live-react` into directory

Expand All @@ -43,18 +43,18 @@ If you wish to maintain + deploy your own version of PagerDuty Live, we recommen
The following _optional_ parameters can be used in a `.env` file to override PagerDuty Live during `$ yarn start`:
| Parameter | Usage |
| ----------- | ----------- |
| `REACT_APP_PD_ENV` | PagerDuty Live Environment Tag; defaults to `localhost-dev` if not set |
| `REACT_APP_PD_OAUTH_CLIENT_ID` | PagerDuty OAuth App client ID (created upon registering app) |
| `REACT_APP_PD_OAUTH_CLIENT_SECRET` | PagerDuty OAuth App client secret (created upon registering app) |
| `REACT_APP_PD_USER_TOKEN` | PagerDuty [Personal API Token](https://support.pagerduty.com/docs/generating-api-keys#generating-a-personal-rest-api-key); this will override OAuth login workflow if set and should be used for integration tests|
| `REACT_APP_PD_SUBDOMAIN_ALLOW_LIST` | Comma separated list of allowed subdomains (e.g. `acme-prod,acme-dev`) |
| `REACT_APP_PD_REQUIRED_ABILITY` | PagerDuty account-level [ability](https://developer.pagerduty.com/api-reference/b3A6Mjc0ODEwMg-list-abilities) required to use application |
| `REACT_APP_DD_APPLICATION_ID` | Datadog [RUM Application ID](https://docs.datadoghq.com/real_user_monitoring/browser/#setup) |
| `REACT_APP_DD_CLIENT_TOKEN` | Datadog [RUM Client Token](https://docs.datadoghq.com/account_management/api-app-keys/#client-tokens) |
| `REACT_APP_DD_SITE` | Datadog [site](https://docs.datadoghq.com/agent/basic_agent_usage/?tab=agentv6v7#datadog-site) (e.g. `datadoghq.com`) |
| `REACT_APP_DD_SAMPLE_RATE` | Datadog [RUM Sample Rate](https://docs.datadoghq.com/real_user_monitoring/browser/#browser-and-session-replay-sampling-configuration) (e.g. `100`) |
| `REACT_APP_DD_TRACK_INTERACTIONS` | Datadog [RUM Track Interactions](https://docs.datadoghq.com/real_user_monitoring/browser/tracking_user_actions/?tab=npm) (e.g. `true`) |
| `REACT_APP_DD_DEFAULT_PRIVACY_LEVEL` | Datadog [RUM Default Privacy Level](https://docs.datadoghq.com/real_user_monitoring/session_replay/privacy_options/?tab=maskuserinput) (e.g. `mask-user-input`) |
| `VITE_PD_ENV` | PagerDuty Live Environment Tag; defaults to `localhost-dev` if not set |
| `VITE_PD_OAUTH_CLIENT_ID` | PagerDuty OAuth App client ID (created upon registering app) |
| `VITE_PD_OAUTH_CLIENT_SECRET` | PagerDuty OAuth App client secret (created upon registering app) |
| `VITE_PD_USER_TOKEN` | PagerDuty [Personal API Token](https://support.pagerduty.com/docs/generating-api-keys#generating-a-personal-rest-api-key); this will override OAuth login workflow if set and should be used for integration tests|
| `VITE_PD_SUBDOMAIN_ALLOW_LIST` | Comma separated list of allowed subdomains (e.g. `acme-prod,acme-dev`) |
| `VITE_PD_REQUIRED_ABILITY` | PagerDuty account-level [ability](https://developer.pagerduty.com/api-reference/b3A6Mjc0ODEwMg-list-abilities) required to use application |
| `VITE_DD_APPLICATION_ID` | Datadog [RUM Application ID](https://docs.datadoghq.com/real_user_monitoring/browser/#setup) |
| `VITE_DD_CLIENT_TOKEN` | Datadog [RUM Client Token](https://docs.datadoghq.com/account_management/api-app-keys/#client-tokens) |
| `VITE_DD_SITE` | Datadog [site](https://docs.datadoghq.com/agent/basic_agent_usage/?tab=agentv6v7#datadog-site) (e.g. `datadoghq.com`) |
| `VITE_DD_SAMPLE_RATE` | Datadog [RUM Sample Rate](https://docs.datadoghq.com/real_user_monitoring/browser/#browser-and-session-replay-sampling-configuration) (e.g. `100`) |
| `VITE_DD_TRACK_INTERACTIONS` | Datadog [RUM Track Interactions](https://docs.datadoghq.com/real_user_monitoring/browser/tracking_user_actions/?tab=npm) (e.g. `true`) |
| `VITE_DD_DEFAULT_PRIVACY_LEVEL` | Datadog [RUM Default Privacy Level](https://docs.datadoghq.com/real_user_monitoring/session_replay/privacy_options/?tab=maskuserinput) (e.g. `mask-user-input`) |

## Testing

Expand All @@ -63,7 +63,7 @@ The following scripts have been created to run unit, component, and integration
- `$ yarn jest` (Jest Unit/Component)
- `$ yarn cypress:run:local` (Cypress Integration with headless Chromedriver)

Please note that running integration tests will require environment variable `REACT_APP_PD_USER_TOKEN` set.
Please note that running integration tests will require environment variable `VITE_PD_USER_TOKEN` set.

The integration tests also assume the PagerDuty account associated with the above user token has been setup with the following [Terraform environment](https://github.com/pagerduty/pd-live-integration-test-environment).

Expand Down
32 changes: 0 additions & 32 deletions craco.config.js

This file was deleted.

30 changes: 11 additions & 19 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const { defineConfig } = require("cypress");
const dotenv = require("dotenv");
const cypressFailFast = require("cypress-fail-fast/plugin");
/* eslint-disable import/no-extraneous-dependencies */
const {
defineConfig,
} = require('cypress');
const dotenv = require('dotenv');
const cypressFailFast = require('cypress-fail-fast/plugin');

module.exports = defineConfig({
video: false,
Expand All @@ -13,25 +16,14 @@ module.exports = defineConfig({
setupNodeEvents(on, config) {
dotenv.config();
cypressFailFast(on, config);
config.env.PD_USER_TOKEN = process.env.REACT_APP_PD_USER_TOKEN;
// eslint-disable-next-line no-param-reassign
config.env.PD_USER_TOKEN = process.env.VITE_PD_USER_TOKEN;
return config;
},
baseUrl: "http://localhost:3000/pd-live-react",
specPattern: "cypress/e2e/**/*.spec.{js,ts,jsx,tsx}",
baseUrl: 'http://localhost:3000/pd-live-react',
specPattern: 'cypress/e2e/**/*.spec.{js,ts,jsx,tsx}',
// Cypress 12 introduces Test Isolation by default which breaks our current tests
// https://docs.cypress.io/guides/references/migration-guide#Test-Isolation
testIsolation: false
},

component: {
setupNodeEvents(on, config) {},
specPattern: "src/**/*.spec.{js,ts,jsx,tsx}",
},

component: {
devServer: {
framework: "create-react-app",
bundler: "webpack",
},
testIsolation: false,
},
});
37 changes: 33 additions & 4 deletions cypress/e2e/Incidents/incidents.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => {
['Responders', 'responders'],
['Latest Log Entry Type', 'latest_log_entry_type'],
];
manageIncidentTableColumns('add', columns.map((column) => column[1]));
manageIncidentTableColumns(
'add',
columns.map((column) => column[1]),
);
waitForIncidentTable();
});

Expand All @@ -44,7 +47,10 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => {
['Responders', 'responders'],
['Latest Log Entry Type', 'latest_log_entry_type'],
];
manageIncidentTableColumns('add', columns.map((column) => column[1]));
manageIncidentTableColumns(
'add',
columns.map((column) => column[1]),
);
}
waitForIncidentTable();
});
Expand All @@ -64,6 +70,19 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => {
selectAllIncidents();
});

it('Shift-select multiple incidents', () => {
selectIncident(0);
selectIncident(4, true);
cy.get('.selected-incidents-badge').then(($el) => {
const text = $el.text();
const incidentNumbers = text.split(' ')[0].split('/');
expect(incidentNumbers[0]).to.equal('5');
});
// Unselect all incidents for the next run
selectAllIncidents();
selectAllIncidents();
});

it('Acknowledge singular incident', () => {
const incidentIdx = 0;
selectIncident(incidentIdx);
Expand Down Expand Up @@ -110,7 +129,12 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => {
addNote(note);
checkActionAlertsModalContent('have been updated with a note');
checkIncidentCellContent(incidentId, 'Latest Note', note);
checkIncidentCellContentHasLink(incidentId, 'Latest Note', 'example.com', 'http://example.com');
checkIncidentCellContentHasLink(
incidentId,
'Latest Note',
'example.com',
'http://example.com',
);
});
});

Expand All @@ -123,7 +147,12 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => {
addNote(note);
checkActionAlertsModalContent('have been updated with a note');
checkIncidentCellContent(incidentId, 'Latest Note', note);
checkIncidentCellContentHasLink(incidentId, 'Latest Note', '[email protected]', 'mailto:[email protected]');
checkIncidentCellContentHasLink(
incidentId,
'Latest Note',
'[email protected]',
'mailto:[email protected]',
);
});
});

Expand Down
7 changes: 2 additions & 5 deletions cypress/e2e/Query/query.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable cypress/unsafe-to-chain-command */
import moment from 'moment';
import moment from 'moment/min/moment-with-locales';

import gb from 'date-fns/locale/en-GB';
import {
Expand Down Expand Up @@ -53,10 +53,7 @@ describe('Query Incidents', { failFast: { enabled: false } }, () => {
.subtract(1, 'days')
.set({ hour: 0, minute: 0, second: 0, millisecond: 0 });
cy.get('#query-date-input').click();
cy.get('#since-date-input')
.clear()
.type(queryDate.format('DD/MM/yyyy'))
.type('{enter}');
cy.get('#since-date-input').clear().type(queryDate.format('DD/MM/yyyy')).type('{enter}');
cy.get('#query-date-submit').click();
waitForIncidentTable();

Expand Down
Loading

0 comments on commit d5adcd1

Please sign in to comment.