feat!: consolidates admin.logoutRoute and admin.inactivityRoute into admin.routes (#6354)
This commit is contained in:
@@ -8,12 +8,18 @@ import { wait } from 'payload/utilities'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
import type { PayloadTestSDK } from '../helpers/sdk/index.js'
|
||||
import type { Config, ReadOnlyCollection, RestrictedVersion } from './payload-types.js'
|
||||
import type {
|
||||
Config,
|
||||
NonAdminUser,
|
||||
ReadOnlyCollection,
|
||||
RestrictedVersion,
|
||||
} from './payload-types.js'
|
||||
|
||||
import {
|
||||
closeNav,
|
||||
ensureAutoLoginAndCompilationIsDone,
|
||||
exactText,
|
||||
getAdminRoutes,
|
||||
initPageConsoleErrorCatch,
|
||||
login,
|
||||
openDocControls,
|
||||
@@ -58,6 +64,7 @@ describe('access control', () => {
|
||||
let restrictedVersionsUrl: AdminUrlUtil
|
||||
let serverURL: string
|
||||
let context: BrowserContext
|
||||
let logoutURL: string
|
||||
|
||||
beforeAll(async ({ browser }, testInfo) => {
|
||||
testInfo.setTimeout(TEST_TIMEOUT_LONG)
|
||||
@@ -75,6 +82,15 @@ describe('access control', () => {
|
||||
|
||||
await login({ page, serverURL })
|
||||
await ensureAutoLoginAndCompilationIsDone({ page, serverURL })
|
||||
|
||||
const {
|
||||
admin: {
|
||||
routes: { logout: logoutRoute },
|
||||
},
|
||||
routes: { admin: adminRoute },
|
||||
} = getAdminRoutes({})
|
||||
|
||||
logoutURL = `${serverURL}${adminRoute}${logoutRoute}`
|
||||
})
|
||||
|
||||
test('field without read access should not show', async () => {
|
||||
@@ -352,8 +368,8 @@ describe('access control', () => {
|
||||
|
||||
await expect(page.locator('.dashboard')).toBeVisible()
|
||||
|
||||
await page.goto(`${serverURL}/admin/logout`)
|
||||
await page.waitForURL(`${serverURL}/admin/logout`)
|
||||
await page.goto(logoutURL)
|
||||
await page.waitForURL(logoutURL)
|
||||
|
||||
await login({
|
||||
page,
|
||||
@@ -366,8 +382,8 @@ describe('access control', () => {
|
||||
|
||||
await expect(page.locator('.next-error-h1')).toBeVisible()
|
||||
|
||||
await page.goto(`${serverURL}/admin/logout`)
|
||||
await page.waitForURL(`${serverURL}/admin/logout`)
|
||||
await page.goto(logoutURL)
|
||||
await page.waitForURL(logoutURL)
|
||||
|
||||
// Log back in for the next test
|
||||
await login({
|
||||
@@ -387,10 +403,12 @@ describe('access control', () => {
|
||||
|
||||
await expect(page.locator('.dashboard')).toBeVisible()
|
||||
|
||||
await page.goto(`${serverURL}/admin/logout`)
|
||||
await page.waitForURL(`${serverURL}/admin/logout`)
|
||||
await page.goto(logoutURL)
|
||||
await page.waitForURL(logoutURL)
|
||||
|
||||
const nonAdminUser = await payload.login({
|
||||
const nonAdminUser: NonAdminUser & {
|
||||
token?: string
|
||||
} = await payload.login({
|
||||
collection: nonAdminUserSlug,
|
||||
data: {
|
||||
email: nonAdminUserEmail,
|
||||
@@ -398,7 +416,7 @@ describe('access control', () => {
|
||||
},
|
||||
})
|
||||
|
||||
context.addCookies([
|
||||
await context.addCookies([
|
||||
{
|
||||
name: 'payload-token',
|
||||
value: nonAdminUser.token,
|
||||
@@ -418,5 +436,5 @@ async function createDoc(data: any): Promise<TypeWithID & Record<string, unknown
|
||||
return payload.create({
|
||||
collection: slug,
|
||||
data,
|
||||
})
|
||||
}) as any as Promise<TypeWithID & Record<string, unknown>>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user