Skip to content

Commit

Permalink
Make Cypress tests more resilient (#2249)
Browse files Browse the repository at this point in the history
* Replace macos-14 with ubuntu runner in cypress
- Replace macos-14 with macos-13 runner in clippy
 - macos14 runner has weaker hardware than other runners: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories

* Remove pre-installed incompatible packages from ubuntu runner

actions/runner-images#9546 (comment)

* Use ubuntu-20.04 for Cypress CI

* Adjust Cypress CI to follow common steps for linux env

* Debug preprep script

* Fix copy/paste typo

* Install playwright native dependencies

* Update release.yml

* Add  Remove 32-bit libs to setup-system

* Change Cypress CI to macos-13
 - Some small test fixes
 - Fix onboarding test must skip testing default location screen if no default locations os available

* Back to ubuntu for Cypress and back to macos-14 to clippy
- Attempt to fix empty default locations on ubuntu CI runner

* Oops

* Install playwright native deps

* Replace path regexs with consts
 - Click on share minimum when doing a fastOnboarding

* Try macos-14 again
  • Loading branch information
HeavenVolkoff committed Mar 28, 2024
1 parent a6737e4 commit 99ed900
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
13 changes: 12 additions & 1 deletion .github/actions/setup-system/action.yml
Expand Up @@ -58,6 +58,17 @@ runs:
curl -L# 'https://github.com/rui314/mold/releases/download/v2.4.0/mold-2.4.0-x86_64-linux.tar.gz' \
| sudo tar -xzf- -C /usr/local
- name: Remove 32-bit libs and incompatible pre-installed pkgs from Runner
shell: bash
if: ${{ runner.os == 'Linux' }}
run: |
dpkg -l | grep i386
sudo apt-get purge --allow-remove-essential libc6-i386 ".*:i386"
sudo dpkg --remove-architecture i386
# https://github.com/actions/runner-images/issues/9546#issuecomment-2014940361
sudo apt-get remove libunwind-*
- name: Setup Rust and Dependencies
uses: ./.github/actions/setup-rust
with:
Expand All @@ -83,4 +94,4 @@ runs:
pushd scripts
npm i --production
popd
node scripts/preprep.mjs
env NODE_ENV=debug node scripts/preprep.mjs
7 changes: 0 additions & 7 deletions .github/workflows/release.yml
Expand Up @@ -68,13 +68,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Remove 32-bit libs
if: ${{ runner.os == 'Linux' }}
run: |
dpkg -l | grep i386
sudo apt-get purge --allow-remove-essential libc6-i386 ".*:i386"
sudo dpkg --remove-architecture i386
- name: Install Apple API key
if: ${{ runner.os == 'macOS' }}
run: |
Expand Down
28 changes: 20 additions & 8 deletions apps/web/cypress/e2e/1-onboarding.spec.cy.ts
@@ -1,5 +1,12 @@
import { discordUrl, libraryName, privacyUrl } from '../fixtures/onboarding.json';
import { libraryRegex, onboardingRegex } from '../fixtures/routes';
import {
libraryRegex,
newLibraryRegex,
onboardingCreatingLibraryRegex,
onboardingLocationRegex,
onboardingPrivacyRegex,
onboardingRegex
} from '../fixtures/routes';

describe('Onboarding', () => {
// TODO: Create debug flag to bypass auto language detection
Expand All @@ -16,7 +23,7 @@ describe('Onboarding', () => {
.then((url) => (onboardingRegex.test(url) ? url : cy.deleteLibrary(libraryName)));

// Check redirect to initial alpha onboarding screen
cy.url().should('match', /\/onboarding\/alpha$/);
cy.url().should('match', onboardingRegex);

// Check application name is present
cy.get('h1').should('contain', 'Spacedrive');
Expand All @@ -41,7 +48,7 @@ describe('Onboarding', () => {
.click();

// Check we were redirect to Library creation screen
cy.url().should('match', /\/onboarding\/new-library$/);
cy.url().should('match', newLibraryRegex);

// Check create library screen title
cy.get('h2').should('contain', 'Create a Library');
Expand Down Expand Up @@ -70,7 +77,7 @@ describe('Onboarding', () => {
cy.get('@newLibraryButton').click();

// Check redirect to add default locations
cy.url().should('match', /\/onboarding\/locations$/);
cy.url().should('match', onboardingLocationRegex);

// Check we have a Toggle All button
cy.get('#toggle-all').as('toggleAllButton');
Expand All @@ -80,6 +87,11 @@ describe('Onboarding', () => {
if (locations == null || typeof locations !== 'object')
throw new Error('Invalid locations data');

const locationsEntries = Object.entries(locations);

// When there is no default locations, the UI doesn't show any buttons
if (locationsEntries.length <= 0) return;

// Check that default location checkboxes work
for (const state of ['unchecked', 'checked']) {
if (state === 'checked') {
Expand All @@ -90,7 +102,7 @@ describe('Onboarding', () => {
}

// Check we have all the default locations available
for (const [location, locationName] of Object.entries(locations)) {
for (const [location, locationName] of locationsEntries) {
if (typeof locationName !== 'string') throw new Error('Invalid location name');

let newState: typeof state;
Expand All @@ -113,7 +125,7 @@ describe('Onboarding', () => {
cy.get('button').contains('Continue').click();

// Check redirect to privacy screen
cy.url().should('match', /\/onboarding\/privacy$/);
cy.url().should('match', onboardingPrivacyRegex);

// Check privacy screen title
cy.get('h2').should('contain', 'Your Privacy');
Expand All @@ -133,8 +145,8 @@ describe('Onboarding', () => {
// Check we have a button to finish onboarding
cy.get('button[type="submit"]').contains('Continue').click();

// Check redirect to privacy screen
cy.url().should('match', /\/onboarding\/creating-library$/);
// Check redirect to create library screen
cy.url().should('match', onboardingCreatingLibraryRegex);

// FIX-ME: This fails a lot, due to the creating library screen only being show for a short time
// Check creating library screen title
Expand Down
1 change: 1 addition & 0 deletions apps/web/cypress/fixtures/routes.ts
Expand Up @@ -5,4 +5,5 @@ export const onboardingLocationRegex = /\/onboarding\/locations$/;
export const onboardingPrivacyRegex = /\/onboarding\/privacy$/;
export const librarySettingsRegex = /\/settings\/library\/general$/;
export const onboardingLibraryRegex = /\/onboarding\/new-library$/;
export const onboardingCreatingLibraryRegex = /\/onboarding\/creating-library$/;
export const locationRegex = /\/location\/1$/;
5 changes: 5 additions & 0 deletions apps/web/cypress/support/commands.ts
Expand Up @@ -6,6 +6,7 @@ import {
onboardingLibraryRegex,
onboardingLocationRegex,
onboardingPrivacyRegex,
onboardingCreatingLibraryRegex,
onboardingRegex
} from '../fixtures/routes';

Expand Down Expand Up @@ -45,8 +46,12 @@ Cypress.Commands.add('fastOnboarding', (libraryName: string) => {

// Privacy screen
cy.url().should('match', onboardingPrivacyRegex);
cy.get('label').contains('Share the bare minimum').click();
cy.get('button[type="submit"]').contains('Continue').click();

// Check redirect to create library screen
cy.url().should('match', onboardingCreatingLibraryRegex);

// Check redirect to Library
cy.checkUrlIsLibrary();
});
Expand Down

0 comments on commit 99ed900

Please sign in to comment.