mirror of https://github.com/Squidex/squidex.git
Browse Source
* Daily test #1 * More tests * More tests * More tests * Retry tests. * Fix rename. * More tests * PII permission and frontend fixes. * Fix pager. * Fix tests * Make tests more stable. * Improve tests. * Improve tests. * Tests * Fix count update.pull/1128/head
committed by
GitHub
90 changed files with 1220 additions and 362 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,89 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|||
*/ |
|||
|
|||
import { expect, test } from '../_fixture'; |
|||
import { ClientsPage } from '../pages'; |
|||
import { getRandomId } from '../utils'; |
|||
|
|||
test.beforeEach(async ({ context, appsPage, clientsPage }) => { |
|||
await context.grantPermissions(['clipboard-read', 'clipboard-write']); |
|||
|
|||
const appName = `app-${getRandomId()}`; |
|||
await appsPage.createNewApp(appName); |
|||
|
|||
await clientsPage.goto(appName); |
|||
}); |
|||
|
|||
test('has header', async ({ page }) => { |
|||
const header = page.getByRole('heading', { name: /Clients/ }); |
|||
|
|||
await expect(header).toBeVisible(); |
|||
}); |
|||
|
|||
test('add client', async ({ clientsPage }) => { |
|||
const clientId = await createRandomClient(clientsPage); |
|||
const clientCard = await clientsPage.getClientCard(clientId); |
|||
|
|||
await expect(clientCard.root).toBeVisible(); |
|||
}); |
|||
|
|||
test('copy client ID', async ({ page, clientsPage }) => { |
|||
const clientCard = await clientsPage.getClientCard('default'); |
|||
await clientCard.copyClientId(); |
|||
|
|||
const handle = await page.evaluateHandle(() => navigator.clipboard.readText()); |
|||
const clipboardContent = await handle.jsonValue(); |
|||
|
|||
await expect(clipboardContent).toContain(':default'); |
|||
}); |
|||
|
|||
test('copy client Secret', async ({ page, clientsPage }) => { |
|||
const clientCard = await clientsPage.getClientCard('default'); |
|||
await clientCard.copyClientSecret(); |
|||
|
|||
const handle = await page.evaluateHandle(() => navigator.clipboard.readText()); |
|||
const clipboardContent = await handle.jsonValue(); |
|||
|
|||
await expect(clipboardContent.length).toBeGreaterThan(40); |
|||
}); |
|||
|
|||
test('rename rule with dbclick', async ({ clientsPage }) => { |
|||
const clientId = await createRandomClient(clientsPage); |
|||
const clientCard = await clientsPage.getClientCard(clientId); |
|||
|
|||
const newName = `client-${getRandomId()}`; |
|||
|
|||
const renameDialog = await clientCard.startRenameDblClick(); |
|||
await renameDialog.enterName(newName); |
|||
await renameDialog.save(); |
|||
const renamedCard = await clientsPage.getClientCard(newName); |
|||
|
|||
await expect(renamedCard.root).toBeVisible(); |
|||
}); |
|||
|
|||
test('rename rule with button', async ({ clientsPage }) => { |
|||
const clientId = await createRandomClient(clientsPage); |
|||
const clientCard = await clientsPage.getClientCard(clientId); |
|||
|
|||
const newName = `client-${getRandomId()}`; |
|||
|
|||
const renameDialog = await clientCard.startRenameButton(); |
|||
await renameDialog.enterName(newName); |
|||
await renameDialog.save(); |
|||
const renamedCard = await clientsPage.getClientCard(newName); |
|||
|
|||
await expect(renamedCard.root).toBeVisible(); |
|||
}); |
|||
|
|||
async function createRandomClient(clientsPage: ClientsPage) { |
|||
const clientId = `client-${getRandomId()}`; |
|||
|
|||
await clientsPage.enterClientId(clientId); |
|||
await clientsPage.save(); |
|||
|
|||
return clientId; |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|||
*/ |
|||
|
|||
import { expect, test } from '../_fixture'; |
|||
import { getRandomId } from '../utils'; |
|||
|
|||
test.beforeEach(async ({ appsPage, settingsPage }) => { |
|||
const appName = `app-${getRandomId()}`; |
|||
await appsPage.createNewApp(appName); |
|||
|
|||
await settingsPage.goto(appName); |
|||
}); |
|||
|
|||
test('has header', async ({ page }) => { |
|||
const header = page.getByRole('heading', { name: /UI Settings/ }); |
|||
|
|||
await expect(header).toBeVisible(); |
|||
}); |
|||
|
|||
test('add pattern', async ({ settingsPage })=> { |
|||
const patternName = `name-${getRandomId()}`; |
|||
const patternRegex = `regex-${getRandomId()}`; |
|||
|
|||
const newRow = await settingsPage.getPatternNewRow(); |
|||
await newRow.enterName(patternName); |
|||
await newRow.enterRegex(patternRegex); |
|||
await settingsPage.save(); |
|||
|
|||
const patternRow = await settingsPage.getPatternRow(patternName); |
|||
|
|||
await expect(patternRow.root).toBeVisible(); |
|||
}); |
|||
|
|||
test('delete pattern', async ({ settingsPage })=> { |
|||
const patternRow = await settingsPage.getPatternRow('Email'); |
|||
await patternRow.delete(); |
|||
await settingsPage.save(); |
|||
|
|||
await expect(patternRow.root).not.toBeVisible(); |
|||
}); |
|||
@ -0,0 +1,60 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|||
*/ |
|||
|
|||
import { Locator, Page } from '@playwright/test'; |
|||
import { escapeRegex } from '../utils'; |
|||
import { RenameDialog } from './rename'; |
|||
|
|||
export class ClientsPage { |
|||
constructor(private readonly page: Page) {} |
|||
|
|||
public async goto(appName: string) { |
|||
await this.page.goto(`/app/${appName}/settings/clients`); |
|||
} |
|||
|
|||
public async enterClientId(input: string) { |
|||
await this.page.getByPlaceholder('Enter client name').fill(input); |
|||
} |
|||
|
|||
public async save() { |
|||
await this.page.getByRole('button', { name: 'Add Client' }).click(); |
|||
} |
|||
|
|||
public async getClientCard(name: string) { |
|||
const locator = this.page.locator('sqx-client', { hasText: escapeRegex(name) }); |
|||
|
|||
return new ClientCard(this.page, locator); |
|||
} |
|||
} |
|||
|
|||
class ClientCard { |
|||
constructor(private readonly page: Page, |
|||
public readonly root: Locator, |
|||
) { |
|||
} |
|||
|
|||
public async copyClientId() { |
|||
await this.root.getByLabel('Copy Client ID').click(); |
|||
} |
|||
|
|||
public async copyClientSecret() { |
|||
await this.root.getByLabel('Copy Client Secret').click(); |
|||
} |
|||
|
|||
public async startRenameDblClick() { |
|||
await this.root.getByRole('heading').first().dblclick(); |
|||
|
|||
return new RenameDialog(this.page); |
|||
} |
|||
|
|||
public async startRenameButton() { |
|||
await this.root.getByRole('heading').hover(); |
|||
await this.root.getByLabel('Rename').click(); |
|||
|
|||
return new RenameDialog(this.page); |
|||
} |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|||
*/ |
|||
|
|||
import { Locator, Page } from '@playwright/test'; |
|||
import { escapeRegex } from '../utils'; |
|||
|
|||
export class LanguagesPage { |
|||
constructor(private readonly page: Page) {} |
|||
|
|||
public async goto(appName: string) { |
|||
await this.page.goto(`/app/${appName}/settings/languages`); |
|||
} |
|||
|
|||
public async enterLanguage(input: string) { |
|||
await this.page.locator('#language').fill(input); |
|||
} |
|||
|
|||
public async selectLanguage(selection: string) { |
|||
await this.page.getByText(selection).click(); |
|||
} |
|||
|
|||
public async save() { |
|||
await this.page.getByRole('button', { name: 'Add Language' }).click(); |
|||
} |
|||
|
|||
public async getLanguageCard(name: string) { |
|||
const locator = this.page.locator('sqx-language', { hasText: escapeRegex(name) }); |
|||
|
|||
return new LanguageCard(this.page, locator); |
|||
} |
|||
} |
|||
|
|||
export class LanguageCard { |
|||
constructor(private readonly page: Page, |
|||
public readonly root: Locator, |
|||
) { |
|||
} |
|||
|
|||
public async delete(button = /Yes/) { |
|||
await this.root.getByLabel('Delete').click(); |
|||
await this.page.getByRole('button', { name: button }).click(); |
|||
} |
|||
|
|||
public async toggle() { |
|||
await this.root.getByLabel('Options').click(); |
|||
} |
|||
|
|||
public async save() { |
|||
await this.root.getByRole('button', { name: 'Save' }).click(); |
|||
} |
|||
|
|||
public async makeMaster() { |
|||
await this.root.getByLabel('Is Master').check(); |
|||
} |
|||
|
|||
public async addFallbackLanguage(language: string) { |
|||
await this.root.getByLabel('Fallback').selectOption({ label: language }); |
|||
await this.root.getByRole('button', { name: 'Add Language' }).click(); |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|||
*/ |
|||
|
|||
import { Locator, Page } from '@playwright/test'; |
|||
|
|||
export class RenameDialog { |
|||
public root: Locator; |
|||
|
|||
constructor(private readonly page: Page) { |
|||
this.root = this.page.locator('sqx-editable-title'); |
|||
} |
|||
|
|||
public async enterName(name: string) { |
|||
await this.root.locator('form').getByRole('textbox').fill(name); |
|||
} |
|||
|
|||
public async save() { |
|||
await this.root.locator('form').getByLabel('Save').click(); |
|||
} |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|||
*/ |
|||
|
|||
import { Locator, Page } from '@playwright/test'; |
|||
|
|||
export class SettingsPage { |
|||
constructor(private readonly page: Page) {} |
|||
|
|||
public async goto(appName: string) { |
|||
await this.page.goto(`/app/${appName}/settings/settings`); |
|||
} |
|||
|
|||
public async save() { |
|||
await this.page.getByRole('button', { name: 'Save' }).click(); |
|||
} |
|||
|
|||
public async getPatternRow(name: string) { |
|||
const locator = this.page.getByTestId(`pattern_${name}`); |
|||
|
|||
return new PatternRow(this.page, locator); |
|||
} |
|||
|
|||
public async getPatternNewRow() { |
|||
const locator = this.page.getByTestId(/pattern_/).last(); |
|||
|
|||
return new PatternRow(this.page, locator); |
|||
} |
|||
|
|||
public async addPattern() { |
|||
await this.page.getByTestId('patterns').getByRole('button', { name: 'Add' }).click(); |
|||
} |
|||
} |
|||
|
|||
export class PatternRow { |
|||
constructor(private readonly page: Page, |
|||
public readonly root: Locator, |
|||
) { |
|||
} |
|||
|
|||
public async enterName(value: string) { |
|||
await this.root.getByPlaceholder('Name').fill(value); |
|||
} |
|||
|
|||
public async enterRegex(value: string) { |
|||
await this.root.getByPlaceholder('Pattern').fill(value); |
|||
} |
|||
|
|||
public async delete() { |
|||
await this.root.getByRole('button', { name: 'Delete' }).click(); |
|||
await this.page.getByRole('button', { name: 'Yes' }).click(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue