|
| 1 | +import { Util } from 'cypress-wikibase-api'; |
| 2 | + |
| 3 | +import { checkA11y } from '../../support/checkA11y'; |
| 4 | +import { ItemViewPage } from '../../support/pageObjects/ItemViewPage'; |
| 5 | +import { AddStatementFormPage } from '../../support/pageObjects/AddStatementFormPage'; |
| 6 | + |
| 7 | +describe( 'wbui2025 item view add statement', () => { |
| 8 | + context( 'mobile view', () => { |
| 9 | + let itemViewPage: ItemViewPage; |
| 10 | + |
| 11 | + before( () => { |
| 12 | + cy.task( 'MwApi:GetOrCreatePropertyIdByDataType', { datatype: 'string' } ) |
| 13 | + .then( ( propertyId: string ) => { |
| 14 | + cy.wrap( propertyId ).as( 'propertyId' ); |
| 15 | + const statementData = { |
| 16 | + claims: [ { |
| 17 | + mainsnak: { |
| 18 | + snaktype: 'value', |
| 19 | + property: propertyId, |
| 20 | + datavalue: { |
| 21 | + value: 'example string value', |
| 22 | + type: 'string', |
| 23 | + }, |
| 24 | + }, |
| 25 | + type: 'statement', |
| 26 | + rank: 'normal', |
| 27 | + } ], |
| 28 | + }; |
| 29 | + cy.task( 'MwApi:CreateItem', { label: Util.getTestString( 'item' ), data: statementData } ) |
| 30 | + .then( ( itemId: string ) => { |
| 31 | + itemViewPage = new ItemViewPage( itemId ); |
| 32 | + } ); |
| 33 | + } ); |
| 34 | + } ); |
| 35 | + |
| 36 | + beforeEach( () => { |
| 37 | + cy.viewport( 375, 1280 ); |
| 38 | + } ); |
| 39 | + |
| 40 | + it( 'loads the item view and shows property selector', () => { |
| 41 | + itemViewPage.open().statementsSection(); |
| 42 | + checkA11y( ItemViewPage.STATEMENTS ); |
| 43 | + itemViewPage.addStatementButton().click(); |
| 44 | + |
| 45 | + const addStatementFormPage = new AddStatementFormPage(); |
| 46 | + addStatementFormPage.propertyLookup().should( 'exist' ); |
| 47 | + cy.get<string>( '@propertyId' ).then( ( propertyId ) => { |
| 48 | + addStatementFormPage.setProperty( propertyId ); |
| 49 | + } ); |
| 50 | + addStatementFormPage.publishButton().should( 'be.disabled' ); |
| 51 | + addStatementFormPage.snakValueInput().should( 'exist' ); |
| 52 | + addStatementFormPage.setSnakValue( 'some string' ); |
| 53 | + addStatementFormPage.publishButton().click(); |
| 54 | + addStatementFormPage.form().should( 'not.exist' ); |
| 55 | + itemViewPage.mainSnakValues().eq( 1 ).should( 'have.text', 'some string' ); |
| 56 | + } ); |
| 57 | + |
| 58 | + } ); |
| 59 | +} ); |
0 commit comments