Skip to content

Commit

Permalink
Merge pull request #15 from Azure-Samples/brecon/aprMerge
Browse files Browse the repository at this point in the history
Merge eshop with aspire preview5
  • Loading branch information
BrennanConroy authored Apr 17, 2024
2 parents 4d8741c + afd500c commit 22165f6
Show file tree
Hide file tree
Showing 83 changed files with 1,016 additions and 579 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
registries:
public-nuget:
type: nuget-feed
url: https://api.nuget.org/v3/index.json
updates:
- package-ecosystem: nuget
directory: "/"
registries:
- public-nuget
schedule:
interval: weekly
open-pull-requests-limit: 15

48 changes: 48 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Playwright Tests for eShop
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
- 'src/ClientApp/**'
- 'test/ClientApp.UnitTests/**'
- '.github/workflows/pr-validation-maui.yml'
pull_request:
branches: [ main ]
paths-ignore:
- '**.md'
- 'src/ClientApp/**'
- 'test/ClientApp.UnitTests/**'
- '.github/workflows/pr-validation-maui.yml'
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Install Aspire
run: |
dotnet workload update
dotnet workload install aspire
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install chromium
- name: Run Playwright tests
run: npx playwright test
env:
ESHOP_USE_HTTP_ENDPOINTS: 1
USERNAME1: bob
PASSWORD: Pass123$
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
42 changes: 42 additions & 0 deletions .github/workflows/pr-validation-maui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: eShop Pull Request Validation - .NET MAUI

on:
pull_request:
branches:
- '**'
paths:
- 'src/ClientApp/**'
- 'test/ClientApp.UnitTests/**'
- '.github/workflows/pr-validation-maui.yml'
push:
branches:
- main
paths:
- 'src/ClientApp/**'
- 'test/ClientApp.UnitTests/**'
- '.github/workflows/pr-validation-maui.yml'

jobs:
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET (global.json)
uses: actions/setup-dotnet@v3

- name: Update Workloads
run: dotnet workload update

- name: Install Workloads
shell: pwsh
run: |
dotnet workload install android
dotnet workload install ios
dotnet workload install maccatalyst
dotnet workload install maui
- name: Build
run: dotnet build src/ClientApp/ClientApp.csproj

- name: Test
run: dotnet test tests/ClientApp.UnitTests/ClientApp.UnitTests.csproj
10 changes: 7 additions & 3 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ on:
pull_request:
paths-ignore:
- '**.md'
- 'src/ClientApp/**'
- 'test/ClientApp.UnitTests/**'
- '.github/workflows/pr-validation-maui.yml'
push:
branches:
- main
paths-ignore:
- '**.md'

- 'src/ClientApp/**'
- 'test/ClientApp.UnitTests/**'
- '.github/workflows/pr-validation-maui.yml'

jobs:
test:
runs-on: ubuntu-latest

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET (global.json)
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -482,3 +482,12 @@ $RECYCLE.BIN/

# Vim temporary swap files
*.swp

# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
/user.json
.azure
4 changes: 0 additions & 4 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
<ItemGroup>
<!-- https:/rabbitmq/rabbitmq-dotnet-client/issues/1410 is tracking fixing the one EventSource warning in RabbitMQ. -->
<IlcArg Include="--singlewarnassembly:RabbitMQ.Client" />

<!-- https:/dotnet/runtime/issues/94117 will fix the warnings coming from the ConfigBinder source generator in these assemblies. -->
<IlcArg Include="--singlewarnassembly:Aspire.RabbitMQ.Client" />
<IlcArg Include="--singlewarnassembly:Aspire.StackExchange.Redis" />
</ItemGroup>
</Target>

