-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Playwright tests for website - Change to use mock service worker (msw) instead of targeting actual API, to make testing in CI easier - Check /api/user/me in oauth callback to prevent 404s later if a user doesnt have a savefile - Some styling and rendering changes to news page
- Loading branch information
1 parent
51b5e64
commit 0ab3f1d
Showing
43 changed files
with
1,096 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Website | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- Website/** | ||
pull_request: | ||
paths: | ||
- Website/** | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
playwright: | ||
name: Playwright test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: "Website" | ||
lfs: true | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
|
||
- name: Setup node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
cache: "pnpm" | ||
cache-dependency-path: "Website/pnpm-lock.yaml" | ||
|
||
- name: Install dependencies | ||
working-directory: Website/ | ||
run: pnpm install | ||
|
||
- name: Install Playwright browsers | ||
working-directory: Website/ | ||
run: pnpm exec playwright install --with-deps chromium | ||
|
||
- name: Run Playwright tests | ||
working-directory: Website/ | ||
run: pnpm exec playwright test | ||
|
||
- name: Upload report | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ !cancelled() }} | ||
with: | ||
name: playwright-report | ||
path: Website/playwright-report/ | ||
retention-days: 3 | ||
|
||
- name: Upload snapshots | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ !cancelled() }} | ||
with: | ||
name: snapshots | ||
path: Website/tests/__screenshots__/ | ||
retention-days: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
DragaliaAPI/DragaliaAPI/Features/Web/Savefile/SavefileController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using DragaliaAPI.Models.Generated; | ||
using DragaliaAPI.Services; | ||
using DragaliaAPI.Shared.Serialization; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace DragaliaAPI.Features.Web.Savefile; | ||
|
||
public class SavefileController(ILoadService loadService) : ControllerBase | ||
{ | ||
[HttpGet("export")] | ||
[Authorize(Policy = AuthConstants.PolicyNames.RequireDawnshardIdentity)] | ||
public async Task<FileResult> GetSavefile(CancellationToken cancellationToken) | ||
{ | ||
LoadIndexResponse savefile = await loadService.BuildIndexData(cancellationToken); | ||
|
||
return this.File( | ||
JsonSerializer.SerializeToUtf8Bytes(savefile, ApiJsonOptions.Instance), | ||
"application/json", | ||
"savedata.txt" | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-4.9 KB
(2.5%)
DragaliaAPI/DragaliaAPI/wwwroot/img/icon/Icon_Profile_Noframe_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-5.82 KB
(2.1%)
DragaliaAPI/DragaliaAPI/wwwroot/img/icon/Icon_Profile_Noframe_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
PUBLIC_DAWNSHARD_URL=http://localhost:3001/ | ||
PUBLIC_DAWNSHARD_API_URL=http://localhost:3001/api/ # use Vite proxy | ||
DAWNSHARD_API_URL_SSR=http://localhost:5000/ | ||
DAWNSHARD_API_URL_SSR=http://localhost:5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ vite.config.js.timestamp-* | |
vite.config.ts.timestamp-* | ||
.pnpm-store | ||
.idea | ||
test-results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/test'; | ||
import { devices, type PlaywrightTestConfig } from '@playwright/test'; | ||
|
||
const url = process.env.CI ? 'http://localhost:4173' : 'http://localhost:3001'; | ||
|
||
const config: PlaywrightTestConfig = { | ||
webServer: { | ||
command: 'pnpm run build && pnpm run preview', | ||
port: 4173 | ||
command: 'pnpm run build && pnpm run preview -- --mode dev', | ||
url, | ||
stdout: 'pipe', | ||
reuseExistingServer: !process.env.CI, | ||
timeout: 120000 | ||
}, | ||
use: { | ||
baseURL: url | ||
}, | ||
updateSnapshots: process.env.UPDATE_SNAPSHOTS ? 'all' : 'missing', | ||
ignoreSnapshots: !process.env.CI, | ||
testDir: 'tests', | ||
testMatch: /(.+\.)?(test|spec)\.[jt]s/ | ||
snapshotPathTemplate: '{testDir}/__screenshots__/{testFilePath}/{arg}{ext}', | ||
testMatch: /(.+\.)?(test|spec)\.[jt]s/, | ||
timeout: 600000, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] } | ||
} | ||
] | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.