@@ -10,10 +10,10 @@ import {
10
10
SiteCustomizationSettings ,
11
11
} from '@gitbook/api' ;
12
12
import { test , expect , Page } from '@playwright/test' ;
13
+ import deepMerge from 'deepmerge' ;
13
14
import jwt from 'jsonwebtoken' ;
14
15
import rison from 'rison' ;
15
16
import { DeepPartial } from 'ts-essentials' ;
16
- import deepMerge from 'deepmerge' ;
17
17
18
18
import { getContentTestURL } from '../tests/utils' ;
19
19
@@ -930,6 +930,94 @@ const testCases: TestsCase[] = [
930
930
} ,
931
931
] ,
932
932
} ,
933
+ {
934
+ name : 'Adaptive Content - VA' ,
935
+ baseUrl : `https://gitbook-open-e2e-sites.gitbook.io/adaptive-content-va/` ,
936
+ tests : [
937
+ {
938
+ name : 'isAlphaUser' ,
939
+ url : ( ( ) => {
940
+ const privateKey = 'afe09cdf-0f43-480a-b54c-8b1f62f174f9' ;
941
+ const token = jwt . sign (
942
+ {
943
+ name : 'gitbook-open-tests' ,
944
+ isAlphaUser : true ,
945
+ } ,
946
+ privateKey ,
947
+ {
948
+ expiresIn : '24h' ,
949
+ } ,
950
+ ) ;
951
+ return `?jwt_token=${ token } ` ;
952
+ } ) ( ) ,
953
+ run : async ( page ) => {
954
+ const alphaUserPage = page
955
+ . locator ( 'a[class*="group\\/toclink"]' )
956
+ . filter ( { hasText : 'Alpha users' } ) ;
957
+ const betaUserPage = page
958
+ . locator ( 'a[class*="group\\/toclink"]' )
959
+ . filter ( { hasText : 'Beta users' } ) ;
960
+ await expect ( alphaUserPage ) . toBeVisible ( ) ;
961
+ await expect ( betaUserPage ) . toHaveCount ( 0 ) ;
962
+ } ,
963
+ } ,
964
+ {
965
+ name : 'isBetaUser' ,
966
+ url : ( ( ) => {
967
+ const privateKey = 'afe09cdf-0f43-480a-b54c-8b1f62f174f9' ;
968
+ const token = jwt . sign (
969
+ {
970
+ name : 'gitbook-open-tests' ,
971
+ isBetaUser : true ,
972
+ } ,
973
+ privateKey ,
974
+ {
975
+ expiresIn : '24h' ,
976
+ } ,
977
+ ) ;
978
+ return `?jwt_token=${ token } ` ;
979
+ } ) ( ) ,
980
+ run : async ( page ) => {
981
+ const alphaUserPage = page
982
+ . locator ( 'a[class*="group\\/toclink"]' )
983
+ . filter ( { hasText : 'Alpha users' } ) ;
984
+ const betaUserPage = page
985
+ . locator ( 'a[class*="group\\/toclink"]' )
986
+ . filter ( { hasText : 'Beta users' } ) ;
987
+ await expect ( betaUserPage ) . toBeVisible ( ) ;
988
+ await expect ( alphaUserPage ) . toHaveCount ( 0 ) ;
989
+ } ,
990
+ } ,
991
+ {
992
+ name : 'isAlphaUser & isBetaUser' ,
993
+ url : ( ( ) => {
994
+ const privateKey = 'afe09cdf-0f43-480a-b54c-8b1f62f174f9' ;
995
+ const token = jwt . sign (
996
+ {
997
+ name : 'gitbook-open-tests' ,
998
+ isAlphaUser : true ,
999
+ isBetaUser : true ,
1000
+ } ,
1001
+ privateKey ,
1002
+ {
1003
+ expiresIn : '24h' ,
1004
+ } ,
1005
+ ) ;
1006
+ return `?jwt_token=${ token } ` ;
1007
+ } ) ( ) ,
1008
+ run : async ( page ) => {
1009
+ const alphaUserPage = page
1010
+ . locator ( 'a[class*="group\\/toclink"]' )
1011
+ . filter ( { hasText : 'Alpha users' } ) ;
1012
+ const betaUserPage = page
1013
+ . locator ( 'a[class*="group\\/toclink"]' )
1014
+ . filter ( { hasText : 'Beta users' } ) ;
1015
+ await expect ( alphaUserPage ) . toBeVisible ( ) ;
1016
+ await expect ( betaUserPage ) . toBeVisible ( ) ;
1017
+ } ,
1018
+ } ,
1019
+ ] ,
1020
+ } ,
933
1021
] ;
934
1022
935
1023
for ( const testCase of testCases ) {
0 commit comments