Copilot commented on code in PR #3050:
URL: https://github.com/apache/apisix-dashboard/pull/3050#discussion_r2086565862


##########
playwright.config.ts:
##########
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { defineConfig, devices } from '@playwright/test';
+
+import { env } from './e2e/utils/env';
+
+/**
+ * See https://playwright.dev/docs/test-configuration.
+ */
+export default defineConfig({
+  tsconfig: './tsconfig.e2e.json',
+  testDir: './e2e',
+  outputDir: './test-results',
+  fullyParallel: true,
+  forbidOnly: !!process.env.CI,
+  retries: process.env.CI ? 2 : 0,
+  workers: process.env.CI ? 1 : undefined,
+  reporter: [
+    ['html'],
+    ['list'],
+    [
+      '@estruyf/github-actions-reporter',
+      {
+        useDetails: true,
+        showError: true,
+      },
+    ],
+  ],
+  use: {
+    baseURL: env.E2E_TARGET_URL,
+    trace: 'on-first-retry',
+  },
+
+  projects: [
+    {
+      name: 'chromium',
+      use: {
+        ...devices['Desktop Chrome'],
+        viewport: { width: 1920, height: 1080 },
+        permissions: ['clipboard-read'],
+        // use chrome
+        // channel: "chrome",

Review Comment:
   [nitpick] Consider removing or clarifying the commented-out 'channel: 
"chrome"' configuration if it is no longer needed.
   ```suggestion
   
   ```



##########
eslint.config.js:
##########
@@ -1,19 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 import js from '@eslint/js'
-import globals from 'globals'
+import headers from "eslint-plugin-headers";
+import importPlugin from 'eslint-plugin-import';
+import playwright from 'eslint-plugin-playwright'
 import react from 'eslint-plugin-react'
 import reactHooks from 'eslint-plugin-react-hooks'
 import reactRefresh from 'eslint-plugin-react-refresh'
-import tseslint from 'typescript-eslint'
-import unusedImports from 'eslint-plugin-unused-imports'
 import simpleImportSort from 'eslint-plugin-simple-import-sort'
-import importPlugin from 'eslint-plugin-import';
-import headers from "eslint-plugin-headers";
+import unusedImports from 'eslint-plugin-unused-imports'
+import globals from 'globals'
+import tseslint from 'typescript-eslint'
+
+const importRules = tseslint.config({
+  plugins: {
+    "unused-imports": unusedImports,
+    "simple-import-sort": simpleImportSort,
+    "import": importPlugin,
+  },
+  rules: {
+    "no-unused-vars": "off",
+    "unused-imports/no-unused-imports": "error",
+    "unused-imports/no-unused-vars": [
+      "warn",
+      {
+        "vars": "all",
+        "varsIgnorePattern": "^_",
+        "args": "after-used",
+        "argsIgnorePattern": "^_",
+      },
+    ],
+    "simple-import-sort/imports": "error",
+    "simple-import-sort/exports": "error",
+    "import/first": "error",
+    "import/newline-after-import": "error",
+    "import/no-duplicates": "error",
+    "import/no-unresolved": 'off',
+    "import/no-named-as-default-member": 'off',
+  }
+})
+
+const e2eRules = tseslint.config({
+  extends: [importRules],
+    ...playwright.configs['flat/recommended'],
+    files: ['e2e/**/*.spec.ts'],
+    rules: {
+      ...playwright.configs['flat/recommended'].rules,
+    },
+});
 
 export default tseslint.config(
   { ignores: ['dist', 'src/routeTree.gen.ts'] },
+  e2eRules,

Review Comment:
   [nitpick] Review the merge order of the e2eRules configuration with the main 
ESLint settings to ensure there are no unintended overrides. Clarifying the 
configuration merge could improve maintainability.
   ```suggestion
   export const e2eRulesConfig = e2eRules;
   
   export default tseslint.config(
     { ignores: ['dist', 'src/routeTree.gen.ts'] },
   ```



##########
.github/workflows/e2e.yml:
##########
@@ -0,0 +1,94 @@
+name: Frontend e2e test
+
+on:
+  push:
+    branches:
+      - "**"
+  pull_request:
+    types: [labeled, synchronize]
+    branches:
+        - "**"
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || 
github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  test:
+    if: ${{ contains(github.event.pull_request.labels.*.name, 'e2e-test') }}
+    timeout-minutes: 40
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Get PR Labels
+        id: get-labels
+        uses: actions/github-script@v6
+        with:
+          script: |
+            const labels = context.payload.pull_request.labels.map(label => 
label.name);
+            core.setOutput("labels", labels.join(","));
+      - name: Set image label as environment variable
+        run: |
+          export LABELS=${{ steps.get-labels.outputs.labels }}
+          echo "LABELS=${LABELS}" >> $GITHUB_ENV
+        shell: bash
+
+      # ensure this in 
https://github.com/apache/infrastructure-actions/blob/main/actions.yml
+      - uses: pnpm/action-setup@v4
+        name: Install pnpm
+        with:
+          run_install: false
+
+      - uses: actions/setup-node@v4
+        with:
+          node-version: "22"
+          cache: "pnpm"
+
+      - name: Install dependencies
+        run: |
+          pnpm install --frozen-lockfile
+
+      - name: Install Playwright Browsers
+        run: |
+          pnpm exec playwright install --with-deps
+
+      - name: Run e2e server
+        working-directory: ./e2e/server
+        run: |
+          docker compose up -d
+
+      - name: Waiting dashboard service to be healthy
+        working-directory: ./e2e/server
+        run: |
+          E2E_SERVER="dashboard-e2e"
+          TIMEOUT=30
+          timeout $TIMEOUT bash -c '
+            until [ "$(docker inspect --format="{{.State.Health.Status}}" 
$(docker compose ps -q '$E2E_SERVER'))" = "healthy" ]; do
+              echo "'$E2E_SERVER' is starting..."

Review Comment:
   The healthcheck command uses nested quoting that may be fragile; consider 
refactoring this script to improve readability and robustness.
   ```suggestion
               while true; do
                 STATUS=$(docker inspect --format="{{.State.Health.Status}}" 
$(docker compose ps -q '"$E2E_SERVER"'))
                 if [ "$STATUS" = "healthy" ]; then
                   break
                 fi
                 echo "$E2E_SERVER is starting..."
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to