11// Entity-location defaults — ADMIN user variant.
22// Logs in as admin@otoroshi .io (super-admin), so the default location should
3- // resolve to "Default organization" + "Default team" .
3+ // resolve to the default organization + default team.
44// See tester.spec.js for the constrained-rights variant.
55import { test , expect } from '@playwright/test' ;
66
77let context ;
8+ // The default org/team name+description differ between a fresh instance and
9+ // an older datastore (two divergent seed paths in Env.scala). Don't hardcode
10+ // them — fetch the real entities and build the expected "<name> - <desc>"
11+ // strings the Location component renders.
12+ let expectedOrgText ;
13+ let expectedTeamText ;
814
915test . beforeAll ( async ( { browser } ) => {
1016 context = await browser . newContext ( { storageState : 'tests/playwright/.auth/admin.json' } ) ;
17+
18+ const page = await context . newPage ( ) ;
19+ const tenant = await ( await page . request . get ( '/bo/api/proxy/api/tenants/default' ) ) . json ( ) ;
20+ const team = await ( await page . request . get ( '/bo/api/proxy/api/teams/default' ) ) . json ( ) ;
21+ expectedOrgText = `${ tenant . name } - ${ tenant . description } ` ;
22+ expectedTeamText = `${ team . name } - ${ team . description } ` ;
23+ await page . close ( ) ;
1124} ) ;
1225
1326test . afterAll ( async ( ) => {
@@ -20,8 +33,8 @@ async function shouldDefaultTeamsAndTenant(path, action = 'add item') {
2033
2134 await page . getByRole ( 'button' , { name : action , exact : false } ) . click ( ) ;
2235
23- await expect ( page . locator ( '#content-scroll-container' ) ) . toContainText ( 'Default organization - The default organization' ) ;
24- await expect ( page . locator ( '#content-scroll-container' ) ) . toContainText ( 'Default Team - The default Team of the default organization' ) ;
36+ await expect ( page . locator ( '#content-scroll-container' ) ) . toContainText ( expectedOrgText ) ;
37+ await expect ( page . locator ( '#content-scroll-container' ) ) . toContainText ( expectedTeamText ) ;
2538}
2639
2740async function shouldDefaultTenantOnTeam ( ) {
@@ -30,7 +43,7 @@ async function shouldDefaultTenantOnTeam() {
3043
3144 await page . getByRole ( 'button' , { name : 'add item' , exact : false } ) . click ( ) ;
3245
33- await expect ( page . locator ( '#content-scroll-container' ) ) . toContainText ( 'Default organization - The default organization' ) ;
46+ await expect ( page . locator ( '#content-scroll-container' ) ) . toContainText ( expectedOrgText ) ;
3447}
3548
3649async function shouldDefaultTeamsAndTenantOnRoutes ( ) {
@@ -40,8 +53,8 @@ async function shouldDefaultTeamsAndTenantOnRoutes() {
4053 await page . getByRole ( 'link' , { name : / C r e a t e n e w r o u t e / } ) . click ( ) ;
4154 await page . locator ( 'div' ) . filter ( { hasText : / ^ L o c a t i o n $ / } ) . nth ( 1 ) . click ( ) ;
4255
43- await expect ( page . locator ( '#content-scroll-container' ) ) . toContainText ( 'Default organization - The default organization' ) ;
44- await expect ( page . locator ( '#content-scroll-container' ) ) . toContainText ( 'Default Team - The default Team of the default organization' ) ;
56+ await expect ( page . locator ( '#content-scroll-container' ) ) . toContainText ( expectedOrgText ) ;
57+ await expect ( page . locator ( '#content-scroll-container' ) ) . toContainText ( expectedTeamText ) ;
4558}
4659
4760test ( '[admin] New Routes got the right entity location' , async ( ) => shouldDefaultTeamsAndTenantOnRoutes ( ) ) ;
0 commit comments