Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- classic-test-app
- test-app
- ember-simple-auth
- playwright-tests

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
Expand Down Expand Up @@ -59,7 +60,7 @@ jobs:
- test:one ember-lts-5.4
- test:one ember-lts-5.8
- test:one ember-lts-5.12
- test:one ember-6.0
- test:one ember-lts-6.4
- test:one ember-default
- test:one ember-release
allow-failure: [false]
Expand Down Expand Up @@ -91,6 +92,41 @@ jobs:
run: pnpm run --filter ${{ matrix.workspace }} ${{ matrix.test-suite }}
continue-on-error: ${{ matrix.allow-failure }}

browser_tests:
name: Browser Tests
runs-on: ubuntu-latest
timeout-minutes: 10
container:
image: mcr.microsoft.com/playwright:v1.53.2-noble
options: --user 1001

strategy:
fail-fast: false
matrix:
ember-version:
- ember-lts-4.12
- ember-lts-5.4
- ember-lts-6.4
- ember-default
- ember-release

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: volta-cli/action@5c175f92dea6f48441c436471e6479dbc192e194 # v4
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-

- run: pnpm install
- name: test ${{ matrix.ember-version }}
env:
EMBER_SERVER_COMMAND: pnpm -F test-app test:one ${{ matrix.ember-version }} --- pnpm start
run: pnpm -F playwright-tests test:e2e:chromium


allow-fail-try-scenarios:
name: ${{ matrix.workspace }} ${{ matrix.test-suite }} - Allowed to fail
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions packages/playwright-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# Playwright
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
1 change: 1 addition & 0 deletions packages/playwright-tests/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '../../eslint.config.mjs';
33 changes: 33 additions & 0 deletions packages/playwright-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "playwright-tests",
"version": "1.0.0",
"description": "Ember-simple-auth e2e tests",
"license": "ISC",
"author": "",
"type": "commonjs",
"main": "index.js",
"scripts": {
"test:e2e": "PUBLIC_MSW_ENABLED=true playwright test",
"test:visual": "PUBLIC_MSW_ENABLED=true playwright test",
"lint": "prettier --check . && ESLINT_USE_FLAT_CONFIG=true eslint .",
"format": "prettier --write . && ESLINT_USE_FLAT_CONFIG=true eslint . --fix",
"test:e2e:firefox": "pnpm test:e2e --project=firefox",
"test:e2e:chromium": "pnpm test:e2e --project=chromium"
},
"devDependencies": {
"@eslint/js": "9.30.1",
"@playwright/test": "1.53.2",
"@types/node": "^24.9.2",
"@typescript-eslint/eslint-plugin": "8.35.1",
"@typescript-eslint/parser": "8.35.1",
"dotenv": "17.0.1",
"dotenv-expand": "12.0.3",
"eslint": "9.30.1",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-prettier": "5.5.4",
"msw": "2.10.5",
"playwright": "1.53.2",
"playwright-msw": "3.0.1",
"prettier": "3.6.2"
}
}
83 changes: 83 additions & 0 deletions packages/playwright-tests/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { defineConfig, devices } from '@playwright/test';

const TEST_COMMAND = process.env.EMBER_SERVER_COMMAND || 'pnpm -F test-app start';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
/* 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: 2,
/* 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://localhost:4200',

/* 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: TEST_COMMAND,
url: 'http://localhost:4200',
reuseExistingServer: true,
},
],
});
62 changes: 62 additions & 0 deletions packages/playwright-tests/tests/test-app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { test, expect, type Page } from '@playwright/test';

const confirmLoggedIn = async (page: Page) => {
await expect(page).toHaveURL('/');
await expect(page.getByTestId('greeting-text')).toHaveText('Signed in as Some person');
await expect(page.locator('[data-is-authenticated]')).toBeTruthy();
};

const loginWithPassword = async (page: Page) => {
await page.getByPlaceholder('Enter Login').fill('letme');
await page.getByPlaceholder('Enter Password').fill('in');
await page.locator('button[type="submit"]:has-text("Login")').click();
};

test.describe('TestApp', () => {
test('it renders and is available', async ({ page }) => {
await page.goto('/');

await expect(page.getByRole('heading')).toHaveText('Ember Simple Auth example app');
});

test('can log-in', async ({ page }) => {
await page.goto('/');

await page.getByTestId('route-login').click();
await expect(page).toHaveURL('/login#');

await loginWithPassword(page);
await confirmLoggedIn(page);
});

test('logged-in state is synchronized between tabs', async ({ page, context }) => {
await page.goto('/');

await page.getByTestId('route-login').click();
await expect(page).toHaveURL('/login#');

await loginWithPassword(page);
await confirmLoggedIn(page);

const anotherPage = await context.newPage();
await anotherPage.goto('/');
await confirmLoggedIn(anotherPage);
});

test('logged-in state is synchronized between tabs when another page is already opened', async ({
page,
context,
}) => {
await page.goto('/');

await page.getByTestId('route-login').click();
await expect(page).toHaveURL('/login#');

const anotherPage = await context.newPage();
await anotherPage.goto('/');

await loginWithPassword(page);
await confirmLoggedIn(page);
await confirmLoggedIn(anotherPage);
});
});
6 changes: 3 additions & 3 deletions packages/test-app/app/components/main-navigation.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
{{! display logout button when the session is authenticated, login button otherwise }}
{{#if this.session.isAuthenticated}}
{{#if this.sessionAccount.account}}
<span class="navbar-text mr-3">Signed in as
{{this.sessionAccount.account.name}}</span>
<span data-testid="greeting-text" class="navbar-text mr-3">Signed in as {{this.sessionAccount.account.name}}</span>
{{/if}}
<a
{{on "click" this.logout}}
Expand All @@ -43,7 +42,8 @@
class="btn btn-success"
href="#"
role="button"
data-testid="route-login"
>Login</a>
{{/if}}
</form>
</nav>
</nav>
6 changes: 3 additions & 3 deletions packages/test-esa/config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ module.exports = function () {
},
},
{
name: 'ember-6.0',
name: 'ember-lts-6.4',
npm: {
devDependencies: {
'ember-cli': '~6.0.0',
'ember-source': '~6.0.0',
'ember-cli': '~6.4.0',
'ember-source': '~6.4.0',
'ember-data': '~5.3.0',
},
},
Expand Down
Loading
Loading