Skip to content

Commit

Permalink
Added JS App handling of 401 authentications, with retry logic, and a…
Browse files Browse the repository at this point in the history
…dded jest tests
  • Loading branch information
jezzsantos committed Oct 29, 2024
1 parent 5f20ea5 commit 288fd0a
Show file tree
Hide file tree
Showing 22 changed files with 11,988 additions and 3,401 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ jobs:
dotnet-version: ${{env.DOTNET_VERSION}}
- name: Restore dependencies
run: dotnet restore "${{env.SOLUTION_PATH}}"
- name: Build for Azure Testing
- name: Build (Backend) for Azure Testing
run: dotnet build --configuration ${{env.TESTINGONLY_BUILD_CONFIGURATION}} "${{env.SOLUTION_PATH}}" /p:HostingPlatform=HOSTEDONAZURE
- name: Build for AWS Testing
- name: Build (Backend) for AWS Testing
run: dotnet build --configuration ${{env.TESTINGONLY_BUILD_CONFIGURATION}} "${{env.SOLUTION_PATH}}" /p:HostingPlatform=HOSTEDONAWS
- name: Build for Azure Deploy
- name: Build (Backend) for Azure Deploy
run: dotnet build --configuration ${{env.DEPLOY_BUILD_CONFIGURATION}} "${{env.SOLUTION_PATH}}" /p:HostingPlatform=HOSTEDONAZURE
- name: Build for AWS Deploy
- name: Build (Backend) for AWS Deploy
run: dotnet build --configuration ${{env.DEPLOY_BUILD_CONFIGURATION}} "${{env.SOLUTION_PATH}}" /p:HostingPlatform=HOSTEDONAWS
- name: Build WebsiteHost (FrontEnd)
run: |
cd src/WebsiteHost/ClientApp
cp .env.example .env
npm ci --cache .npm --prefer-offline
npm run build:releasefordeploy
test:
runs-on: windows-latest
timeout-minutes: 15
Expand All @@ -47,7 +53,7 @@ jobs:
run: dotnet restore "${{env.SOLUTION_PATH}}"
- name: Build for CI Testing (for Azure)
run: dotnet build --configuration ${{env.TESTINGONLY_BUILD_CONFIGURATION}} "${{env.SOLUTION_PATH}}" /p:HostingPlatform=HOSTEDONAZURE
- name: Unit Test
- name: Unit Test (Backend)
continue-on-error: false
run: >
dotnet test --no-build --verbosity normal
Expand All @@ -56,7 +62,7 @@ jobs:
--logger:"trx"
--logger:"junit;LogFileName={assembly}.junit.xml;MethodFormat=Class;FailureBodyFormat=Verbose"
--test-adapter-path:. "${{env.SOLUTION_PATH}}"
- name: Integration Test
- name: Integration Test (Backend)
continue-on-error: true
run: >
dotnet test --no-build --verbosity normal
Expand All @@ -65,6 +71,14 @@ jobs:
--logger:"trx"
--logger:"junit;LogFileName={assembly}.junit.xml;MethodFormat=Class;FailureBodyFormat=Verbose"
--test-adapter-path:. "${{env.SOLUTION_PATH}}"
- name: Test WebsiteHost (FrontEnd)
continue-on-error: false
run: |
cd src/WebsiteHost/ClientApp
cp .env.example .env
npm ci --cache .npm --prefer-offline
npm run build:releasefordeploy
npm run test:ci
- name: Testing Report
uses: dorny/[email protected]
if: success() || failure()
Expand Down
4 changes: 2 additions & 2 deletions README_DERIVATIVE.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ You need to create your own version of the `.env` file on your computer (not sou

1. Copy the `src/WebsiteHost/ClientApp/.env.example` to `src/WebsiteHost/ClientApp/.env`.

> DO NOT add this file `.env` to source control! This files exists locally for security purposes, and in order to have
> the right environment variables in place when running and testing the JS App.
> DO NOT add this file
`.env` to source control! This files exists locally for security purposes, and in order to have the right environment variables in place when running and testing the JS App.

# Build & Deploy

Expand Down
259 changes: 93 additions & 166 deletions docs/design-principles/0010-rest-api.md

Large diffs are not rendered by default.

313 changes: 118 additions & 195 deletions docs/design-principles/0110-back-end-for-front-end.md

Large diffs are not rendered by default.

375 changes: 143 additions & 232 deletions docs/how-to-guides/020-api-endpoint.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/.idea/.idea.SaaStack/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/SaaStack.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,7 @@ public void When$condition$_Then$outcome$()
<s:Boolean x:Key="/Default/UserDictionary/Words/=ctors/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=decryptor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dehydratable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=dorny/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dtos/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=el_0022_002C_0020Y/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=emaildelivery/@EntryIndexedValue">True</s:Boolean>
Expand Down Expand Up @@ -1809,6 +1810,7 @@ public void When$condition$_Then$outcome$()
<s:Boolean x:Key="/Default/UserDictionary/Words/=putpatch/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=readmodel/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=redrive/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=releasefordeploy/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SAASAPP/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SAASDDD/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SAASDOC/@EntryIndexedValue">True</s:Boolean>
Expand Down
3 changes: 3 additions & 0 deletions src/WebsiteHost/ClientApp/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [["@babel/preset-env", { targets: { node: "current" } }], "@babel/preset-typescript"]
};
194 changes: 194 additions & 0 deletions src/WebsiteHost/ClientApp/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/**
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/

import type { Config } from "jest";

const config: Config = {
// All imported modules in your tests should be mocked automatically
// automock: false,

// Stop running tests after `n` failures
// bail: 0,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "C:\\Users\\jezzs\\AppData\\Local\\Temp\\jest",

// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,

// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,

// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,

// The directory where Jest should output its coverage files
coverageDirectory: "../../TestResults/websitehost",

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "\\\\node_modules\\\\"
// ],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "babel",

// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: ["json", "text", "lcov", "clover", "cobertura"],

// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,

// A path to a custom dependency extractor
// dependencyExtractor: undefined,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// The default configuration for fake timers
// fakeTimers: {
// "enableGlobally": false
// },

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,

// A set of global variables that need to be available in all test environments
// globals: {},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",

// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],

// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "mjs",
// "cjs",
// "jsx",
// "ts",
// "tsx",
// "json",
// "node"
// ],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
// preset: undefined,

// Run tests from one or more projects
// projects: undefined,

// Use this configuration option to add custom reporters to Jest
reporters: ["default", ["jest-junit", { outputDirectory: "../../TestResults/websitehost", outputName: "junit.xml" }]],

// Automatically reset mock state before every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: undefined,

// Automatically restore mock state and implementation before every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: ["./src/testing/setup.ts"],

// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: "jsdom"

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "\\\\node_modules\\\\"
// ],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: undefined,

// This option allows use of a custom test runner
// testRunner: "jest-circus/runner",

// A map from regular expressions to paths to transformers
// transform: undefined,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "\\\\node_modules\\\\",
// "\\.pnp\\.[^\\\\]+$"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
// verbose: undefined,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
};

export default config;
Loading

0 comments on commit 288fd0a

Please sign in to comment.