Skip to content

Commit acb785a

Browse files
Merge remote-tracking branch 'origin/2.1.x'
# Conflicts: # .github/workflows/tests.yml # Makefile # compose.ci.yml # compose.e2e.yml # compose.override.yml # front/e2e/package.json # front/e2e/playwright.config.ts
2 parents 88e068c + dfd1775 commit acb785a

File tree

11 files changed

+571
-3
lines changed

11 files changed

+571
-3
lines changed

.github/workflows/deploy-demo-sylius.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: ./.github/workflows/tests.yml
1717
with:
1818
version: ${{ github.ref_name }}
19-
last_published_version: 2.0.0
19+
last_published_version: 2.1.0
2020
secrets: inherit
2121

2222
deploy-demo-sylius:
@@ -28,7 +28,7 @@ jobs:
2828
uses: ./.github/workflows/deploy-int.yml
2929
with:
3030
version: ${{ github.ref_name }}
31-
last_published_version: 2.0.0
31+
last_published_version: 2.1.0
3232
secrets:
3333
AWS_DEPLOY_KEY: ${{ secrets.AWS_DEPLOY_KEY }}
3434
AWS_HOSTNAME: ${{ secrets.AWS_HOSTNAME_DEMO_SYLIUS }}

front/e2e/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {defineConfig, devices} from '@playwright/test'
1+
import { defineConfig, devices } from '@playwright/test'
22

