Skip to content

Commit

Permalink
feat: update mode button, refactor (#1030)
Browse files Browse the repository at this point in the history
* refactor: update mode button, refactor

* refactor: apply PR requested changes

* refactor: update cypress

* refactor: mock item layout in commands

* refactor: import automatically env in cypress

* refactor: env in cypress

* refactor: import VITE_GRAASP_REDIRECTION_HOST

* refactor: use cypress baseurl
  • Loading branch information
pyphilia authored Feb 29, 2024
1 parent 3a9ca9d commit 1ee57ef
Show file tree
Hide file tree
Showing 76 changed files with 531 additions and 567 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Cypress CI
on:
push:
branches:
- "main"
- 'main'
merge_group:
pull_request:

Expand Down Expand Up @@ -45,11 +45,11 @@ jobs:
VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }}
VITE_GRAASP_ANALYZER_HOST: ${{ vars.VITE_GRAASP_ANALYZER_HOST }}
VITE_SHOW_NOTIFICATIONS: ${{ vars.VITE_SHOW_NOTIFICATIONS }}
VITE_GRAASP_REDIRECTION_HOST: ${{ vars.VITE_GRAASP_REDIRECTION_HOST }}
VITE_GRAASP_REDIRECTION_HOST: ${{ vars.VITE_GRAASP_REDIRECTION_HOST }}

