test: fix bad file ref and update locators
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import type { Page } from '@playwright/test';
|
import type { Page } from '@playwright/test';
|
||||||
import { expect, test } from '@playwright/test';
|
import { expect, test } from '@playwright/test';
|
||||||
import { AdminUrlUtil } from '../../helpers/adminUrlUtil';
|
import { AdminUrlUtil } from '../../helpers/adminUrlUtil';
|
||||||
import { initPayloadTest } from '../../helpers/configHelpers';
|
import { initPayloadE2E } from '../../helpers/configHelpers';
|
||||||
import { login } from '../helpers';
|
import { login } from '../helpers';
|
||||||
import { textDoc } from './shared';
|
import { textDoc } from './collections/Text';
|
||||||
|
|
||||||
const { beforeAll, describe } = test;
|
const { beforeAll, describe } = test;
|
||||||
|
|
||||||
@@ -12,13 +12,7 @@ let url: AdminUrlUtil;
|
|||||||
|
|
||||||
describe('fields', () => {
|
describe('fields', () => {
|
||||||
beforeAll(async ({ browser }) => {
|
beforeAll(async ({ browser }) => {
|
||||||
const { serverURL } = await initPayloadTest({
|
const { serverURL } = await initPayloadE2E(__dirname);
|
||||||
__dirname,
|
|
||||||
init: {
|
|
||||||
local: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
url = new AdminUrlUtil(serverURL, 'text-fields');
|
url = new AdminUrlUtil(serverURL, 'text-fields');
|
||||||
|
|
||||||
const context = await browser.newContext();
|
const context = await browser.newContext();
|
||||||
@@ -30,7 +24,7 @@ describe('fields', () => {
|
|||||||
describe('text', () => {
|
describe('text', () => {
|
||||||
test('should display field in list view', async () => {
|
test('should display field in list view', async () => {
|
||||||
await page.goto(url.list);
|
await page.goto(url.list);
|
||||||
const textCell = await page.locator('table tr:first-child td:first-child a');
|
const textCell = page.locator('table tr:first-child td:first-child a');
|
||||||
await expect(textCell).toHaveText(textDoc.text);
|
await expect(textCell).toHaveText(textDoc.text);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -66,16 +66,16 @@ describe('Localization', () => {
|
|||||||
await changeLocale('es');
|
await changeLocale('es');
|
||||||
|
|
||||||
// Localized field should not be populated
|
// Localized field should not be populated
|
||||||
await expect(page.locator('#title')).toBeEmpty();
|
await expect(page.locator('#field-title')).toBeEmpty();
|
||||||
await expect(page.locator('#description')).toHaveValue(description);
|
await expect(page.locator('#field-description')).toHaveValue(description);
|
||||||
|
|
||||||
await fillValues({ title: spanishTitle, description });
|
await fillValues({ title: spanishTitle, description });
|
||||||
await saveDocAndAssert(page);
|
await saveDocAndAssert(page);
|
||||||
await changeLocale(defaultLocale);
|
await changeLocale(defaultLocale);
|
||||||
|
|
||||||
// Expect english title
|
// Expect english title
|
||||||
await expect(page.locator('#title')).toHaveValue(title);
|
await expect(page.locator('#field-title')).toHaveValue(title);
|
||||||
await expect(page.locator('#description')).toHaveValue(description);
|
await expect(page.locator('#field-description')).toHaveValue(description);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('create spanish post, add english', async () => {
|
test('create spanish post, add english', async () => {
|
||||||
@@ -93,8 +93,8 @@ describe('Localization', () => {
|
|||||||
await changeLocale(defaultLocale);
|
await changeLocale(defaultLocale);
|
||||||
|
|
||||||
// Localized field should not be populated
|
// Localized field should not be populated
|
||||||
await expect(page.locator('#title')).toBeEmpty();
|
await expect(page.locator('#field-title')).toBeEmpty();
|
||||||
await expect(page.locator('#description')).toHaveValue(description);
|
await expect(page.locator('#field-description')).toHaveValue(description);
|
||||||
|
|
||||||
// Add English
|
// Add English
|
||||||
|
|
||||||
@@ -102,8 +102,8 @@ describe('Localization', () => {
|
|||||||
await saveDocAndAssert(page);
|
await saveDocAndAssert(page);
|
||||||
await saveDocAndAssert(page);
|
await saveDocAndAssert(page);
|
||||||
|
|
||||||
await expect(page.locator('#title')).toHaveValue(title);
|
await expect(page.locator('#field-title')).toHaveValue(title);
|
||||||
await expect(page.locator('#description')).toHaveValue(description);
|
await expect(page.locator('#field-description')).toHaveValue(description);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -119,8 +119,8 @@ async function clearDocs(): Promise<void> {
|
|||||||
async function fillValues(data: Partial<Omit<LocalizedPost, keyof TypeWithTimestamps>>) {
|
async function fillValues(data: Partial<Omit<LocalizedPost, keyof TypeWithTimestamps>>) {
|
||||||
const { title: titleVal, description: descVal } = data;
|
const { title: titleVal, description: descVal } = data;
|
||||||
|
|
||||||
if (titleVal) await page.locator('#title').fill(titleVal);
|
if (titleVal) await page.locator('#field-title').fill(titleVal);
|
||||||
if (descVal) await page.locator('#description').fill(descVal);
|
if (descVal) await page.locator('#field-description').fill(descVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeLocale(newLocale: string) {
|
async function changeLocale(newLocale: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user