@@ -208,3 +208,92 @@ describe('Lexical Fully Featured', () => {
208208 await expect ( codeBlock . locator ( '.monaco-editor .view-overlays .squiggly-error' ) ) . toHaveCount ( 0 )
209209 } )
210210} )
211+
212+ describe ( 'Lexical Fully Featured, admin panel in RTL' , ( ) => {
213+ let lexical : LexicalHelpers
214+ beforeAll ( async ( { browser } , testInfo ) => {
215+ testInfo . setTimeout ( TEST_TIMEOUT_LONG )
216+ process . env . SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit
217+ ; ( { payload, serverURL } = await initPayloadE2ENoConfig < Config > ( { dirname } ) )
218+
219+ const page = await browser . newPage ( )
220+ await ensureCompilationIsDone ( { page, serverURL } )
221+ await page . close ( )
222+ } )
223+ beforeEach ( async ( { page } ) => {
224+ const url = new AdminUrlUtil ( serverURL , lexicalFullyFeaturedSlug )
225+ lexical = new LexicalHelpers ( page )
226+ await page . goto ( url . account )
227+ await page . locator ( '.payload-settings__language .react-select' ) . click ( )
228+ const options = page . locator ( '.rs__option' )
229+ await options . locator ( 'text=עברית' ) . click ( )
230+ await expect ( page . getByText ( 'משתמשים' ) . first ( ) ) . toBeVisible ( )
231+ await page . goto ( url . create )
232+ await lexical . editor . first ( ) . focus ( )
233+ } )
234+ test ( 'slash menu should be positioned correctly in RTL' , async ( { page } ) => {
235+ await page . keyboard . type ( '/' )
236+ const menu = page . locator ( '#slash-menu .slash-menu-popup' )
237+ await expect ( menu ) . toBeVisible ( )
238+
239+ // left edge (0 indents)
240+ const menuBox = ( await menu . boundingBox ( ) ) !
241+ const slashBox = ( await lexical . paragraph . getByText ( '/' , { exact : true } ) . boundingBox ( ) ) !
242+ await expect ( ( ) => {
243+ expect ( menuBox . x ) . toBeGreaterThan ( 0 )
244+ expect ( menuBox . x ) . toBeLessThan ( slashBox . x )
245+ } ) . toPass ( { timeout : 100 } )
246+ await page . keyboard . press ( 'Backspace' )
247+ await expect ( menu ) . toBeHidden ( )
248+
249+ // A bit separated (3 tabs)
250+ for ( let i = 0 ; i < 3 ; i ++ ) {
251+ await page . keyboard . press ( 'Tab' )
252+ }
253+ await page . keyboard . type ( '/' )
254+ await expect ( menu ) . toBeVisible ( )
255+ const menuBox2 = ( await menu . boundingBox ( ) ) !
256+ const slashBox2 = ( await lexical . paragraph . getByText ( '/' , { exact : true } ) . boundingBox ( ) ) !
257+ await expect ( ( ) => {
258+ expect ( menuBox2 . x ) . toBe ( menuBox . x )
259+ // indents should allways be 40px. Please don't change this! https://github.com/payloadcms/payload/pull/13274
260+ expect ( slashBox2 . x ) . toBe ( slashBox . x + 40 * 3 )
261+ } ) . toPass ( { timeout : 100 } )
262+ await page . keyboard . press ( 'Backspace' )
263+ await expect ( menu ) . toBeHidden ( )
264+
265+ // middle approx (13 tabs)
266+ for ( let i = 0 ; i < 10 ; i ++ ) {
267+ await page . keyboard . press ( 'Tab' )
268+ }
269+ await page . keyboard . type ( '/' )
270+ await expect ( menu ) . toBeVisible ( )
271+ const menuBox3 = ( await menu . boundingBox ( ) ) !
272+ const slashBox3 = ( await lexical . paragraph . getByText ( '/' , { exact : true } ) . boundingBox ( ) ) !
273+ await expect ( ( ) => {
274+ // The right edge of the menu should be approximately the same as the left edge of the slash
275+ expect ( menuBox3 . x + menuBox3 . width ) . toBeLessThan ( slashBox3 . x + 15 )
276+ expect ( menuBox3 . x + menuBox3 . width ) . toBeGreaterThan ( slashBox3 . x - 15 )
277+ // indents should allways be 40px. Please don't change this! https://github.com/payloadcms/payload/pull/13274
278+ expect ( slashBox3 . x ) . toBe ( slashBox . x + 40 * 13 )
279+ } ) . toPass ( { timeout : 100 } )
280+ await page . keyboard . press ( 'Backspace' )
281+ await expect ( menu ) . toBeHidden ( )
282+
283+ // right edge (27 tabs)
284+ for ( let i = 0 ; i < 14 ; i ++ ) {
285+ await page . keyboard . press ( 'Tab' )
286+ }
287+ await page . keyboard . type ( '/' )
288+ await expect ( menu ) . toBeVisible ( )
289+ const menuBox4 = ( await menu . boundingBox ( ) ) !
290+ const slashBox4 = ( await lexical . paragraph . getByText ( '/' , { exact : true } ) . boundingBox ( ) ) !
291+ await expect ( ( ) => {
292+ // The right edge of the menu should be approximately the same as the left edge of the slash
293+ expect ( menuBox4 . x + menuBox4 . width ) . toBeLessThan ( slashBox4 . x + 15 )
294+ expect ( menuBox4 . x + menuBox4 . width ) . toBeGreaterThan ( slashBox4 . x - 15 )
295+ // indents should allways be 40px. Please don't change this! https://github.com/payloadcms/payload/pull/13274
296+ expect ( slashBox4 . x ) . toBe ( slashBox . x + 40 * 27 )
297+ } ) . toPass ( { timeout : 100 } )
298+ } )
299+ } )
0 commit comments