# use the Cypress GitHub Action to run Cypress tests within the chrome browser
- name: Cypress run
uses: cypress-io/github-action@v5
uses: cypress-io/github-action@v6
with:
install: false
# we launch the app in preview mode to avoid issues with hmr websockets from vite polluting the mocks
Expand Down
16 changes: 9 additions & 7 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ export default defineConfig({
chromeWebSecurity: false,
e2e: {
env: {
API_HOST: process.env.VITE_GRAASP_API_HOST,
AUTH_HOST: process.env.VITE_GRAASP_AUTH_HOST,
BUILDER_HOST: `http://localhost:${process.env.VITE_PORT}`,
PLAYER_HOST: process.env.VITE_GRAASP_PLAYER_HOST,
ANALYZER_HOST: process.env.VITE_GRAASP_ANALYZER_HOST,
LIBRARY_HOST: process.env.VITE_GRAASP_LIBRARY_HOST,
REDIRECTION_HOST: process.env.VITE_GRAASP_REDIRECTION_HOST,
VITE_GRAASP_REDIRECTION_HOST: process.env.VITE_GRAASP_REDIRECTION_HOST,
VITE_GRAASP_DOMAIN: process.env.VITE_GRAASP_DOMAIN,
VITE_GRAASP_API_HOST: process.env.VITE_GRAASP_API_HOST,
VITE_SHOW_NOTIFICATIONS: false,
VITE_GRAASP_AUTH_HOST: process.env.VITE_GRAASP_AUTH_HOST,
VITE_GRAASP_PLAYER_HOST: process.env.VITE_GRAASP_PLAYER_HOST,
VITE_GRAASP_ANALYZER_HOST: process.env.VITE_GRAASP_ANALYZER_HOST,
VITE_GRAASP_LIBRARY_HOST: process.env.VITE_GRAASP_LIBRARY_HOST,
VITE_GRAASP_ACCOUNT_HOST: process.env.VITE_GRAASP_ACCOUNT_HOST,
},
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/item/copy/gridCopyItem.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
buildItemMenu,
buildItemMenuButtonId,
} from '../../../../src/config/selectors';
import { ITEM_LAYOUT_MODES } from '../../../../src/enums';
import { ItemLayoutMode } from '../../../../src/enums';
import { SAMPLE_ITEMS } from '../../../fixtures/items';

const copyItem = ({
Expand All @@ -28,7 +28,7 @@ describe('Copy Item in Grid', () => {
it('copy item on Home', () => {
cy.setUpApi(SAMPLE_ITEMS);
cy.visit(HOME_PATH);
cy.switchMode(ITEM_LAYOUT_MODES.GRID);
cy.switchMode(ItemLayoutMode.Grid);

// copy
const { id: copyItemId } = SAMPLE_ITEMS.items[0];
Expand All @@ -47,7 +47,7 @@ describe('Copy Item in Grid', () => {

// go to children item
cy.visit(buildItemPath(id));
cy.switchMode(ITEM_LAYOUT_MODES.GRID);
cy.switchMode(ItemLayoutMode.Grid);

// copy
const { id: copyItemId } = SAMPLE_ITEMS.items[2];
Expand All @@ -67,7 +67,7 @@ describe('Copy Item in Grid', () => {

// go to children item
cy.visit(buildItemPath(id));
cy.switchMode(ITEM_LAYOUT_MODES.GRID);
cy.switchMode(ItemLayoutMode.Grid);

// copy
const { id: copyItemId } = SAMPLE_ITEMS.items[2];
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/item/copy/listCopyItem.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
buildItemMenuButtonId,
buildItemsTableRowIdAttribute,
} from '../../../../src/config/selectors';
import ITEM_LAYOUT_MODES from '../../../../src/enums/itemLayoutModes';
import ItemLayoutMode from '../../../../src/enums/itemLayoutMode';
import { SAMPLE_ITEMS } from '../../../fixtures/items';

const copyItem = ({
Expand All @@ -27,7 +27,7 @@ describe('Copy Item in List', () => {
it('copy item on Home', () => {
cy.setUpApi(SAMPLE_ITEMS);
cy.visit(HOME_PATH);
cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// copy
const { id: copyItemId } = SAMPLE_ITEMS.items[0];
Expand All @@ -46,7 +46,7 @@ describe('Copy Item in List', () => {

// go to children item
cy.visit(buildItemPath(id));
cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// copy
const { id: copyItemId } = SAMPLE_ITEMS.items[2];
Expand All @@ -66,7 +66,7 @@ describe('Copy Item in List', () => {

// go to children item
cy.visit(buildItemPath(id));
cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// copy
const { id: copyItemId } = SAMPLE_ITEMS.items[2];
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/item/copy/listCopyMultiple.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
MY_GRAASP_ITEM_PATH,
buildItemsTableRowIdAttribute,
} from '../../../../src/config/selectors';
import ITEM_LAYOUT_MODES from '../../../../src/enums/itemLayoutModes';
import ItemLayoutMode from '../../../../src/enums/itemLayoutMode';
import { SAMPLE_ITEMS } from '../../../fixtures/items';

const copyItems = ({
Expand All @@ -30,7 +30,7 @@ describe('Copy items in List', () => {
cy.setUpApi(SAMPLE_ITEMS);
cy.visit(HOME_PATH);

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

const itemIds = [SAMPLE_ITEMS.items[0].id, SAMPLE_ITEMS.items[5].id];
const { path: toItemPath } = SAMPLE_ITEMS.items[1];
Expand All @@ -50,7 +50,7 @@ describe('Copy items in List', () => {

// go to children item
cy.visit(buildItemPath(start));
cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// copy
const itemIds = [SAMPLE_ITEMS.items[2].id, SAMPLE_ITEMS.items[4].id];
Expand All @@ -72,7 +72,7 @@ describe('Copy items in List', () => {

// go to children item
cy.visit(buildItemPath(start));
cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// copy
const itemIds = [SAMPLE_ITEMS.items[2].id, SAMPLE_ITEMS.items[4].id];
Expand Down
10 changes: 5 additions & 5 deletions cypress/e2e/item/create/createApp.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import ITEM_LAYOUT_MODES from '../../../../src/enums/itemLayoutModes';
import ItemLayoutMode from '../../../../src/enums/itemLayoutMode';
import {
GRAASP_APP_ITEM,
GRAASP_CUSTOM_APP_ITEM,
Expand All @@ -14,7 +14,7 @@ describe('Create App', () => {
cy.setUpApi();
cy.visit(HOME_PATH);

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createApp(GRAASP_APP_ITEM, { id: APPS_LIST[0].id });
Expand All @@ -29,7 +29,7 @@ describe('Create App', () => {
cy.setUpApi();
cy.visit(HOME_PATH);

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createApp(GRAASP_APP_ITEM, { custom: true });
Expand All @@ -49,7 +49,7 @@ describe('Create App', () => {
// go to children item
cy.visit(buildItemPath(id));

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createApp(GRAASP_APP_ITEM, { id: APPS_LIST[0].id });
Expand All @@ -67,7 +67,7 @@ describe('Create App', () => {
// go to children item
cy.visit(buildItemPath(id));

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createApp(GRAASP_CUSTOM_APP_ITEM, { custom: true });
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/item/create/createDocument.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ITEM_FORM_CONFIRM_BUTTON_ID } from '@/config/selectors';

import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import ITEM_LAYOUT_MODES from '../../../../src/enums/itemLayoutModes';
import ItemLayoutMode from '../../../../src/enums/itemLayoutMode';
import {
GRAASP_DOCUMENT_BLANK_NAME_ITEM,
GRAASP_DOCUMENT_ITEM,
Expand All @@ -14,7 +14,7 @@ describe('Create Document', () => {
cy.setUpApi();
cy.visit(HOME_PATH);

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createDocument(GRAASP_DOCUMENT_ITEM);
Expand All @@ -32,7 +32,7 @@ describe('Create Document', () => {
// go to children item
cy.visit(buildItemPath(id));

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createDocument(GRAASP_DOCUMENT_ITEM);
Expand All @@ -47,7 +47,7 @@ describe('Create Document', () => {
cy.setUpApi();
cy.visit(HOME_PATH);

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);
createDocument(GRAASP_DOCUMENT_BLANK_NAME_ITEM, { confirm: false });

cy.get(`#${ITEM_FORM_CONFIRM_BUTTON_ID}`).should(
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/item/create/createFile.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
// import ITEM_LAYOUT_MODES from '../../../../src/enums/itemLayoutModes';
// import ItemLayoutMode from '../../../../src/enums/itemLayoutModes';
// import { IMAGE_ITEM_DEFAULT, IMAGE_ITEM_S3 } from '../../../fixtures/files';
// import { SAMPLE_ITEMS } from '../../../fixtures/items';
// import { CREATE_ITEM_PAUSE } from '../../../support/constants';
Expand All @@ -12,7 +12,7 @@
// cy.setUpApi();
// cy.visit(HOME_PATH);

// cy.switchMode(ITEM_LAYOUT_MODES.LIST);
// cy.switchMode(ItemLayoutMode.List);

// // create
// createFile(IMAGE_ITEM_DEFAULT);
Expand All @@ -32,7 +32,7 @@
// // go to children item
// cy.visit(buildItemPath(id));

// cy.switchMode(ITEM_LAYOUT_MODES.LIST);
// cy.switchMode(ItemLayoutMode.List);

// // create
// createFile(IMAGE_ITEM_S3);
Expand Down
12 changes: 6 additions & 6 deletions cypress/e2e/item/create/createFolder.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ITEM_FORM_NAME_INPUT_ID,
buildItemsTableRowIdAttribute,
} from '../../../../src/config/selectors';
import ITEM_LAYOUT_MODES from '../../../../src/enums/itemLayoutModes';
import ItemLayoutMode from '../../../../src/enums/itemLayoutMode';
import {
CREATED_BLANK_NAME_ITEM,
CREATED_ITEM,
Expand All @@ -19,7 +19,7 @@ describe('Create Folder', () => {
cy.setUpApi();
cy.visit(HOME_PATH);

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createFolder(CREATED_ITEM);
Expand All @@ -34,7 +34,7 @@ describe('Create Folder', () => {
// go to children item
cy.visit(buildItemPath(id));

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createFolder(CREATED_ITEM);
Expand All @@ -58,7 +58,7 @@ describe('Create Folder', () => {
it('create folder on Home', () => {
cy.setUpApi();
cy.visit(HOME_PATH);
cy.switchMode(ITEM_LAYOUT_MODES.GRID);
cy.switchMode(ItemLayoutMode.Grid);

// create
createFolder(CREATED_ITEM);
Expand All @@ -77,7 +77,7 @@ describe('Create Folder', () => {

// go to children item
cy.visit(buildItemPath(id));
cy.switchMode(ITEM_LAYOUT_MODES.GRID);
cy.switchMode(ItemLayoutMode.Grid);

// create
createFolder(CREATED_ITEM);
Expand All @@ -97,7 +97,7 @@ describe('Create Folder', () => {
// go to children item
cy.visit(buildItemPath(id));

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createFolder(CREATED_ITEM);
Expand Down
10 changes: 5 additions & 5 deletions cypress/e2e/item/create/createLink.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import { ITEM_FORM_CONFIRM_BUTTON_ID } from '../../../../src/config/selectors';
import ITEM_LAYOUT_MODES from '../../../../src/enums/itemLayoutModes';
import ItemLayoutMode from '../../../../src/enums/itemLayoutMode';
import { SAMPLE_ITEMS } from '../../../fixtures/items';
import {
GRAASP_LINK_ITEM,
Expand All @@ -15,7 +15,7 @@ describe('Create Link', () => {
cy.setUpApi();
cy.visit(HOME_PATH);

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createLink(GRAASP_LINK_ITEM);
Expand All @@ -33,7 +33,7 @@ describe('Create Link', () => {
cy.setUpApi();
cy.visit(HOME_PATH);

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createLink(GRAASP_LINK_ITEM_NO_PROTOCOL);
Expand All @@ -54,7 +54,7 @@ describe('Create Link', () => {
// go to children item
cy.visit(buildItemPath(id));

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createLink(GRAASP_LINK_ITEM);
Expand All @@ -76,7 +76,7 @@ describe('Create Link', () => {
// go to children item
cy.visit(buildItemPath(id));

cy.switchMode(ITEM_LAYOUT_MODES.LIST);
cy.switchMode(ItemLayoutMode.List);

// create
createLink(INVALID_LINK_ITEM, {
Expand Down
Loading

0 comments on commit 1ee57ef

Please sign in to comment.