1717 * Imports
1818 */
1919import assert from "assert" ;
20- import puppeteer from "puppeteer" ;
21- import fetch from "isomorphic-fetch" ;
2220import {
2321 clearBrowserCookiesWithoutAffectingConsole ,
2422 screenshotOnFailure ,
@@ -30,15 +28,17 @@ import {
3028 getInvalidClaimsJSON as getInvalidClaims ,
3129 waitFor ,
3230 waitForText ,
33- backendBeforeEach ,
3431 waitForUrl ,
3532 setupBrowser ,
33+ backendHook ,
34+ setupCoreApp ,
35+ setupST ,
3636} from "../helpers" ;
37-
38- import { TEST_APPLICATION_SERVER_BASE_URL , TEST_CLIENT_BASE_URL , TEST_SERVER_BASE_URL } from "../constants" ;
37+ import { TEST_APPLICATION_SERVER_BASE_URL , TEST_CLIENT_BASE_URL } from "../constants" ;
3938
4039describe ( "User Roles in the frontend" , function ( ) {
4140 before ( async function ( ) {
41+ backendHook ( "before" ) ;
4242 const isRolesSupported = await isUserRolesSupported ( ) ;
4343 if ( ! isRolesSupported ) {
4444 this . skip ( ) ;
@@ -49,11 +49,8 @@ describe("User Roles in the frontend", function () {
4949 let browser ;
5050 let page ;
5151 before ( async function ( ) {
52- await backendBeforeEach ( ) ;
53-
54- await fetch ( `${ TEST_SERVER_BASE_URL } /startst` , {
55- method : "POST" ,
56- } ) . catch ( console . error ) ;
52+ const coreUrl = await setupCoreApp ( ) ;
53+ await setupST ( { coreUrl } ) ;
5754
5855 browser = await setupBrowser ( ) ;
5956 page = await browser . newPage ( ) ;
@@ -66,24 +63,8 @@ describe("User Roles in the frontend", function () {
6663 await page . close ( ) ;
6764 } ) ;
6865
69- after ( async function ( ) {
70- await browser . close ( ) ;
71- await fetch ( `${ TEST_SERVER_BASE_URL } /after` , {
72- method : "POST" ,
73- } ) . catch ( console . error ) ;
74- await fetch ( `${ TEST_SERVER_BASE_URL } /stopst` , {
75- method : "POST" ,
76- } ) . catch ( console . error ) ;
77- } ) ;
78-
79- afterEach ( async function ( ) {
80- await screenshotOnFailure ( this , browser ) ;
81- if ( page ) {
82- page . close ( ) ;
83- }
84- } ) ;
85-
8666 beforeEach ( async function ( ) {
67+ backendHook ( "beforeEach" ) ;
8768 page = await browser . newPage ( ) ;
8869 await clearBrowserCookiesWithoutAffectingConsole ( page , [ ] ) ;
8970
@@ -100,6 +81,17 @@ describe("User Roles in the frontend", function () {
10081 await page . waitForSelector ( ".sessionInfo-user-id" ) ;
10182 } ) ;
10283
84+ afterEach ( async function ( ) {
85+ await screenshotOnFailure ( this , browser ) ;
86+ await page ?. close ( ) ;
87+ await backendHook ( "afterEach" ) ;
88+ } ) ;
89+
90+ after ( async function ( ) {
91+ await browser ?. close ( ) ;
92+ await backendHook ( "after" ) ;
93+ } ) ;
94+
10395 it ( "should be able to read in the frontend" , async ( ) => {
10496 assert . deepStrictEqual (
10597 await page . evaluate ( ( ) =>
0 commit comments