Skip to content

Commit 01d40ab

Browse files
committed
chore: Fix multitenant test
1 parent 7aadc5a commit 01d40ab

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
import { createTest, type TestConfig } from 'e2e-shared/create-test'
2-
import { getShallowUrl } from 'e2e-shared/specs/shallow.defs'
2+
import { getOptionsUrl } from 'e2e-shared/lib/options'
33

4-
function testMultiTenant(options: TestConfig) {
4+
function testMultiTenant(
5+
options: TestConfig & {
6+
expectedPathname: string
7+
}
8+
) {
59
const factory = createTest('Multitenant', ({ path }) => {
610
for (const shallow of [true, false]) {
711
for (const history of ['replace', 'push'] as const) {
812
it(`Updates with ({ shallow: ${shallow}, history: ${history} })`, () => {
9-
cy.visit(getShallowUrl(path, { shallow, history }))
13+
cy.visit(getOptionsUrl(path, { shallow, history }))
1014
cy.contains('#hydration-marker', 'hydrated').should('be.hidden')
1115
cy.get('#client-state').should('be.empty')
1216
cy.get('#server-state').should('be.empty')
1317
cy.get('#client-tenant').should('have.text', 'david')
1418
cy.get('#server-tenant').should('have.text', 'david')
1519
cy.get('#router-pathname').should(
1620
'have.text',
17-
options.nextJsRouter === 'pages'
18-
? '/pages/multitenant/[tenant]'
19-
: '/app/multitenant'
21+
options.expectedPathname
2022
)
2123
cy.get('button').click()
2224
cy.get('#client-state').should('have.text', 'pass')
2325
cy.get('#client-tenant').should('have.text', 'david')
2426
cy.get('#server-tenant').should('have.text', 'david')
2527
cy.get('#router-pathname').should(
2628
'have.text',
27-
options.nextJsRouter === 'pages'
28-
? '/pages/multitenant/[tenant]'
29-
: '/app/multitenant'
29+
options.expectedPathname
3030
)
3131
if (shallow === false) {
3232
cy.get('#server-state').should('have.text', 'pass')
@@ -43,9 +43,7 @@ function testMultiTenant(options: TestConfig) {
4343
cy.get('#server-state').should('be.empty')
4444
cy.get('#router-pathname').should(
4545
'have.text',
46-
options.nextJsRouter === 'pages'
47-
? '/pages/multitenant/[tenant]'
48-
: '/app/multitenant'
46+
options.expectedPathname
4947
)
5048
})
5149
}
@@ -57,10 +55,14 @@ function testMultiTenant(options: TestConfig) {
5755

5856
testMultiTenant({
5957
path: '/app/multitenant',
60-
nextJsRouter: 'app'
58+
nextJsRouter: 'app',
59+
description: 'Dynamic route',
60+
expectedPathname: '/app/multitenant'
6161
})
6262

6363
testMultiTenant({
6464
path: '/pages/multitenant',
65-
nextJsRouter: 'pages'
65+
nextJsRouter: 'pages',
66+
description: 'Dynamic route',
67+
expectedPathname: '/pages/multitenant/[tenant]'
6668
})

packages/e2e/next/src/app/app/multitenant/[tenant]/page.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { Display } from 'e2e-shared/components/display'
12
import { ShallowUseQueryState } from 'e2e-shared/specs/shallow'
2-
import { ShallowDisplay } from 'e2e-shared/specs/shallow-display'
33
import {
44
createSearchParamsCache,
55
parseAsString,
@@ -36,7 +36,7 @@ export default async function TenantPage({ params, searchParams }: PageProps) {
3636
<Suspense>
3737
<ShallowUseQueryState />
3838
</Suspense>
39-
<ShallowDisplay environment="server" state={cache.get('state')} />
39+
<Display environment="server" state={cache.get('state')} />
4040
<p id="server-tenant">{tenant}</p>
4141
<Suspense>
4242
<TenantClient />

packages/e2e/next/src/pages/pages/multitenant/[tenant].tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { Display } from 'e2e-shared/components/display'
12
import { ShallowUseQueryState } from 'e2e-shared/specs/shallow'
2-
import { ShallowDisplay } from 'e2e-shared/specs/shallow-display'
33
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next'
44
import { useParams } from 'next/navigation'
55
import { useRouter } from 'next/router'
@@ -15,7 +15,7 @@ export default function Page({ serverState, tenant }: Props) {
1515
return (
1616
<>
1717
<ShallowUseQueryState />
18-
<ShallowDisplay environment="server" state={serverState} />
18+
<Display environment="server" state={serverState} />
1919
<p id="server-tenant">{tenant}</p>
2020
<p id="client-tenant">{params?.tenant}</p>
2121
<p id="router-pathname">{router.pathname}</p>

0 commit comments

Comments
 (0)