Expand Down
71 changes: 36 additions & 35 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,28 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<AspnetVersion>8.0.0</AspnetVersion>
<MicrosoftExtensionsVersion>8.0.0</MicrosoftExtensionsVersion>
<EfVersion>8.0.0</EfVersion>
<RuntimeVersion>8.0.0</RuntimeVersion>
<AspireVersion>8.0.0-preview.2.23619.3</AspireVersion>
<GrpcVersion>2.59.0</GrpcVersion>
<AspnetVersion>8.0.3</AspnetVersion>
<MicrosoftExtensionsVersion>8.3.0</MicrosoftExtensionsVersion>
<EfVersion>8.0.3</EfVersion>
<AspireVersion>8.0.0-preview.5.24201.12</AspireVersion>
<GrpcVersion>2.62.0</GrpcVersion>
<DuendeVersion>7.0.4</DuendeVersion>
</PropertyGroup>
<ItemGroup>
<!-- Version together with Aspire -->
<PackageVersion Include="Aspire.Azure.Messaging.ServiceBus" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.AppHost" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.Azure.CognitiveServices" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.PostgreSQL" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.RabbitMQ" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.Redis" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.Azure" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.Azure.ApplicationInsights" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.Azure.ServiceBus" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Npgsql" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.StackExchange.Redis" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Azure.AI.OpenAI" Version="$(AspireVersion)" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="$(AspireVersion)" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery.Yarp" Version="$(AspireVersion)" />
<!-- Version together with ASP.NET -->
Expand All @@ -32,56 +39,50 @@
<PackageVersion Include="Microsoft.Extensions.Identity.Stores" Version="$(AspnetVersion)" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="$(MicrosoftExtensionsVersion)" />
<!-- Version together with EF -->
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="$(EfVersion)" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.15" />
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" />
<PackageVersion Include="Pgvector" Version="0.2.0" />
<PackageVersion Include="Pgvector.EntityFrameworkCore" Version="0.2.0" />
<!-- Version together with runtime -->
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="$(RuntimeVersion)" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="$(RuntimeVersion)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(RuntimeVersion)" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<!-- Xabaril packages -->
<PackageVersion Include="AspNetCore.HealthChecks.NpgSql" Version="7.1.0" />
<PackageVersion Include="AspNetCore.HealthChecks.UI" Version="7.0.2" />
<PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="7.1.0" />
<PackageVersion Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="7.0.0" />
<PackageVersion Include="AspNetCore.HealthChecks.Uris" Version="7.0.0" />
<PackageVersion Include="AspNetCore.HealthChecks.Uris" Version="8.0.1" />
<!-- AI -->
<PackageVersion Include="Azure.AI.OpenAI" Version="1.0.0-beta.12" />
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.0.1" />
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.7.1" />
<!-- Open Telemetry -->
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.6.0-beta.2" />
<PackageVersion Include="OpenTelemetry.Instrumentation.EventCounters" Version="1.5.1-alpha.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.6.0-beta.2" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.6.0-beta.2" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.5.1" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.6.0-beta.3" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.0" />
<!-- VS Test -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<!-- Scaffolding -->
<PackageVersion Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0-rc.1.23461.3" />
<!-- Grpc -->
<PackageVersion Include="Grpc.AspNetCore" Version="$(GrpcVersion)" />
<PackageVersion Include="Grpc.AspNetCore.Server.ClientFactory" Version="$(GrpcVersion)" />
<PackageVersion Include="Grpc.Tools" Version="2.59.0" PrivateAssets="All" />
<PackageVersion Include="Grpc.Tools" Version="$(GrpcVersion)" PrivateAssets="All" />
<!-- Azure -->
<PackageVersion Include="AspNetCore.HealthChecks.AzureServiceBus" Version="7.0.0" />
<PackageVersion Include="AspNetCore.HealthChecks.AzureServiceBus" Version="8.0.0" />
<PackageVersion Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.0.0-beta.8" />
<PackageVersion Include="Microsoft.Identity.Web" Version="2.15.3" />
<PackageVersion Include="Microsoft.Identity.Web" Version="2.17.4" />
<!-- Miscellaneous -->
<PackageVersion Include="Automapper" Version="12.0.1" />
<PackageVersion Include="Dapper" Version="2.0.151" />
<PackageVersion Include="Automapper" Version="13.0.1" />
<PackageVersion Include="Dapper" Version="2.1.35" />
<PackageVersion Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageVersion Include="MediatR" Version="12.2.0" />
<PackageVersion Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
<PackageVersion Include="Polly" Version="8.0.0" />
<PackageVersion Include="Polly" Version="8.3.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="System.Reflection.TypeExtensions" Version="4.7.0" />
<PackageVersion Include="xunit" Version="2.5.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.1" />
<PackageVersion Include="xunit" Version="2.6.6" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageVersion Include="Yarp.ReverseProxy" Version="2.1.0" />
</ItemGroup>
</Project>
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A reference .NET application implementing an eCommerce web site using a services
### Prerequisites

