1717 * Imports
1818 */
1919import assert from "assert" ;
20- import puppeteer from "puppeteer" ;
21- import fetch from "isomorphic-fetch" ;
2220import {
2321 clearBrowserCookiesWithoutAffectingConsole ,
2422 screenshotOnFailure ,
@@ -29,14 +27,18 @@ import {
2927 submitForm ,
3028 getInvalidClaimsJSON as getInvalidClaims ,
3129 waitFor ,
30+ waitForText ,
31+ waitForUrl ,
32+ setupBrowser ,
33+ backendHook ,
34+ setupCoreApp ,
35+ setupST ,
3236} from "../helpers" ;
33-
34- // Run the tests in a DOM environment.
35- require ( "jsdom-global" ) ( ) ;
36- 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" ;
3738
3839describe ( "User Roles in the frontend" , function ( ) {
3940 before ( async function ( ) {
41+ backendHook ( "before" ) ;
4042 const isRolesSupported = await isUserRolesSupported ( ) ;
4143 if ( ! isRolesSupported ) {
4244 this . skip ( ) ;
@@ -47,13 +49,8 @@ describe("User Roles in the frontend", function () {
4749 let browser ;
4850 let page ;
4951 before ( async function ( ) {
50- await fetch ( `${ TEST_SERVER_BASE_URL } /beforeeach` , {
51- method : "POST" ,
52- } ) . catch ( console . error ) ;
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 puppeteer . launch ( {
5956 args : [ "--no-sandbox" , "--disable-setuid-sandbox" ] ,
@@ -69,24 +66,8 @@ describe("User Roles in the frontend", function () {
6966 await page . close ( ) ;
7067 } ) ;
7168
72- after ( async function ( ) {
73- await browser . close ( ) ;
74- await fetch ( `${ TEST_SERVER_BASE_URL } /after` , {
75- method : "POST" ,
76- } ) . catch ( console . error ) ;
77- await fetch ( `${ TEST_SERVER_BASE_URL } /stopst` , {
78- method : "POST" ,
79- } ) . catch ( console . error ) ;
80- } ) ;
81-
82- afterEach ( async function ( ) {
83- await screenshotOnFailure ( this , browser ) ;
84- if ( page ) {
85- page . close ( ) ;
86- }
87- } ) ;
88-
8969 beforeEach ( async function ( ) {
70+ backendHook ( "beforeEach" ) ;
9071 page = await browser . newPage ( ) ;
9172 await clearBrowserCookiesWithoutAffectingConsole ( page , [ ] ) ;
9273
@@ -103,6 +84,17 @@ describe("User Roles in the frontend", function () {
10384 await page . waitForSelector ( ".sessionInfo-user-id" ) ;
10485 } ) ;
10586
87+ afterEach ( async function ( ) {
88+ await screenshotOnFailure ( this , browser ) ;
89+ await page ?. close ( ) ;
90+ await backendHook ( "afterEach" ) ;
91+ } ) ;
92+
93+ after ( async function ( ) {
94+ await browser ?. close ( ) ;
95+ await backendHook ( "after" ) ;
96+ } ) ;
97+
10698 it ( "should be able to read in the frontend" , async ( ) => {
10799 assert . deepStrictEqual (
108100 await page . evaluate ( ( ) =>
0 commit comments