1+
12import { test , expect } from "@playwright/test" ;
23
3- test ( "Instagram 0" , async ( { page } ) => {
4- await page . goto ( "/template/instagram-0" ) ;
4+ test . describe ( "instagram-0: ui tests" , ( ) => {
5+ test . beforeEach ( async ( { page } ) => {
6+ await page . goto ( "/template/instagram-0" ) ;
7+ } ) ;
58
6- // TODO
7- } ) ;
9+ test ( 'Should display changing content' , async ( { page } ) => {
10+ let image = await page . locator ( '.image.media-contain' ) ;
11+ await expect ( image ) . toHaveCSS ( 'background-image' , new RegExp ( 'fixtures/template/images/mountain1.jpeg' ) ) ;
12+ await expect ( image ) . toHaveCSS ( 'animation' , '1.5s ease 0s 1 normal none running fade-in' ) ;
13+ let userName = await page . locator ( '.author' ) ;
14+ await expect ( userName ) . toHaveText ( 'username' ) ;
15+ let descriptionText = await page . locator ( '.description .text' ) ;
16+ await expect ( descriptionText ) . toHaveText ( / S e d n u l l a l o r e m , v a r i u s s o d a l e s j u s t o a c , u l t r i c e s p l a c e r a t n u n c ./ ) ;
17+ let firstTag = await page . locator ( '.tags .tag' ) . nth ( 0 ) ;
18+ let secondTag = await page . locator ( '.tags .tag' ) . nth ( 1 ) ;
19+ await expect ( firstTag ) . toContainText ( '#mountains' ) ;
20+ await expect ( secondTag ) . toContainText ( '#horizon' ) ;
21+ let brandTag = await page . locator ( '.brand-tag' ) ;
22+ await expect ( brandTag ) . toHaveText ( '#myhashtag' ) ;
23+ await page . waitForTimeout ( 2000 ) ;
24+ image = await page . locator ( '.image.media-contain' ) ;
25+ await expect ( image ) . toHaveCSS ( 'background-image' , new RegExp ( 'fixtures/template/images/mountain1.jpeg' ) ) ;
26+ await expect ( image ) . toHaveCSS ( 'animation' , '1.5s ease 0s 1 normal none running fade-in' ) ;
27+ userName = await page . locator ( '.author' ) ;
28+ firstTag = await page . locator ( '.tags .tag' ) . nth ( 0 ) ;
29+ await expect ( firstTag ) . toContainText ( 'mountains' ) ;
30+ secondTag = await page . locator ( '.tags .tag' ) . nth ( 1 ) ;
31+ await expect ( secondTag ) . toContainText ( '#horizon' ) ;
32+ let thirdTag = await page . locator ( '.tags .tag' ) . nth ( 2 ) ;
33+ await expect ( thirdTag ) . toContainText ( '#sky' ) ;
34+ await expect ( userName ) . toHaveText ( 'username2' ) ;
35+ descriptionText = await page . locator ( '.description .text' ) ;
36+ await expect ( descriptionText ) . toHaveText ( / A e n e a n c o n s e q u a t s e m u t t o r t o r a u c t o r , e g e t v o l u t p a t l i b e r o c o n s e q u a t . D o n e c l a c i n i a v a r i u s q u a m , u t e f f i c i t u r d i a m u l t r i c e s e t . A l i q u a m e g e t a u g u e a t f e l i s r h o n c u s e g e s t a s . S e d p o r t t i t o r e l i t a t e l l u s t e m p u s , s e d t e m p u s s a p i e n f i n i b u s . N a m a t d a p i b u s s e m . A l i q u a m s i t a m e t f e u g i a t e x . U t d a p i b u s , m i e u f e r m e n t u m d i g n i s s i m , s e m i p s u m v u l p u t a t e e s t , s i t a m e t e u i s m o d o r c i o d i o p h a r e t r a m a s s a ./ ) ;
37+ brandTag = await page . locator ( '.brand-tag' ) ;
38+ await expect ( brandTag ) . toHaveText ( '#myhashtag' ) ;
39+ await page . waitForTimeout ( 3000 ) ;
40+ let video = await page . locator ( 'video' ) ;
41+ await expect ( video ) . toHaveAttribute ( 'autoplay' , '' ) ;
42+ await expect ( video ) . toHaveAttribute ( 'loop' , '' ) ;
43+ userName = await page . locator ( '.author' ) ;
44+ await expect ( userName ) . toHaveText ( 'username2' ) ;
45+ descriptionText = await page . locator ( '.description .text' ) ;
46+ await expect ( descriptionText ) . toHaveText ( / I n t e r d u m e t m a l e s u a d a f a m e s a c a n t e i p s u m p r i m i s / ) ;
47+ firstTag = await page . locator ( '.tags .tag' ) . nth ( 0 ) ;
48+ await expect ( firstTag ) . toContainText ( '#video' ) ;
49+ brandTag = await page . locator ( '.brand-tag' ) ;
50+ await expect ( brandTag ) . toHaveText ( '#myhashtag' ) ;
51+ } )
52+
53+ test ( 'Should display brand tag' , async ( { page } ) => {
54+ const brandTag = await page . locator ( '.brand-tag' ) ;
55+ await expect ( brandTag ) . toHaveText ( '#myhashtag' ) ;
56+ } ) ;
857
9- test ( "Instagram 1" , async ( { page } ) => {
10- await page . goto ( "/template/instagram-1-no-max-entries" ) ;
58+ test ( 'Should display brand shape' , async ( { page } ) => {
59+ const brandShape = await page . locator ( '.shape svg' ) ;
60+ await expect ( brandShape ) . toBeVisible ( ) ;
61+ } ) ;
1162
12- // TODO
63+ test ( 'Should have vertical class set' , async ( { page } ) => {
64+ let instagramTemplate = await page . locator ( '.template-instagram-feed' ) ;
65+ await expect ( instagramTemplate ) . toHaveClass ( 'template-instagram-feed vertical show' ) ;
66+ } ) ;
67+ test ( 'Should have image width style set' , async ( { page } ) => {
68+ let instagramTemplate = await page . locator ( '.template-instagram-feed' ) ;
69+ await expect ( instagramTemplate ) . toHaveCSS ( '--percentage-wide' , '20%' ) ;
70+ await expect ( instagramTemplate ) . toHaveCSS ( '--percentage-narrow' , '80%' ) ;
71+ } ) ;
1372} ) ;
73+
74+ test . describe ( "instagram-1-no-max-entries: ui tests" , ( ) => {
75+ test . beforeEach ( async ( { page } ) => {
76+ await page . goto ( "/template/instagram-1-no-max-entries" ) ;
77+ } ) ;
78+
79+ test ( 'Max entries not set' , async ( { page } ) => {
80+ let userName = await page . locator ( '.author' ) ;
81+ await expect ( userName ) . toHaveText ( 'username1' ) ;
82+ await page . waitForTimeout ( 1000 ) ;
83+ userName = await page . locator ( '.author' ) ;
84+ await expect ( userName ) . toHaveText ( 'username2' ) ;
85+ await page . waitForTimeout ( 1000 ) ;
86+ userName = await page . locator ( '.author' ) ;
87+ await expect ( userName ) . toHaveText ( 'username3' ) ;
88+ await page . waitForTimeout ( 1000 ) ;
89+ userName = await page . locator ( '.author' ) ;
90+ await expect ( userName ) . toHaveText ( 'username4' ) ;
91+ await page . waitForTimeout ( 1000 ) ;
92+ userName = await page . locator ( '.author' ) ;
93+ await expect ( userName ) . toHaveText ( 'username5' ) ;
94+ await page . waitForTimeout ( 1000 ) ;
95+ userName = await page . locator ( '.author' ) ;
96+ await expect ( userName ) . toHaveText ( 'username5' ) ;
97+ } ) ;
98+
99+ test ( 'Should have landscape class set' , async ( { page } ) => {
100+ let instagramTemplate = await page . locator ( '.template-instagram-feed' ) ;
101+ await expect ( instagramTemplate ) . toHaveClass ( 'template-instagram-feed landscape hide' ) ;
102+ } ) ;
103+ test ( 'Should have image width style set' , async ( { page } ) => {
104+ let instagramTemplate = await page . locator ( '.template-instagram-feed' ) ;
105+ await expect ( instagramTemplate ) . toHaveCSS ( '--percentage-wide' , '40%' ) ;
106+ await expect ( instagramTemplate ) . toHaveCSS ( '--percentage-narrow' , '60%' ) ;
107+ } ) ;
108+ } ) ;
0 commit comments