Skip to content

Commit

Permalink
Merge test changes to main - v0.33.0-pre.3ef8937 (#115)
Browse files Browse the repository at this point in the history
Automatically created pull-request in order to merge changes that were
recently pushed to the test branch, back to main
  • Loading branch information
hwinther authored Jun 21, 2024
2 parents caaf766 + 3ef8937 commit d3c8360
Show file tree
Hide file tree
Showing 26 changed files with 723 additions and 63 deletions.
5 changes: 3 additions & 2 deletions .github/actions/frontend-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ runs:
steps:
- uses: actions/setup-node@v4
name: Setup node (npm)
if: inputs.working_directory == 'npm'
if: inputs.package_manager == 'npm'
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: "${{ inputs.working_directory }}/package-lock.json"

- uses: actions/setup-node@v4
name: Setup node (yarn)
if: inputs.working_directory == 'yarn'
if: inputs.package_manager == 'yarn'
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
Expand Down Expand Up @@ -143,6 +143,7 @@ runs:

- name: Create Todo Comments
uses: gkampitakis/github-action-todo-commenter@v1
if: ${{ github.event_name == 'pull_request' }}
with:
github-token: ${{ env.GH_TOKEN }}
review-message: "Please take a look :eyes:"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ jobs:

- name: Create Todo Comments
uses: gkampitakis/github-action-todo-commenter@v1
if: ${{ github.event_name == 'pull_request' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
review-message: "Please take a look :eyes:"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ jobs:
uses: actions/checkout@v4

- uses: actions/setup-node@v4
name: Setup node
name: Setup node (yarn)
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: "${{ env.PLAYWRIGHT_PATH }}/package-lock.json"
cache: "yarn"
cache-dependency-path: "${{ env.PLAYWRIGHT_PATH }}/yarn.lock"

- name: Get API token and set environment variables
run: |
Expand All @@ -79,7 +79,7 @@ jobs:
echo "API_TOKEN=$(echo ${TOKEN})" >> $GITHUB_ENV
- name: Install dependencies
run: npm ci
run: yarn install --immutable --immutable-cache --check-cache

- name: Get installed Playwright version
id: playwright-version
Expand Down
4 changes: 4 additions & 0 deletions src/backend/WebApi/Entities/VersionInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,29 @@ public class VersionInformation(Assembly assembly)
/// <summary>
/// Constants defined in the assembly, if any.
/// </summary>
/// <example>["DEBUG","NET8"]</example>
public string[] Constants { get; private set; } = assembly
.GetCustomAttribute<DefineConstantsAttribute>()
?.Constants ?? [];

/// <summary>
/// The version of the assembly.
/// </summary>
/// <example>1.0.0</example>
public string Version { get; private set; } = assembly.GetCustomAttribute<AssemblyVersionAttribute>()
?.Version ?? "n/a";

/// <summary>
/// The informational version of the assembly, which may include additional details.
/// </summary>
/// <example>1.0.0-dev</example>
public string InformationalVersion { get; private set; } = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion ?? "n/a";

/// <summary>
/// The name of the environment where the application is running.
/// </summary>
/// <example>Development</example>
public string EnvironmentName { get; private set; } = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT")
?? Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
?? "Unknown";
Expand Down
3 changes: 3 additions & 0 deletions src/backend/WebApi/Entities/WeatherForecast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ public class WeatherForecast
/// <summary>
/// Date of forecast
/// </summary>
/// <example>2024.06.07</example>
public DateOnly Date { get; set; }

/// <summary>
/// Temperature in celsius
/// </summary>
/// <example>25</example>
public int TemperatureC { get; set; }

/// <summary>
/// Summary text
/// </summary>
/// <example>Sunny</example>
public string? Summary { get; set; }
}
24 changes: 17 additions & 7 deletions src/backend/WebApi/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,25 +407,32 @@
},
"description": "Constants defined in the assembly, if any.",
"nullable": true,
"readOnly": true
"readOnly": true,
"example": [
"DEBUG",
"NET8"
]
},
"version": {
"type": "string",
"description": "The version of the assembly.",
"nullable": true,
"readOnly": true
"readOnly": true,
"example": "1.0.0"
},
"informationalVersion": {
"type": "string",
"description": "The informational version of the assembly, which may include additional details.",
"nullable": true,
"readOnly": true
"readOnly": true,
"example": "1.0.0-dev"
},
"environmentName": {
"type": "string",
"description": "The name of the environment where the application is running.",
"nullable": true,
"readOnly": true
"readOnly": true,
"example": "Development"
}
},
"additionalProperties": false,
Expand All @@ -437,17 +444,20 @@
"date": {
"type": "string",
"description": "Date of forecast",
"format": "date"
"format": "date",
"example": "2024.06.07"
},
"temperatureC": {
"type": "integer",
"description": "Temperature in celsius",
"format": "int32"
"format": "int32",
"example": 25
},
"summary": {
"type": "string",
"description": "Summary text",
"nullable": true
"nullable": true,
"example": "Sunny"
}
},
"additionalProperties": false,
Expand Down
1 change: 0 additions & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@cspell/eslint-plugin": "^8.9.1",
"@eslint/js": "8.57.0",
"@faker-js/faker": "^8.4.1",
"@types/faker": "^6.6.9",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@typescript-eslint/eslint-plugin": "^7.2.0",
Expand Down
8 changes: 8 additions & 0 deletions src/frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type JSX, useEffect, useState } from 'react'

