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
4 changes: 2 additions & 2 deletions front/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineConfig({
retries: process.env.CI ? 0 : 0, // Experimental settings, update it if necessary for the CI
workers: process.env.CI ? 1 : 1, // We put 1 worker even for dev mode to save computer resources
reporter: [['list', {printSteps: true}]],
timeout: 120000, // 2min per test
timeout: process.env.CI ? 180000 : 120000, // 2min per test in local, 3min in CI
use: {
baseURL: process.env.SERVER_BASE_URL || 'https://gally.local',
trace: 'on',
Expand All @@ -16,7 +16,7 @@ export default defineConfig({
permissions: ['clipboard-read', 'clipboard-write'],
},
expect: {
timeout: 20000, // 20s per expect
timeout: process.env.CI ? 30000 : 20000, // 20s per expect in local, 60 in CI
},
projects: [
{
Expand Down
4 changes: 4 additions & 0 deletions front/e2e/src/helper/gallyPackage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum GallyPackage {
STANDARD = 'standard',
PREMIUM = 'premium',
}
8 changes: 8 additions & 0 deletions front/e2e/src/helper/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,12 @@ export class Tabs {
useInnerText: true,
})
}

public async expectToHaveSomeTabs(tabs: string[]): Promise<void> {
const container = this.getTabsContainer()
const tabsLocator = container.getByTestId(this.tabTestId)
await expect(tabsLocator).toContainText(tabs, {
useInnerText: true,
})
}
}
105 changes: 63 additions & 42 deletions front/e2e/src/tests/pages/admin/settings/configurations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { expect, test } from '@playwright/test'
import { Page, expect, test } from '@playwright/test'
import { login } from '../../../../helper/auth'
import { navigateTo } from '../../../../helper/menu'
import { Dropdown } from '../../../../helper/dropdown'
import { Tabs } from '../../../../helper/tabs'
import { TestId, generateTestId } from '../../../../helper/testIds'
import { Switch } from '../../../../helper/switch'
import { GallyPackage } from '../../../../helper/gallyPackage'

const testIds = {
form: {
Expand Down Expand Up @@ -35,29 +36,41 @@ const texts = {
user: "Users",
},
configurationSubtabs: {
general: 'General',
index: 'Index',
search: 'Search',
boost: 'Boost',
thesaurus: 'Thesaurus',
vectorSearch: 'Vector Search',
explain: 'Explain',
[GallyPackage.STANDARD]: {
general: 'General',
index: 'Index',
search: 'Search',
},
[GallyPackage.PREMIUM]: {
general: 'General',
index: 'Index',
search: 'Search',
boost: 'Boost',
thesaurus: 'Thesaurus',
vectorSearch: 'Vector Search',
explain: 'Explain',
}
}
}

// Test configuration values for different scopes
const testValues = {
general: {
baseUrl: `https://example.com/media/catalog/product${Math.random()}`,
defaultSender: `contactgeneral${Math.random()}@example.com`,
},
catalog: {
baseUrl: `https://example.com/media/catalog/productcatalog${Math.random()}`,
defaultSender: `contactcatalog${Math.random()}@example.com`,
},
// Must be a function so when running premium and standard tests
// back to back, the values change between each test
function getTestValues(): Record<string, Record<string, string>> {
return {
general: {
baseUrl: `https://example.com/media/catalog/product${Math.random()}`,
defaultSender: `contactgeneral${Math.random()}@example.com`,
},
catalog: {
baseUrl: `https://example.com/media/catalog/productcatalog${Math.random()}`,
defaultSender: `contactcatalog${Math.random()}@example.com`,
},
}
}

test('Pages > Configuration > Configuration Form', { tag: ['@premium', '@standard'] }, async ({ page }) => {
async function testConfigurationsPage(page: Page, gallyPackage: GallyPackage): Promise<void> {
const testValues = getTestValues()
await test.step('Login and navigate to the configuration form page', async () => {
await login(page)
await navigateTo(
Expand Down Expand Up @@ -92,14 +105,12 @@ test('Pages > Configuration > Configuration Form', { tag: ['@premium', '@standar
await expect(page.getByTestId(testIds.fields.defaultSenderField)).not.toBeEmpty()
})


await test.step('Verify configuration subtabs are present', async () => {
// Expected subtabs based on the configuration groups
const expectedSubtabs = Object.values(texts.configurationSubtabs)

// Check presence of all subtabs
const expectedSubtabs = Object.values(texts.configurationSubtabs[gallyPackage])
// Check presence of subtabs
const configurationTabs = new Tabs(page,'configurationsGroups')
await configurationTabs.expectToHaveTabs(expectedSubtabs)
await configurationTabs.expectToHaveSomeTabs(expectedSubtabs)
})

await test.step('Update configuration values and save', async () => {
Expand Down Expand Up @@ -191,29 +202,39 @@ test('Pages > Configuration > Configuration Form', { tag: ['@premium', '@standar
await page.getByTestId(testIds.fields.defaultSenderField).fill(testValues.general.defaultSender)
})

await test.step('Navigate to Explain tab and test switch functionality', async () => {
// Navigate to the Explain subtab
const configurationTabs = new Tabs(page,'configurationsGroups')
await configurationTabs.navigateTo('Explain')
if (gallyPackage === GallyPackage.PREMIUM) {
await test.step('Navigate to Explain tab and test switch functionality', async () => {
// Navigate to the Explain subtab
const configurationTabs = new Tabs(page,'configurationsGroups')
await configurationTabs.navigateTo('Explain')

// Wait for the Explain tab content to load
await page.waitForTimeout(1000)
// Wait for the Explain tab content to load
await page.waitForTimeout(1000)

// Check for the presence of the boolean field for highlight collector fields
const highlightCollectorFieldsSwitch = new Switch(page, 'gally_explain.highlight_collector_fields')
await highlightCollectorFieldsSwitch.expectToBeVisible()
// Check for the presence of the boolean field for highlight collector fields
const highlightCollectorFieldsSwitch = new Switch(page, 'gally_explain.highlight_collector_fields')
await highlightCollectorFieldsSwitch.expectToBeVisible()

// Test the switch functionality
await highlightCollectorFieldsSwitch.expectToBeChecked()
// Test the switch functionality
await highlightCollectorFieldsSwitch.expectToBeChecked()

// Toggle the switch
await highlightCollectorFieldsSwitch.toggle()
// Toggle the switch
await highlightCollectorFieldsSwitch.toggle()

// Verify the state changed
await highlightCollectorFieldsSwitch.expectToBeChecked(false)
// Verify the state changed
await highlightCollectorFieldsSwitch.expectToBeChecked(false)

// Toggle back to original state
await highlightCollectorFieldsSwitch.toggle()
await highlightCollectorFieldsSwitch.expectToBeChecked(true)
})
// Toggle back to original state
await highlightCollectorFieldsSwitch.toggle()
await highlightCollectorFieldsSwitch.expectToBeChecked(true)
})
}
}

test('Pages > Configuration > Standard Configuration Form', { tag: ['@standard'] }, async ({ page }) => {
await testConfigurationsPage(page, GallyPackage.STANDARD)
})

test('Pages > Configuration > Premium Configuration Form', { tag: ['@premium'] }, async ({ page }) => {
await testConfigurationsPage(page, GallyPackage.PREMIUM)
})
Loading