Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 7 additions & 12 deletions cms-ui/apps/admin-ui/e2e/api-tokens.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import {
TestSize,
UserImportData,
} from '@gentics/e2e-utils';
import { expect, Page, test } from '@playwright/test';
import { expect, Locator, Page, test } from '@playwright/test';
import { cloneWithSymbols } from '@gentics/common';
import { AccessControlledType, GcmsPermission, LoginResponse } from '@gentics/cms-models';
import { setGtxDateFromXpath } from './helpers';

const API_MODAL = 'gtx-api-tokens-modal';
const API_CREATE_MODAL = 'gtx-api-tokens-create-modal';
Expand Down Expand Up @@ -120,29 +121,23 @@ test.describe('Api Tokens', () => {

await expect(submitBtn.locator('button')).toBeEnabled();

const dateInput = form.locator('input[type="date"]');
const dateInput = form.locator('gtx-date-time-picker');

// fill with date from yesterday
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);

await dateInput.fill(yesterday.toISOString().split('T')[0]);
await setGtxDateFromXpath(page, dateInput, 'xpath=preceding-sibling::td[1]');

await expect(submitBtn.locator('button')).toBeDisabled();

// fill with date from tomorrow
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);

await dateInput.fill(tomorrow.toISOString().split('T')[0]);
await setGtxDateFromXpath(page, dateInput, 'xpath=following-sibling::td[2]');

await expect(submitBtn.locator('button')).toBeEnabled();

await submitBtn.click();

await expect(page.locator('.success-message')).toBeVisible();
await expect(page.locator('gtx-api-copy-token-modal')).toBeVisible();
await expect(findNotification(page, 'api-token-create-success')).toBeVisible();
await expect(page.locator('.success-message').locator('.content')).toHaveText(/\S+/);
await expect(page.locator('gtx-api-copy-token-modal').locator('.content')).toHaveText(/\S+/);
});

test('can delete Api Tokens', async ({ page }) => {
Expand Down
8 changes: 7 additions & 1 deletion cms-ui/apps/admin-ui/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function navigateToModule(page: Page, moduleId: string): Promise<Lo
* Logs out from the mesh management interface
*/
export async function logoutMeshManagement(page: Page): Promise<void> {
const req = page.waitForResponse(response =>
const req = page.waitForResponse((response) =>
response.ok() && matchesPath(response.url(), '/rest/contentrepositories/*/proxy/api/v2/auth/logout'),
);
await page.locator('.management-container .logout-button').click();
Expand All @@ -42,3 +42,9 @@ export async function loginWithCR(page: Page, shouldBeLoggedIn: boolean = true):
export function findEntityTableActionButton(source: Page | Locator, action: string): Locator {
return source.locator(`.entity-table-actions-bar .table-action-button[data-action="${action}"] button`);
}

export async function setGtxDateFromXpath(page: Page, dateInput: Locator, xPath: string): Promise<void> {
await dateInput.click();
await page.locator('gtx-date-time-picker-modal').locator('td.rd-day-selected').locator(xPath).click();
await page.locator('gtx-date-time-picker-modal').locator('[data-action="confirm"] button').click();
}
Loading