- Clone the eShop repository: https:/dotnet/eshopOnAzure
- (Windows only) Install Visual Studio. Visual Studio contains tooling support for .NET Aspire that you will want to have. [Visual Studio 2022 version 17.9 Preview](https://visualstudio.microsoft.com/vs/preview/).
- (Windows only) Install Visual Studio. Visual Studio contains tooling support for .NET Aspire that you will want to have. [Visual Studio 2022 version 17.10 Preview](https://visualstudio.microsoft.com/vs/preview/).
- During installation, ensure that the following are selected:
- `ASP.NET and web development` workload.
- `.NET Aspire SDK` component in `Individual components`.
Expand Down Expand Up @@ -47,7 +47,37 @@ Now listening on: http://localhost:18848

The sample catalog data is defined in [catalog.json](https:/dotnet/eShop/blob/main/src/Catalog.API/Setup/catalog.json). Those product names, descriptions, and brand names are fictional and were generated using [GPT-35-Turbo](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/chatgpt), and the corresponding [product images](https:/dotnet/eShop/tree/main/src/Catalog.API/Pics) were generated using [DALL·E 3](https://openai.com/dall-e-3).

### Contributing
## Use Azure Developer CLI

You can use the [Azure Developer CLI](https://aka.ms/azd) to run this project on Azure with only a few commands. Follow the next instructions:

- Install [azd](https://aka.ms/azure-dev/install).
- Log in `azd` (if you haven't done it before) to your Azure account:
```sh
azd auth login
```
- Initialize `azd` from the root of the repo.
```sh
azd init
```
- During init:
- Select `Use code in the current directory`. Azd will automatically detect the Dotnet Aspire project.
- Confirm `.Net (Aspire)` and continue.
- Select which services to expose to the Internet (exposing `webapp` is enough to test the sample).
- Finalize the initialization by giving a name to your environment.

- Create Azure resources and deploy the sample by running:
```sh
azd up
```
Notes:
- The operation takes a few minutes the first time it is ever run for an environment.
- At the end of the process, `azd` will display the `url` for the webapp. Follow that link to test the sample.
- You can run `azd up` after saving changes to the sample to re-deploy and update the sample.
- Report any issues to [azure-dev](https:/Azure/azure-dev/issues) repo.
- [FAQ and troubleshoot](https://learn.microsoft.com/azure/developer/azure-developer-cli/troubleshoot?tabs=Browser) for azd.

## Contributing

For more information on contributing to this repo, please read [the contribution documentation](./CONTRIBUTING.md) and [the Code of Conduct](CODE-OF-CONDUCT.md).

Expand Down
16 changes: 16 additions & 0 deletions e2e/AddItemTest.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { test, expect } from '@playwright/test';

test('Add item to the cart', async ({ page }) => {
await page.goto('/');

await expect(page.getByRole('heading', { name: 'Ready for a new adventure?' })).toBeVisible();
await page.getByRole('link', { name: 'Adventurer GPS Watch' }).click();
await page.getByRole('button', { name: 'Add to shopping bag' }).click();
await page.getByRole('link', { name: 'shopping bag' }).click();
await page.getByRole('heading', { name: 'Shopping bag' }).click();

await page.getByText('Total').nth(1).click();
await page.getByLabel('product quantity').getByText('1');

await expect.poll(() => page.getByLabel('product quantity').count()).toBeGreaterThan(0);
});
13 changes: 13 additions & 0 deletions e2e/BrowseItemTest.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { test, expect } from '@playwright/test';

test('Browse Items', async ({ page }) => {
await page.goto('/');

await expect(page.getByRole('heading', { name: 'Ready for a new adventure?' })).toBeVisible();

await page.getByRole('link', { name: 'Adventurer GPS Watch' }).click();
await page.getByRole('heading', { name: 'Adventurer GPS Watch' }).click();

//Expect
await expect(page.getByRole('heading', { name: 'Adventurer GPS Watch' })).toBeVisible();
});
21 changes: 21 additions & 0 deletions e2e/RemoveItemTest.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test, expect } from '@playwright/test';

test('Remove item from cart', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('heading', { name: 'Ready for a new adventure?' })).toBeVisible();

await page.getByRole('link', { name: 'Adventurer GPS Watch' }).click();
await expect(page.getByRole('heading', { name: 'Adventurer GPS Watch' })).toBeVisible();

await page.getByRole('button', { name: 'Add to shopping bag' }).click();
await page.getByRole('link', { name: 'shopping bag' }).click();
await expect(page.getByRole('heading', { name: 'Shopping bag' })).toBeVisible();

await expect.poll(() => page.getByLabel('product quantity').count()).toBeGreaterThan(0);

await page.getByLabel('product quantity').fill('0');

await page.getByRole('button', { name: 'Update' }).click();

await expect(page.getByText('Your shopping bag is empty')).toBeVisible();
});
20 changes: 20 additions & 0 deletions e2e/login.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { test as setup, expect } from '@playwright/test';
import { STORAGE_STATE } from '../playwright.config';
import { assert } from 'console';

assert(process.env.USERNAME1, 'USERNAME1 is not set');
assert(process.env.PASSWORD, 'PASSWORD is not set');

setup('Login', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('heading', { name: 'Ready for a new adventure?' })).toBeVisible();

await page.getByLabel('Sign in').click();
await expect(page.getByRole('heading', { name: 'Login' })).toBeVisible();

await page.getByPlaceholder('Username').fill(process.env.USERNAME1!);
await page.getByPlaceholder('Password').fill(process.env.PASSWORD!);
await page.getByRole('button', { name: 'Login' }).click();
await expect(page.getByRole('heading', { name: 'Ready for a new adventure?' })).toBeVisible();
await page.context().storageState({ path: STORAGE_STATE });
})
Loading

0 comments on commit 22165f6

Please sign in to comment.