Skip to content

Commit

Permalink
Merge branch 'release/v3.17.5' of ssh://github.com/g-research/fasttra…
Browse files Browse the repository at this point in the history
…ckml-ui-aim into release/v3.17.5
  • Loading branch information
suprjinx committed Jun 21, 2024
2 parents f64c6aa + b430d0e commit 23edf39
Show file tree
Hide file tree
Showing 39 changed files with 1,047 additions and 101 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Playwright Tests

on:
push:
branches: [ main, release/* ]
pull_request:
branches: [ main, release/* ]

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 16

- name: Install frontend dependencies
run: cd src && npm ci --legacy-peer-deps

- name: Install wait-on
run: npm install -g wait-on

- name: Install Playwright browsers
run: npx playwright install --with-deps

- name: Build and run backend
run: |
docker run --rm -p 5000:5000 -e FML_DEV_MODE=true gresearch/fasttrackml:main &
npx wait-on http://localhost:5000
- name: Install k6
run: |
sudo apt-get update
sudo apt-get install -y gnupg software-properties-common ca-certificates curl
curl -s https://dl.k6.io/key.gpg | sudo apt-key add -
echo "deb https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install -y k6
- name: Seed database with k6
run: |
wget https://raw.githubusercontent.com/G-Research/fasttrackml/main/docs/example/k6_load.js
k6 run k6_load.js
- name: Start frontend dev server and run E2E tests
run: |
cd src
npm start &
npx wait-on http://localhost:3000
npx playwright test src/e2e
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ An embed directory will be created with the built UI, ready to be embedded in th

Once you're happy with them, create a pull request **against the `release/vX.Y.Z` branch*** that you started from (***not `main`!***). Once merged, the CI will run and build the UI. It will then push it to a new tag that is compatible with the Go module rules. For example, the first customization to `v3.16.2` of Aim will end up in a tag named `v0.31602.1`.

### How to run E2E tests?

The E2E tests can be run locally by following these steps:
1. Start the FastTrackML server
2. Run the Aim UI in development mode (on localhost:3000)
3. In another terminal, run `cd src/e2e`
4. Run `npx playwright test` to run the test suite

New tests can be added directly to the `src/e2e` directory. You may also run `npx playwright show-report` to see the test results.

For a guide on how to write a test, see [Playwright's example tests](https://github.com/microsoft/playwright/blob/main/examples/todomvc/tests/integration.spec.ts).

### How is this all enforced?

A GitHub app has been created with the `contents:write` permissions on this repo. Its App ID and private key are stored as secrets under the `restricted` environment. This environment is limited to the `main` and `release/v*` branches
Expand Down Expand Up @@ -245,3 +257,4 @@ do
gh api /repos/G-Research/fasttrackml-ui-aim/rulesets/$rule | jq '[{name: .name, target: .target, conditions: .conditions, rules: .rules, bypass_actors: .bypass_actors}]'
done | jq -s add
```

4 changes: 4 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ yarn-debug.log*
yarn-error.log*

Desktop
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
19 changes: 19 additions & 0 deletions src/e2e/Dashboard/DashboardContent.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { test, expect } from '@playwright/test';

const BASE_URL = 'http://localhost:3000';

test.describe('Dashboard', () => {
test.beforeEach(async ({ page }) => {
await page.goto(BASE_URL);
await page.waitForLoadState('networkidle');
});

// Test that the total number of runs is two. This assumes that the
// test database has been seeded with two runs by running `k6 run k6_load.js`
test('has two runs', async ({ page }) => {
const textContent = await page.textContent(
'p.ProjectStatistics__totalRuns',
);
expect(textContent).toBe('Total runs: 2');
});
});
35 changes: 35 additions & 0 deletions src/e2e/Dashboard/DashboardLogic.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { test, expect } from '@playwright/test';

const BASE_URL = 'http://localhost:3000';

test.describe('Dashboard', () => {
test.beforeEach(async ({ page }) => {
await page.goto(BASE_URL);
});

test('has title', async ({ page }) => {
await expect(page).toHaveTitle('FastTrackML (modern)');
});

test('active runs link redirects correctly', async ({ page }) => {
await page.getByText('Active Runs').click({ force: true });

await page.getByRole('code', { name: 'runs.active == True' });
});

test('archived runs link redirects correctly', async ({ page }) => {
await page.getByText('Archived Runs').click({ force: true });

await page.getByRole('code', { name: 'runs.active == False' });
});

test("last week's runs link redirects correctly", async ({ page }) => {
await page.getByText("Last Week's Runs").click({ force: true });

// The text varies depending on the current date:
// Example: datetime(2024, 6, 3) <= run.created_at < datetime(2024, 6, 10)
await page.getByRole('code', {
name: /datetime\(\d+, \d+, \d+\) <= run\.created_at < datetime\(\d+, \d+, \d+\)/,
});
});
});
68 changes: 68 additions & 0 deletions src/package-lock.json

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

2 changes: 2 additions & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"memoize-one": "^5.2.1",
"moment": "^2.29.4",
"monaco-editor": "^0.33.0",
"playwright": "^1.44.1",
"plotly.js": "^2.7.0",
"prop-types": "^15.7.2",
"prosemirror-tables": "^1.1.1",
Expand Down Expand Up @@ -107,6 +108,7 @@
]
},
"devDependencies": {
"@playwright/test": "^1.44.1",
"@storybook/addon-actions": "^6.5.12",
"@storybook/addon-essentials": "^6.5.12",
"@storybook/addon-interactions": "^6.5.12",
Expand Down
77 changes: 77 additions & 0 deletions src/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
3 changes: 3 additions & 0 deletions src/src/components/Grouping/Grouping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import './Grouping.scss';
function Grouping({
groupingData,
groupingSelectOptions,
conditionalGroupingOptions,
onGroupingSelectChange,
onGroupingModeChange,
onGroupingPaletteChange,
Expand Down Expand Up @@ -46,6 +47,7 @@ function Grouping({
groupName={groupName as GroupNameEnum}
groupingData={groupingData}
groupingSelectOptions={groupingSelectOptions}
conditionalGroupingOptions={conditionalGroupingOptions}
onSelect={onGroupingSelectChange}
onGroupingModeChange={onGroupingModeChange}
isDisabled={isDisabled}
Expand All @@ -65,6 +67,7 @@ function Grouping({
paletteIndex: groupingData?.paletteIndex,
})}
groupingSelectOptions={groupingSelectOptions}
conditionalGroupingOptions={conditionalGroupingOptions}
onSelect={onGroupingSelectChange}
onGroupingConditionsChange={onGroupingConditionsChange}
/>
Expand Down
Loading

0 comments on commit 23edf39

Please sign in to comment.