Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-8689rj9th Add Super Admin Tests #820

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
947ba7d
create computed property for tasksDictionary
ksmontville Sep 18, 2024
4b764c3
add waiting between checking reports
ksmontville Sep 18, 2024
68d78a8
remove duplicate imports
ksmontville Sep 18, 2024
ae36994
try watcher instead of computed property for tasksDictionary
ksmontville Sep 18, 2024
116831a
create tasksDictionary in auth store method, rather than firekit method
ksmontville Sep 19, 2024
23a09d5
resolve dynamic imports in parallel to improve performance
ksmontville Sep 19, 2024
1eef1ac
update packages and add super admin github workflow
ksmontville Sep 16, 2024
1724d53
remove dynamic imports in Home Selector
ksmontville Sep 16, 2024
fec9d5b
create clean up tests for admins, administrators, orgs
ksmontville Sep 17, 2024
bcd9c23
add new ob to workflow to run clean up tests
ksmontville Sep 17, 2024
dce98d8
update super admin tests
ksmontville Sep 17, 2024
1447d48
change name of partner test admin in cypress config:
ksmontville Sep 18, 2024
9ed7500
comment out progress and score report filtering for now
ksmontville Sep 18, 2024
35d4a72
adjust registerStudents test
ksmontville Sep 18, 2024
df990e0
refactor some tests
ksmontville Sep 18, 2024
2d048ec
create computed property for tasksDictionary
ksmontville Sep 18, 2024
7392175
refactor registerStudents test
ksmontville Sep 18, 2024
18863b9
remove duplicate imports
ksmontville Sep 18, 2024
dcf491b
undo changes duplicated in a separate PR, update comments and formatting
ksmontville Sep 19, 2024
4a32935
create helper function for navigating to a page from the menu bar
ksmontville Sep 19, 2024
e74e52d
fix build failiures
ksmontville Sep 19, 2024
1cb80aa
Fix lint issues
ksmontville Sep 19, 2024
8bdb0cb
fix registerAdministrator test
ksmontville Sep 19, 2024
046a66e
cache node modules and build artifacts in workflow, for faster proces…
ksmontville Sep 19, 2024
595e545
properly cache node modules in clean-up step
ksmontville Sep 19, 2024
915fc30
refactor getDevFirebase
ksmontville Sep 23, 2024
202fb65
Refactor firebase utils and tests
ksmontville Sep 24, 2024
3b52b8a
update test descriptions and remove some comments
ksmontville Sep 24, 2024
9f63652
add super admin email secret to workflow
ksmontville Sep 25, 2024
7b8d97f
add super admin email secret to clean-up workflow
ksmontville Sep 25, 2024
bd8f1c7
Change description in clean-up workflow
ksmontville Sep 25, 2024
2815a0d
update package-lock
ksmontville Oct 16, 2024
e7a9a77
format and update cypress
ksmontville Oct 16, 2024
d4aebda
resolve linting issues
ksmontville Oct 16, 2024
21f6766
fix filepath to test student data csv
ksmontville Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/cypress-participant-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
CLEVER_PASSWORD: ${{ secrets.CLEVER_PASSWORD }}
CYPRESS_BASE_URL: 'http://localhost:5173'
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
COMMIT_INFO_MESSAGE: E2E Tests for PR ${{ github.event.number }} "${{ github.event.pull_request.title }}" from commit "${{ github.event.pull_request.head.sha }}"
COMMIT_INFO_MESSAGE: Participant E2E Tests for PR ${{ github.event.number }} "${{ github.event.pull_request.title }}" from commit "${{ github.event.pull_request.head.sha }}"
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}
PARTNER_ADMIN_USERNAME: ${{ secrets.PARTNER_ADMIN_USERNAME }}
PARTNER_ADMIN_PASSWORD: ${{ secrets.PARTNER_ADMIN_PASSWORD }}
Expand All @@ -48,7 +48,6 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

