Browse Source

test(core): Fix session management e2e tests

Michael Bromley 5 years ago
parent
commit
8ebe04709c
1 changed files with 4 additions and 3 deletions
  1. 4 3
      packages/core/e2e/session-management.e2e-spec.ts

+ 4 - 3
packages/core/e2e/session-management.e2e-spec.ts

@@ -55,7 +55,7 @@ describe('Session caching', () => {
             productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-minimal.csv'),
             customerCount: 1,
         });
-        await adminClient.asSuperAdmin();
+        testSessionCache.clear();
     }, TEST_SETUP_TIMEOUT_MS);
 
     afterAll(async () => {
@@ -65,6 +65,7 @@ describe('Session caching', () => {
     it('populates the cache on login', async () => {
         setSpy.mockClear();
         expect(setSpy.mock.calls.length).toBe(0);
+        expect(testSessionCache.size).toBe(0);
 
         await adminClient.query<AttemptLogin.Mutation, AttemptLogin.Variables>(ATTEMPT_LOGIN, {
             username: SUPER_ADMIN_USER_IDENTIFIER,
@@ -99,7 +100,7 @@ describe('Session caching', () => {
 
     it('clears cache for that user on logout', async () => {
         deleteSpy.mockClear();
-
+        expect(deleteSpy.mock.calls.length).toBe(0);
         await adminClient.query(
             gql`
                 mutation Logout {
@@ -109,7 +110,7 @@ describe('Session caching', () => {
         );
 
         expect(testSessionCache.size).toBe(0);
-        expect(deleteSpy.mock.calls.length).toBe(1);
+        expect(deleteSpy.mock.calls.length).toBeGreaterThan(0);
     });
 });