33
export default defineConfig({
44
testDir: './src/tests',
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { test, expect } from '@playwright/test'
2+
import { randomUUID } from 'crypto'
3+
import { login } from '../helper/auth'
4+
import { navigateTo } from '../helper/menu'
5+
import { Dropdown } from '../helper/dropdown'
6+
7+
test('Boosts', async ({ page }) => {
8+
await login(page)
9+
await navigateTo(page, 'Boosts', '/fr/admin/merchandize/boost/grid')
10+
11+
const createButton = await page.getByTestId('createButtonResourceGrid')
12+
13+
/*
14+
Grid Boost
15+
*/
16+
// TO DO
17+
18+
/*
19+
Create Boost
20+
*/
21+
await createButton.click()
22+
await expect(page).toHaveURL('/fr/admin/merchandize/boost/create')
23+
24+
// isActive Switch
25+
const isActiveInput = await page.getByTestId('isActive')
26+
const isActiveCheckbox = await isActiveInput.locator("input[type='checkbox']")
27+
28+
await expect(isActiveCheckbox).toBeChecked()
29+
await isActiveInput.click()
30+
await expect(isActiveCheckbox).not.toBeChecked()
31+
await isActiveInput.click()
32+
await expect(isActiveCheckbox).toBeChecked()
33+
34+
// Boost Preview
35+
const previewFieldSet = await page.getByTestId('previewFieldSet')
36+
await expect(
37+
await previewFieldSet.getByTestId('previewRequiredMessage')
38+
).toBeVisible()
39+
40+
// name InputText
41+
const nameInput = await page.getByTestId('name')
42+
const newName = randomUUID()
43+
44+
await expect(nameInput).toBeEmpty()
45+
await nameInput.fill(newName)
46+
await expect(nameInput).toHaveValue(newName)
47+
48+
// // Localized Catalogs Multiple Dropdown
49+
const localizedCatalogs = new Dropdown(page, 'localizedCatalogs', true)
50+
await localizedCatalogs.selectValue([
51+
'COM French Catalog',
52+
'COM English Catalog',
53+
'FR French Catalog',
54+
'EN French Catalog',
55+
])
56+
57+
// Request types Multiple Dropdown
58+
const requestTypesDropdown = new Dropdown(page, 'requestTypesDropdown', true)
59+
await requestTypesDropdown.selectValue(['Category listing', 'Search result'])
60+
61+
// Model Dropdown
62+
const modelDropdown = new Dropdown(page, 'model')
63+
await modelDropdown.selectValue('Constante')
64+
65+
// Preview Boost Required Message
66+
await expect(
67+
await previewFieldSet.getByTestId('previewRequiredMessage')
68+
).not.toBeVisible()
69+
70+
// Create the Boost and verify his existence
71+
const saveButton = await page.getByTestId('submitButtonResourceForm')
72+
await saveButton.click()
73+
await expect(page).toHaveURL('/fr/admin/merchandize/boost/grid')
74+
await expect(await page.getByText(newName)).toBeDefined() // TO DO : Manipulate the grid instead of research in the page.
75+
76+
/*
77+
Edit Boost
78+
*/
79+
// TO DO
80+
81+
/*
82+
Delete Boost
83+
*/
84+
// TO DO
85+
})
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { test, expect } from '@playwright/test'
2+
import { login } from '../helper/auth'
3+
4+
test('Header', async ({ page }) => {
5+
await login(page)
6+
7+
const appBar = await page.getByTestId('appBar')
8+
const breadcrumbs = await appBar.getByTestId('breadcrumbs')
9+
const tooltip = await appBar.getByTestId('helpToolTip')
10+
const tooltipOver = await tooltip.getByTestId('helpOver')
11+
const userMenu = await appBar.getByTestId('userMenu')
12+
13+
// Global Tests
14+
await expect(breadcrumbs).toBeVisible()
15+
await expect(tooltip).toBeVisible()
16+
await expect(tooltipOver).not.toBeVisible()
17+
await expect(userMenu).toBeVisible()
18+
19+
// ToolTip tests
20+
await tooltip.hover()
21+
await expect(tooltipOver).toBeVisible()
22+
23+
// UserMenu tests
24+
const username = await userMenu.getByTestId('username')
25+
const email = await userMenu.getByTestId('userEmail')
26+
const logOutButton = await userMenu.getByTestId('logOutButton')
27+
28+
await expect(username).toBeVisible()
29+
await expect(await username.innerText()).toBe('Admin@example.com')
30+
await expect(email).not.toBeVisible()
31+
await expect(logOutButton).not.toBeVisible()
32+
33+
await userMenu.click()
34+
35+
await expect(email).toBeVisible()
36+
await expect(logOutButton).toBeVisible()
37+
await expect(await email.innerText()).toBe('Admin@example.com')
38+
39+
await logOutButton.click()
40+
41+
await expect(page).toHaveURL(
42+
`${process.env.SERVER_BASE_URL || 'https://gally.local'}/fr/login`
43+
)
44+
await login(page)
45+
})
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { test, expect } from '@playwright/test'
2+
import { login } from '../helper/auth'
3+
4+
test('Menu', async ({ page }) => {
5+
await login(page)
6+
7+
const sidebar = await page.getByTestId('sidebarMenu')
8+
const collapseButton = await page.getByTestId('sidebarMenuCollapseButton')
9+
10+
const labelMenuItemIconList = await await page
11+
.getByTestId('labelMenuItemIcon')
12+
.all()
13+
const menuItemChildrenButtonList = await page
14+
.getByTestId('menuItemChildrenButton')
15+
.all()
16+
const menuItemChildrenList = await (
17+
await page.getByTestId('menuItemChildren')
18+
).all()
19+
const labelMenuLinkItemList = await (
20+
await page.getByTestId('labelMenuLinkItem')
21+
).all()
22+
23+
for (const locator of menuItemChildrenList) {
24+
await expect(locator).not.toBeVisible()
25+
}
26+
27+
for (const locator of menuItemChildrenButtonList) {
28+
await locator.click()
29+
}
30+
31+
for (const locator of [...labelMenuLinkItemList, ...labelMenuItemIconList]) {
32+
await expect(locator).toBeVisible()
33+
}
34+
35+
const defaultSideBarWidth = (await sidebar.boundingBox())?.width
36+
37+
await expect(defaultSideBarWidth).not.toBe(undefined)
38+
39+
await collapseButton.click()
40+
41+
// Wait for menu transition to end
42+
await page.evaluate(() => {
43+
return new Promise<void>((resolve) => {
44+
const element = document.querySelector('[data-testid="sidebarMenu"]')
45+
46+
element?.addEventListener('animationend', () => resolve(), {
47+
once: true,
48+
})
49+
})
50+
})
51+
52+
await expect((await sidebar.boundingBox())?.width).toBeLessThan(
53+
defaultSideBarWidth as number
54+
)
55+
56+
for (const locator of [...labelMenuLinkItemList, ...labelMenuItemIconList]) {
57+
await expect(locator).not.toBeVisible()
58+
}
59+
60+
await collapseButton.click()
61+
62+
await expect((await sidebar.boundingBox())?.width).toBe(defaultSideBarWidth)
63+
64+
for (const locator of [...labelMenuLinkItemList, ...labelMenuItemIconList]) {
65+
await expect(locator).toBeVisible()
66+
}
67+
68+
for (const locator of menuItemChildrenButtonList) {
69+
await locator.click()
70+
}
71+
72+
for (const locator of menuItemChildrenList) {
73+
await expect(locator).not.toBeVisible()
74+
}
75+
})
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { test, expect } from '@playwright/test'
2+
import { login } from '../helper/auth'
3+
4+
const authentificationURL = `${process.env.API_SERVER_BASE_URL || "https://gally.local"}/authentication_token`
5+
6+
test('Login page', async ({ page }) => {
7+
await page.goto('/fr/login')
8+
9+
// Get inputs and submit button
10+
const emailInput = await page.getByTestId('emailInput')
11+
const passwordInput = await page.getByTestId('passwordInput')
12+
const submitButton = await page.getByTestId('submitButton')
13+
14+
// Check validation messages for empty fields
15+
16+
await submitButton.click()
17+
let emailErrorElement = await page.getByTestId('emailInputErrorMessage')
18+
const passwordErrorElement = await page.getByTestId(
19+
'passwordInputErrorMessage'
20+
)
21+
await expect(emailErrorElement).toHaveText('La valeur est requise')
22+
await expect(passwordErrorElement).toHaveText('La valeur est requise')
23+
await expect(page).toHaveURL('/fr/login')
24+
25+
// Check validation messages for empty fields
26+
27+
await emailInput.fill('admin@')
28+
await submitButton.click()
29+
emailErrorElement = await page.getByTestId('emailInputErrorMessage')
30+
await expect(emailErrorElement).toHaveText("Le format de l'adresse e-mail est invalide.")
31+
32+
// Check validation message when log in with incorrect credentials
33+
34+
await emailInput.fill('admin@example.com')
35+
await passwordInput.fill('WrongPassword')
36+
await submitButton.click()
37+
38+
// TODO: Remplacer analyse de la requette par la détection d'un toast d'erreur
39+
const unsuccessResponse = await (
40+
await page.waitForResponse(
41+
(response) =>
42+
response.url() === authentificationURL && response.status() === 401
43+
)
44+
).json()
45+
46+
await expect(unsuccessResponse).toEqual({
47+
code: 401,
48+
message: 'Identifiants invalides.',
49+
})
50+
51+
// Check that there is a redirection when there is correct login credentials
52+
await login(page)
53+
})

front/e2e/tests/helper/auth.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Page, expect } from '@playwright/test'
2+
3+
export async function login(page: Page) {
4+
await page.goto('/fr/login')
5+
6+
// Get inputs and submit button
7+
const emailInput = await page.getByTestId('emailInput')
8+
const passwordInput = await page.getByTestId('passwordInput')
9+
const submitButton = await page.getByTestId('submitButton')
10+
11+
// Fill with correct credentials and submit the form
12+
await emailInput.fill('admin@example.com')
13+
await passwordInput.fill('apassword')
14+
await submitButton.click()
15+
16+
await expect(page).toHaveURL('/fr/admin/settings/scope/catalogs', {})
17+
}

0 commit comments

Comments
 (0)