# For workflows triggered manually, targeting the LEVANTE dashboard repository specifically
- name: Checkout manual trigger code
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/cypress-partner-admin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
NODE_ENV: 'test'
CYPRESS_BASE_URL: 'http://localhost:5173'
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
COMMIT_INFO_MESSAGE: E2E Tests for PR ${{ github.event.number }} "${{ github.event.pull_request.title }}" from commit "${{ github.event.pull_request.head.sha }}"
COMMIT_INFO_MESSAGE: Partner Admin E2E Tests for PR ${{ github.event.number }} "${{ github.event.pull_request.title }}" from commit "${{ github.event.pull_request.head.sha }}"
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}
PARTNER_ADMIN_USERNAME: ${{ secrets.PARTNER_ADMIN_USERNAME }}
PARTNER_ADMIN_PASSWORD: ${{ secrets.PARTNER_ADMIN_PASSWORD }}
Expand All @@ -50,7 +50,6 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

# For workflows triggered manually, targeting the LEVANTE dashboard repository specifically
- name: Checkout manual trigger code
Expand Down
181 changes: 181 additions & 0 deletions .github/workflows/cypress-super-admin-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: Run Cypress Super Admin Tests

on:
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:
inputs:
pr_branch:
description: 'Checkout this branch from the LEVANTE repository and execute CI/CD tests on it.'
required: true

concurrency:
group: cypress-tests-${{ github.ref }}-0
cancel-in-progress: true

jobs:
cypress-run:
name: Run Cypress Super Admin Tests
runs-on: ubuntu-latest
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
browser: [chromium, edge]
containers: [1, 2]
env:
NODE_OPTIONS: '--max_old_space_size=8192'
NODE_ENV: 'test'
CYPRESS_BASE_URL: 'http://localhost:5173'
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
COMMIT_INFO_MESSAGE: Super Admin E2E Tests for PR ${{ github.event.number }} "${{ github.event.pull_request.title }}" from commit "${{ github.event.pull_request.head.sha }}"
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}
PARTNER_ADMIN_USERNAME: ${{ secrets.PARTNER_ADMIN_USERNAME }}
PARTNER_ADMIN_PASSWORD: ${{ secrets.PARTNER_ADMIN_PASSWORD }}
PARTNER_ADMIN_ID: ${{ secrets.PARTNER_ADMIN_ID }}
PARTICIPANT_USERNAME: ${{ secrets.PARTICIPANT_USERNAME}}
PARTICIPANT_PASSWORD: ${{ secrets.PARTICIPANT_PASSWORD }}
PARTICIPANT_EMAIL: ${{ secrets.PARTICIPANT_EMAIL }}
PARTICIPANT_EMAIL_PASSWORD: ${{ secrets.PARTICIPANT_EMAIL_PASSWORD }}
SUPER_ADMIN_USERNAME: ${{ secrets.SUPER_ADMIN_USERNAME }}
SUPER_ADMIN_PASSWORD: ${{ secrets.SUPER_ADMIN_PASSWORD }}
SUPER_ADMIN_EMAIL: ${{ secrets.SUPER_ADMIN_EMAIL }}
SUPER_ADMIN_ID: ${{ secrets.SUPER_ADMIN_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VITE_APPCHECK_DEBUG_TOKEN: ${{ secrets.VITE_APPCHECK_DEBUG_TOKEN }}
steps:
# For workflows triggered by pull requests
- name: Checkout PR code
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

# For workflows triggered manually, targeting the LEVANTE dashboard repository specifically
- name: Checkout manual trigger code
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.pr_branch }}
repository: levante-framework/levante-dashboard
fetch-depth: 0

- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: npm ci