import './App.css'
import { useVersion } from './api/endpoints/service/service'
import { useGetWeatherForecast } from './api/endpoints/weather-forecast/weather-forecast'
import { type WeatherForecast } from './api/models'
import reactLogo from './assets/react.svg'
Expand All @@ -16,6 +17,7 @@ function App(): JSX.Element {
const [count, setCount] = useState(0)
const dispatch = useAuthDispatch()
const { data: weatherForecasts, refetch } = useGetWeatherForecast()
const { data: version } = useVersion()

useEffect(() => {
dispatch('token')
Expand Down Expand Up @@ -55,6 +57,12 @@ function App(): JSX.Element {
{wf.date}: {wf.summary} - {wf.temperatureC}
</p>
))}

{version !== null && (
<p style={{ fontSize: '0.7em' }}>
Version: {version?.informationalVersion} Env: {version?.environmentName} Mode: {import.meta.env.MODE}
</p>
)}
</>
)
}
Expand Down
135 changes: 135 additions & 0 deletions src/frontend/src/api/endpoints/blogging/blogging.msw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
//@ts-nocheck
import { faker } from '@faker-js/faker'
import { HttpResponse, delay, http } from 'msw'

export const getGetBlogsResponseMock = (): Blog[] =>
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
posts: faker.helpers.arrayElement([
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
content: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
postId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
title: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
})),
undefined,
]),
url: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
}))

export const getPostBlogResponseMock = (overrideResponse: Partial<Blog> = {}): Blog => ({
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
posts: faker.helpers.arrayElement([
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
blog: faker.helpers.arrayElement([
{
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
posts: faker.helpers.arrayElement([[], undefined]),
url: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
},
undefined,
]),
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
content: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
postId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
title: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
})),
undefined,
]),
url: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
...overrideResponse,
})

export const getGetPostsResponseMock = (): Post[] =>
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
blog: faker.helpers.arrayElement([
{
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
posts: faker.helpers.arrayElement([[], undefined]),
url: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
},
undefined,
]),
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
content: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
postId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
title: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
}))

export const getPostPostResponseMock = (overrideResponse: Partial<Post> = {}): Post => ({
blog: faker.helpers.arrayElement([
{
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
posts: faker.helpers.arrayElement([
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
content: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
postId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
title: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
})),
undefined,
]),
url: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
},
undefined,
]),
blogId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
content: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
postId: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
title: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
...overrideResponse,
})

export const getGetBlogsMockHandler = () => {
return http.get('*/Blogging/Blog', async () => {
await delay(1000)
return new HttpResponse(getGetBlogsResponseMock(), {
status: 200,
headers: {
'Content-Type': 'text/plain',
},
})
})
}

export const getPostBlogMockHandler = () => {
return http.post('*/Blogging/Blog', async () => {
await delay(1000)
return new HttpResponse(getPostBlogResponseMock(), {
status: 200,
headers: {
'Content-Type': 'text/plain',
},
})
})
}

export const getGetPostsMockHandler = () => {
return http.get('*/Blogging/Post', async () => {
await delay(1000)
return new HttpResponse(getGetPostsResponseMock(), {
status: 200,
headers: {
'Content-Type': 'text/plain',
},
})
})
}

export const getPostPostMockHandler = () => {
return http.post('*/Blogging/Post', async () => {
await delay(1000)
return new HttpResponse(getPostPostResponseMock(), {
status: 200,
headers: {
'Content-Type': 'text/plain',
},
})
})
}
export const getBloggingMock = () => [
getGetBlogsMockHandler(),
getPostBlogMockHandler(),
getGetPostsMockHandler(),
getPostPostMockHandler(),
]
Loading

0 comments on commit d3c8360

Please sign in to comment.