Skip to content

Commit 332f8ce

Browse files
RTL languages support
RTL languages are supported & E2E. Bug: T403013 Change-Id: I9ee2e8a72aa5c9808c58d808e6284f5be27c742f
1 parent 54ff34c commit 332f8ce

File tree

5 files changed

+116
-2
lines changed

5 files changed

+116
-2
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import { Util } from 'cypress-wikibase-api';
2+
import { EditStatementFormPage } from '../../support/pageObjects/EditStatementFormPage';
3+
import { ItemViewPage } from '../../support/pageObjects/ItemViewPage';
4+
5+
// RTL functionality and layout checks (see: T403013).
6+
describe( 'wbui2025 language preferences and RTL functionality', () => {
7+
context( 'mobile view', () => {
8+
let propertyName: string;
9+
let itemId: string;
10+
11+
const SELECTED_LANGUAGE = 'ar';
12+
13+
before( () => {
14+
cy.viewport( 375, 1280 );
15+
16+
// Note: Test data uses Arabic text.
17+
propertyName = Util.getTestString( 'خاصية' );
18+
cy.task( 'MwApi:CreateProperty', {
19+
label: {
20+
[ SELECTED_LANGUAGE ]: { language: SELECTED_LANGUAGE, value: propertyName },
21+
},
22+
data: { datatype: 'string' },
23+
} ).then( ( newPropertyId: string ) => {
24+
const statementData = {
25+
claims: [ {
26+
mainsnak: {
27+
snaktype: 'value',
28+
property: newPropertyId,
29+
datavalue: {
30+
value: 'مثال نصي',
31+
type: 'string',
32+
},
33+
},
34+
type: 'statement',
35+
rank: 'normal',
36+
} ],
37+
};
38+
cy.task( 'MwApi:CreateItem', {
39+
label: {
40+
[ SELECTED_LANGUAGE ]: {
41+
language: SELECTED_LANGUAGE,
42+
value: Util.getTestString( 'مثال لعنصر بالعربي' ),
43+
},
44+
},
45+
data: statementData,
46+
} ).then( ( newItemId: string ) => {
47+
itemId = newItemId;
48+
} );
49+
} );
50+
} );
51+
52+
beforeEach( () => {
53+
cy.viewport( 375, 1280 );
54+
} );
55+
56+
it.only( 'Checking RTL layout when editing statements', () => {
57+
const itemViewPage = new ItemViewPage( itemId );
58+
const editFormPage = new EditStatementFormPage();
59+
60+
itemViewPage.open( SELECTED_LANGUAGE );
61+
62+
// Verify RTL layout is maintained
63+
cy.get( 'html' ).should( 'have.attr', 'dir', 'rtl' );
64+
cy.get( 'html' ).should( 'have.attr', 'lang', SELECTED_LANGUAGE );
65+
66+
itemViewPage.statementsSection();
67+
68+
// Check if edit links exist and are clickable
69+
itemViewPage.editLinks().then( ( $links ) => {
70+
if ( $links.length > 0 ) {
71+
cy.wrap( $links.first() ).click();
72+
73+
// Verify RTL is maintained in edit mode
74+
cy.get( 'html' ).should( 'have.attr', 'dir', 'rtl' );
75+
cy.get( 'html' ).should( 'have.attr', 'lang', SELECTED_LANGUAGE );
76+
77+
editFormPage.textInput()
78+
.should( 'be.visible' )
79+
.should( 'have.value', 'مثال نصي' );
80+
81+
editFormPage.formHeading()
82+
.find( '.cdx-icon--flipped' )
83+
.should( 'exist' )
84+
.should( 'be.visible' );
85+
86+
editFormPage.formHeading()
87+
.find( '.cdx-icon--flipped' )
88+
.then( ( $el ) => {
89+
const comp = getComputedStyle( $el[ 0 ] );
90+
expect( parseFloat( comp.marginRight ) ).to.be.equal( 0 );
91+
} );
92+
93+
editFormPage.cancelButton()
94+
.invoke( 'text' )
95+
.should( 'match', /[\u0600-\u06FF]/ );
96+
97+
editFormPage.publishButton().then( ( $btn ) => {
98+
const { left, right } = $btn[ 0 ].getBoundingClientRect();
99+
// In RTL, "end" is left; button should be closer to left than right padding.
100+
expect( left ).to.be.lessThan( right );
101+
} );
102+
}
103+
} );
104+
} );
105+
} );
106+
} );

cypress/support/e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'cypress-axe';
33
// eslint-disable-next-line @typescript-eslint/no-namespace
44
declare namespace Cypress {
55
interface Chainable {
6-
visitTitle( args: string|object, qsDefaults: object ): Chainable<void>;
6+
visitTitle( args: string|object, qsDefaults: object ): Chainable<Window>;
77
visitTitleMobile( args: string|object ): Chainable<void>;
88
}
99
}

cypress/support/pageObjects/EditStatementFormPage.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ export class EditStatementFormPage {
5858
return cy.get( EditStatementFormPage.SELECTORS.SUBMIT_BUTTONS ).last();
5959
}
6060

61+
public cancelButton(): Chainable {
62+
return cy.get( EditStatementFormPage.SELECTORS.SUBMIT_BUTTONS ).first();
63+
}
64+
6165
public lookupInput(): Chainable {
6266
return cy.get( EditStatementFormPage.SELECTORS.LOOKUP_INPUT );
6367
}

cypress/support/pageObjects/ItemViewPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class ItemViewPage {
3333
// about texts (especially, for example, selecting items from a Codex MenuButton
3434
// menu) without needing to modify Codex components or introduce translation
3535
// support to Cypress.
36-
cy.visitTitleMobile( { title: 'Item:' + this.itemId, uselang: lang } );
36+
cy.visitTitleMobile( { title: 'Item:' + this.itemId, qs: { uselang: lang } } );
3737
return this;
3838
}
3939

repo/resources/wikibase.wbui2025/wikibase.wbui2025.statusMessage.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,9 @@ module.exports = exports = defineComponent( {
7575
.wikibase-wbui2025-status-message-container {
7676
position: fixed;
7777
bottom: 0;
78+
79+
& .cdx-message--user-dismissable {
80+
padding: 10px 10px 28px;
81+
}
7882
}
7983
</style>

0 commit comments

Comments
 (0)