- name: Cache build output
id: cache-build-output
uses: actions/cache@v3
with:
path: dist
key: ${{ runner.os }}-build-${{ hashFiles('package.json', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-

- name: Build project
run: npm run build

- name: Cypress run
uses: cypress-io/github-action@v6
with:
browser: ${{ matrix.browser }}
start: npm run dev
wait-on: ${{ env.CYPRESS_BASE_URL }}
wait-on-timeout: 120
record: true
parallel: true
spec: 'cypress/e2e/super-admin/default-tests/**/*'
ci-build-id: ${{ github.run_id }}-${{ matrix.browser }}

cypress-clean-up:
needs: cypress-run
name: Run Cypress Clean-Up tests
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
browser: [chromium]
containers: [1]
env:
NODE_OPTIONS: '--max_old_space_size=8192'
NODE_ENV: 'test'
CYPRESS_BASE_URL: 'http://localhost:5173'
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
COMMIT_INFO_MESSAGE: Super Admin Clean-Up Tests for PR ${{ github.event.number }} "${{ github.event.pull_request.title }}" from commit "${{ github.event.pull_request.head.sha }}"
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}
PARTNER_ADMIN_USERNAME: ${{ secrets.PARTNER_ADMIN_USERNAME }}
PARTNER_ADMIN_PASSWORD: ${{ secrets.PARTNER_ADMIN_PASSWORD }}
PARTNER_ADMIN_ID: ${{ secrets.PARTNER_ADMIN_ID }}
PARTICIPANT_USERNAME: ${{ secrets.PARTICIPANT_USERNAME}}
PARTICIPANT_PASSWORD: ${{ secrets.PARTICIPANT_PASSWORD }}
PARTICIPANT_EMAIL: ${{ secrets.PARTICIPANT_EMAIL }}
PARTICIPANT_EMAIL_PASSWORD: ${{ secrets.PARTICIPANT_EMAIL_PASSWORD }}
SUPER_ADMIN_USERNAME: ${{ secrets.SUPER_ADMIN_USERNAME }}
SUPER_ADMIN_PASSWORD: ${{ secrets.SUPER_ADMIN_PASSWORD }}
SUPER_ADMIN_EMAIL: ${{ secrets.SUPER_ADMIN_EMAIL }}
SUPER_ADMIN_ID: ${{ secrets.SUPER_ADMIN_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VITE_APPCHECK_DEBUG_TOKEN: ${{ secrets.VITE_APPCHECK_DEBUG_TOKEN }}

steps:
# For workflows triggered by pull requests
- name: Checkout PR code
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

# For workflows triggered manually, targeting the LEVANTE dashboard repository specifically
- name: Checkout manual trigger code
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.pr_branch }}
repository: levante-framework/levante-dashboard
fetch-depth: 0

- name: Restore node modules cache
id: restore-node-modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies (if not cached)
run: npm ci
if: steps.restore-node-modules.outputs.cache-hit != 'true'

- name: Restore build output cache
id: restore-build-output
uses: actions/cache@v3
with:
path: dist
key: ${{ runner.os }}-build-${{ hashFiles('package.json', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-

- name: Build project (if cache is not found)
run: npm run build
if: steps.restore-build-output.outputs.cache-hit != 'true'

- name: Cypress run
uses: cypress-io/github-action@v6
with:
browser: ${{ matrix.browser }}
start: npm run dev
wait-on: ${{ env.CYPRESS_BASE_URL }}
wait-on-timeout: 120
record: true
spec: 'cypress/e2e/super-admin/clean-up/**/*'
ci-build-id: ${{ github.run_id }}-${{ matrix.browser }}
3 changes: 2 additions & 1 deletion cypress.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module.exports = defineConfig({
sessionCookieValue: process.env.SESSION_COOKIE_VALUE,
superAdminUsername: process.env.SUPER_ADMIN_USERNAME,
superAdminPassword: process.env.SUPER_ADMIN_PASSWORD,
superAdminEmail: process.env.SUPER_ADMIN_EMAIL,
superAdminId: process.env.SUPER_ADMIN_ID,
partnerAdminUsername: process.env.PARTNER_ADMIN_USERNAME,
partnerAdminPassword: process.env.PARTNER_ADMIN_PASSWORD,
Expand All @@ -89,7 +90,7 @@ module.exports = defineConfig({
cleverSchoolName: '61e8aee84cf0e71b14295d45',
cleverUsername: process.env.CLEVER_USERNAME,
cleverPassword: process.env.CLEVER_PASSWORD,
testAdministrationName: 'Cypress Test Administration',
testAdministrationName: 'Cypress Super Admin Test Administration',
testAdministrationId: 'kKUSypkMc36mPEzleDE6',
testAdministratorFirstName: 'Cypress Test Administrator First Name',
testAdministratorMiddleName: 'Cypress Test Administrator Middle Name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('The partner admin can select and export progress reports for a given a
cy.get('.p-checkbox-box').first().click();

cy.get('button').contains('Export Selected').click();
cy.wait(Cypress.env('timeout'));
cy.readFile(`${Cypress.env('cypressDownloads')}/roar-progress-selected.csv`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('The partner admin can select and export progress reports for a given a
cy.get('.p-checkbox-box').first().click();

cy.get('button').contains('Export Selected').click();
cy.wait(Cypress.env('timeout'));
cy.readFile(
`${Cypress.env('cypressDownloads')}/roar-scores-selected-partner-test-administration-cypress-test-district.csv`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('The partner admin can select and export progress reports for a given a
cy.get('button').contains('Progress').first().click();

cy.get('button').contains('Export Whole Table').click();
cy.wait(Cypress.env('timeout'));
cy.readFile(
`${Cypress.env('cypressDownloads')}/roar-progress-partner-test-administration-cypress-test-district.csv`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('The partner admin can select and export progress reports for a given a
cy.get('button').contains('Score').first().click();

cy.get('button').contains('Export Whole Table').click();
cy.wait(Cypress.env('timeout'));
cy.readFile(`${Cypress.env('cypressDownloads')}/roar-scores-partner-test-administration-cypress-test-district.csv`);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { deleteTestAdministrations } from '../../../support/query.js';
import { useDevFirebase, signInAsSuperAdmin } from '../../../support/utils.js';

const { auth, db } = useDevFirebase('adminDev');

describe('Delete Test Administrations', () => {
before(() => {
signInAsSuperAdmin(auth);
});

it('should delete all test administrations for super and partner administrators', () => {
cy.wrap(deleteTestAdministrations(db), { timeout: 6 * Cypress.env('timeout') });
});
});
16 changes: 16 additions & 0 deletions cypress/e2e/super-admin/clean-up/deleteTestAdministrators.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { deleteTestAdministrators } from '../../../support/query.js';
import { useDevFirebase, signInAsSuperAdmin } from '../../../support/utils.js';

const { auth: adminAuth, db: adminDb } = useDevFirebase('adminDev');
const { auth: assessmentAuth, db: assessmentDb } = useDevFirebase('assessmentDev');

describe('Remove Test Administrators from admin and assessment Firestores', () => {
before(() => {
signInAsSuperAdmin(adminAuth);
signInAsSuperAdmin(assessmentAuth);
});

it('should delete all test administrations for super and partner administrators', () => {
cy.wrap(deleteTestAdministrators(adminDb, assessmentDb), { timeout: 6 * Cypress.env('timeout') });
});
});
14 changes: 14 additions & 0 deletions cypress/e2e/super-admin/clean-up/deleteTestOrgs.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { deleteTestOrgs } from '../../../support/query.js';
import { useDevFirebase, signInAsSuperAdmin } from '../../../support/utils.js';

const { auth: adminAuth, db: adminDb } = useDevFirebase('adminDev');

describe('Remove Test Organizations from Firestore.', () => {
before(() => {
signInAsSuperAdmin(adminAuth);
});

it('should delete all test administrations for super and partner administrators', () => {
cy.wrap(deleteTestOrgs(adminDb), { timeout: 6 * Cypress.env('timeout') });
});
});
22 changes: 11 additions & 11 deletions cypress/e2e/super-admin/clean-up/deleteTestRuns.cy.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { signInAsSuperAdmin } from '../../../support/helper-functions/super-admin/superAdminHelpers';
import { deleteTestRuns } from '../../../support/query';
import { getDevFirebase } from '../../../support/devFirebase';
import { useDevFirebase, signInAsSuperAdmin } from '../../../support/utils.js';

const testUsers = Cypress.env('testUserList');
const { auth: adminAuth, db: adminDb } = useDevFirebase('adminDev');
const { auth: assessmentAuth, db: assessmentDb } = useDevFirebase('assessmentDev');

const adminAuth = getDevFirebase('admin').auth;
const adminFirestore = getDevFirebase('admin').db;
const testUsers = Cypress.env('testUserList');

const assessmentAuth = getDevFirebase('assessment').auth;
const assessmentFirestore = getDevFirebase('assessment').db;
// This test is used to delete all test runs for all test users
// Leaving this out of CI for now, as it has caused issues in the past with run IDs not being deleted properly

describe('Delete Test Runs', () => {
before(() => {
Expand All @@ -17,9 +16,10 @@ describe('Delete Test Runs', () => {
});

it('should delete all test runs for all test users', () => {
for (const testUser of testUsers) {
cy.log('Deleting test runs for user:', testUser);
deleteTestRuns(testUser, adminFirestore, assessmentFirestore);
}
cy.log('Passes for now.');
// for (const testUser of testUsers) {
// cy.log('Deleting test runs for user:', testUser);
// deleteTestRuns(testUser, adminFirestore, assessmentFirestore);
// }
});
});
Loading
Loading