Skip to content

Commit 1ca91d8

Browse files
committed
chore: add failing version view tests
1 parent 405c563 commit 1ca91d8

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

test/helpers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ export async function saveDocAndAssert(
191191
expectation: 'error' | 'success' = 'success',
192192
): Promise<void> {
193193
await wait(500) // TODO: Fix this
194+
if (selector === '#publish-locale') {
195+
// open dropdown
196+
const chevronButton = page.locator('.form-submit .popup__trigger-wrap > .popup-button')
197+
await chevronButton.click()
198+
}
194199
await page.click(selector, { delay: 100 })
195200

196201
if (expectation === 'success') {

test/localization/e2e.spec.ts

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { nestedToArrayAndBlockCollectionSlug } from './collections/NestedToArray
3535
import { noLocalizedFieldsCollectionSlug } from './collections/NoLocalizedFields/index.js'
3636
import { richTextSlug } from './collections/RichText/index.js'
3737
import {
38+
allFieldsLocalizedSlug,
3839
arrayWithFallbackCollectionSlug,
3940
defaultLocale,
4041
englishTitle,
@@ -68,6 +69,7 @@ let urlArray: AdminUrlUtil
6869
let arrayWithFallbackURL: AdminUrlUtil
6970
let noLocalizedFieldsURL: AdminUrlUtil
7071
let urlBlocks: AdminUrlUtil
72+
let urlAllFieldsLocalized: AdminUrlUtil
7173

7274
const title = 'english title'
7375
const spanishTitle = 'spanish title'
@@ -96,6 +98,7 @@ describe('Localization', () => {
9698
arrayWithFallbackURL = new AdminUrlUtil(serverURL, arrayWithFallbackCollectionSlug)
9799
noLocalizedFieldsURL = new AdminUrlUtil(serverURL, noLocalizedFieldsCollectionSlug)
98100
urlBlocks = new AdminUrlUtil(serverURL, blocksCollectionSlug)
101+
urlAllFieldsLocalized = new AdminUrlUtil(serverURL, allFieldsLocalizedSlug)
99102

100103
context = await browser.newContext()
101104
page = await context.newPage()
@@ -712,8 +715,6 @@ describe('Localization', () => {
712715
await page.goto(urlPostsWithDrafts.create)
713716
await changeLocale(page, 'es')
714717
await fillValues({ title: 'Created In Spanish' })
715-
const chevronButton = page.locator('.form-submit .popup__trigger-wrap > .popup-button')
716-
await chevronButton.click()
717718
await saveDocAndAssert(page, '#publish-locale')
718719

719720
await expect(page.locator('#field-title')).toHaveValue('Created In Spanish')
@@ -775,6 +776,47 @@ describe('Localization', () => {
775776
await expect(page.locator('#field-title')).toHaveValue('Portuguese Title')
776777
})
777778
})
779+
780+
describe('localize status', () => {
781+
describe('versions list', () => {
782+
test('should show currently published doc in version list', async () => {
783+
await changeLocale(page, defaultLocale)
784+
await page.goto(urlAllFieldsLocalized.create)
785+
786+
await page.locator('#field-text').fill('EN Draft')
787+
await saveDocAndAssert(page, '#action-save-draft')
788+
await page.locator('#field-text').fill('EN Published')
789+
await saveDocAndAssert(page, '#publish-locale')
790+
791+
const versionsURL = page.url() + '/versions'
792+
await page.goto(versionsURL)
793+
794+
const firstRow = page.locator('tbody tr').first()
795+
await expect(firstRow.locator('.pill__label span')).toHaveText('Currently Published')
796+
})
797+
798+
test('should only show published status when viewing the published locale', async () => {
799+
await changeLocale(page, defaultLocale)
800+
await page.goto(urlAllFieldsLocalized.create)
801+
802+
await page.locator('#field-text').fill('EN Published')
803+
await saveDocAndAssert(page, '#publish-locale')
804+
await page.locator('#field-text').fill('EN Draft')
805+
await saveDocAndAssert(page, '#action-save-draft')
806+
807+
await changeLocale(page, spanishLocale)
808+
await page.locator('#field-text').fill('ES Published')
809+
await saveDocAndAssert(page, '#publish-locale')
810+
811+
const versionsURL = page.url().replace(/\?locale=[^&]*/, '/versions')
812+
await page.goto(versionsURL)
813+
await changeLocale(page, defaultLocale)
814+
815+
const firstRow = page.locator('tbody tr').first()
816+
await expect(firstRow.locator('.pill__label span')).toHaveText('Draft')
817+
})
818+
})
819+
})
778820
})
779821

780822
async function createLocalizedArrayItem(page: Page, url: AdminUrlUtil) {

test/versions/e2e.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,8 +1138,6 @@ describe('Versions', () => {
11381138

11391139
await changeLocale(page, 'en')
11401140
await textField.fill('english published')
1141-
const publishOptions = page.locator('.doc-controls__controls .popup')
1142-
await publishOptions.click()
11431141

11441142
const publishSpecificLocale = page.locator('#publish-locale')
11451143
await expect(publishSpecificLocale).toContainText('English')

0 commit comments

Comments
 (0)