Skip to content

Commit dc649a0

Browse files
authored
migrate e2e (#664)
- **rename vue->platform-ui** - **git mv platform-ui e2e tests to platform-ui** - **move testing scripts for platform-ui e2e**
2 parents ed4d434 + 5941a17 commit dc649a0

File tree

22 files changed

+144
-57
lines changed

22 files changed

+144
-57
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: E2E Tests
1+
name: Platform E2E Tests
22

33
on:
44
schedule:
@@ -37,7 +37,7 @@ jobs:
3737
run: yarn install
3838
3939
- name: Install Cypress
40-
run: yarn cypress install
40+
run: yarn workspace @vue-skuilder/platform-ui cypress install
4141
4242
- name: Setup and wait for services
4343
run: |
@@ -53,7 +53,7 @@ jobs:
5353
- name: Run E2E tests
5454
run: |
5555
# Run Cypress tests
56-
yarn cypress run
56+
yarn workspace @vue-skuilder/platform-ui cypress run
5757
5858
- name: Cleanup services
5959
if: always()
@@ -68,13 +68,13 @@ jobs:
6868
if: failure()
6969
with:
7070
name: cypress-screenshots
71-
path: cypress/screenshots
71+
path: packages/platform-ui/cypress/screenshots
7272
retention-days: 7 # Optional: set retention period
7373
7474
- name: Upload videos
7575
uses: actions/upload-artifact@v4
7676
if: always()
7777
with:
7878
name: cypress-videos
79-
path: cypress/videos
79+
path: packages/platform-ui/cypress/videos
8080
retention-days: 7 # Optional: set retention period

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ yarn-error.log*
3131
# The caddy (web server) config file
3232
vue/Caddyfile
3333

34-
# Cyrpress build artifacts
35-
/packages/platform-ui/cypress
36-
3734
# yarn 2+ files
3835
.yarn/*
3936
!.yarn/patches

package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
"couchdb:status": "node scripts/dev-couchdb.js status",
1111
"couchdb:remove": "node scripts/dev-couchdb.js remove",
1212
"postdev": "node scripts/dev-couchdb.js stop",
13-
"test:e2e": "cypress open",
14-
"test:e2e:headless": "cypress run",
15-
"ci:e2e": "yarn dev & wait-on http://localhost:5173 && cypress run; kill $(lsof -t -i:8080); yarn couchdb:stop",
1613
"build": "yarn workspace @vue-skuilder/common build && yarn workspace @vue-skuilder/db build && yarn workspace @vue-skuilder/common-ui build && yarn workspace @vue-skuilder/courses build && yarn workspace @vue-skuilder/platform-ui build && yarn workspace @vue-skuilder/express build",
1714
"clean": "yarn clean:dist && yarn clean:node_modules",
1815
"clean:dist": "find packages -name 'dist' -type d -exec rm -rf {} +",
@@ -25,9 +22,6 @@
2522
],
2623
"packageManager": "yarn@4.6.0",
2724
"devDependencies": {
28-
"@types/cypress": "^1.1.6",
29-
"concurrently": "^9.1.2",
30-
"cypress": "^14.1.0",
31-
"wait-on": "^8.0.2"
25+
"concurrently": "^9.1.2"
3226
}
3327
}

packages/db/src/core/interfaces/courseDB.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { CourseConfig, CourseElo, DataShape } from '@vue-skuilder/common';
22
import { StudySessionNewItem, StudySessionItem } from './contentSource';
33
import { TagStub, Tag } from '../types/types-legacy';
44
import { SkuilderCourseData } from '@vue-skuilder/common/dist/db';
5+
import { DataLayerResult } from '../types/db';
56

67
/**
78
* Course content and management
@@ -121,7 +122,7 @@ export interface CourseDBInterface {
121122
tags: string[],
122123
uploads?: { [key: string]: PouchDB.Core.FullAttachment },
123124
elo?: CourseElo
124-
): Promise<PouchDB.Core.Response>;
125+
): Promise<DataLayerResult>;
125126

126127
removeCard(cardId: string): Promise<PouchDB.Core.Response>;
127128

packages/db/src/core/types/db.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Status } from '@vue-skuilder/common';
2+
3+
export interface DataLayerResult {
4+
status: Status;
5+
message: string;
6+
}

packages/db/src/impl/pouch/courseAPI.ts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { prepareNote55 } from '@vue-skuilder/common';
1111
import { User } from './userDB';
1212

1313
/**
14-
* @deprecated Use similar functionality from the dataLayerProvider
1514
*
1615
* @param courseID id of the course (quilt) being added to
1716
* @param codeCourse
@@ -43,14 +42,13 @@ export async function addNote55(
4342
if (result.ok) {
4443
// create cards
4544
await createCards(courseID, dataShapeId, result.id, tags, elo);
45+
} else {
46+
console.log(`Error adding note: ${result}`);
4647
}
4748

4849
return result;
4950
}
5051

51-
/**
52-
* @deprecated Use similar functionality from the dataLayerProvider
53-
*/
5452
export async function createCards(
5553
courseID: string,
5654
datashapeID: PouchDB.Core.DocumentId,
@@ -73,9 +71,6 @@ export async function createCards(
7371
}
7472
}
7573

76-
/**
77-
* @deprecated Use similar functionality from the dataLayerProvider
78-
*/
7974
async function createCard(
8075
questionViewName: string,
8176
courseID: string,
@@ -109,14 +104,15 @@ async function createCard(
109104
}
110105

111106
/**
112-
* @deprecated Use similar functionality from the dataLayerProvider
113107
*
114108
* Adds a card to the DB. This function is called
115109
* as a side effect of adding either a View or
116110
* DisplayableData item.
117111
* @param course The name of the course that the card belongs to
118112
* @param id_displayable_data C/PouchDB ID of the data used to hydrate the view
119113
* @param id_view C/PouchDB ID of the view used to display the card
114+
*
115+
* @package
120116
*/
121117
async function addCard(
122118
courseID: string,
@@ -153,8 +149,6 @@ export async function getCredentialledCourseConfig(courseID: string) {
153149
}
154150

155151
/**
156-
@deprecated Use similar functionality from the dataLayerProvider
157-
158152
Assciates a tag with a card.
159153
160154
NB: DB stores tags as separate documents, with a list of card IDs.
@@ -163,6 +157,7 @@ export async function getCredentialledCourseConfig(courseID: string) {
163157
NB: tags are created if they don't already exist
164158
165159
@param updateELO whether to update the ELO of the card with the new tag. Default true.
160+
@package
166161
*/
167162
export async function addTagToCard(
168163
courseID: string,
@@ -213,12 +208,6 @@ class AlreadyTaggedErr extends Error {
213208
}
214209
}
215210

216-
/**
217-
* @deprecated Use similar functionality from the dataLayerProvider
218-
*
219-
* @param tagName
220-
* @returns
221-
*/
222211
export function getTagID(tagName: string): string {
223212
const tagPrefix = DocType.TAG.valueOf() + '-';
224213
if (tagName.indexOf(tagPrefix) === 0) {
@@ -227,9 +216,7 @@ export function getTagID(tagName: string): string {
227216
return tagPrefix + tagName;
228217
}
229218
}
230-
/**
231-
* @deprecated Use similar functionality from the dataLayerProvider
232-
*/
219+
233220
export function getCourseDB(courseID: string): PouchDB.Database {
234221
const dbName = `coursedb-${courseID}`;
235222
return new pouch(

packages/db/src/impl/pouch/courseDB.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
DataShape,
77
ENV,
88
EloToNumber,
9+
Status,
910
blankCourseElo,
1011
toCourseElo,
1112
} from '@vue-skuilder/common';
@@ -21,6 +22,8 @@ import {
2122
import { CardData, DocType, SkuilderCourseData, Tag, TagStub } from '../../core/types/types-legacy';
2223
import { GET_CACHED } from './clientCache';
2324
import { addNote55, addTagToCard, getCredentialledCourseConfig, getTagID } from './courseAPI';
25+
import { DataLayerResult } from '@/core/types/db';
26+
import { PouchError } from './types';
2427

2528
const courseLookupDBTitle = 'coursedb-lookup';
2629

@@ -495,8 +498,30 @@ above:\n${above.rows.map((r) => `\t${r.id}-${r.key}\n`)}`;
495498
tags: string[],
496499
uploads?: { [key: string]: PouchDB.Core.FullAttachment },
497500
elo: CourseElo = blankCourseElo()
498-
): Promise<PouchDB.Core.Response> {
499-
return await addNote55(this.id, codeCourse, shape, data, author, tags, uploads, elo);
501+
): Promise<DataLayerResult> {
502+
try {
503+
const resp = await addNote55(this.id, codeCourse, shape, data, author, tags, uploads, elo);
504+
if (resp.ok) {
505+
return {
506+
status: Status.ok,
507+
message: '',
508+
};
509+
} else {
510+
return {
511+
status: Status.error,
512+
message: 'Unexpected ',
513+
};
514+
}
515+
} catch (e) {
516+
const err = e as PouchDB.Core.Error;
517+
console.error(
518+
`[addNote] error ${err.name}\n\treason: ${err.reason}\n\tmessage: ${err.message}`
519+
);
520+
return {
521+
status: Status.error,
522+
message: `Error adding note to course. ${(e as PouchError).reason}`,
523+
};
524+
}
500525
}
501526

502527
async getCourseDoc<T extends SkuilderCourseData>(

packages/express/src/client-requests/course-requests.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { postProcessCourse } from '../attachment-preprocessing/index.js';
66
import AsyncProcessQueue from '../utils/processQueue.js';
77
import nano from 'nano';
88
import { Status } from '@vue-skuilder/common';
9+
import logger from '@/logger.js';
910

1011
/**
1112
* Fake fcn to allow usage in couchdb map fcns which, after passing
@@ -190,22 +191,34 @@ async function createCourse(cfg: CourseConfig): Promise<any> {
190191
}
191192

192193
const courseID = lookupInsert.id;
194+
193195
cfg.courseID = courseID;
196+
await lookup.insert({
197+
...cfg,
198+
_id: lookupInsert.id,
199+
_rev: lookupInsert.rev,
200+
} as nano.MaybeDocument);
194201

195202
const courseDBName: string = getCourseDBName(courseID);
196203
const dbCreation = await CouchDB.db.create(courseDBName);
197204

198205
if (dbCreation.ok) {
199206
const courseDB = CouchDB.use(courseDBName);
200207

201-
courseDB.insert({
202-
_id: 'CourseConfig',
203-
...cfg,
204-
});
208+
courseDB
209+
.insert({
210+
_id: 'CourseConfig',
211+
...cfg,
212+
})
213+
.catch((e) => {
214+
logger.error(`Error inserting CourseConfig for course ${courseID}:`, e);
215+
});
205216

206217
// insert the tags, elo, etc view docs
207218
courseDBDesignDocs.forEach((doc) => {
208-
courseDB.insert(doc);
219+
courseDB.insert(doc).catch((e) => {
220+
logger.error(`Error inserting design doc for course ${courseID}:`, e);
221+
});
209222
});
210223

211224
if (!cfg.public) {
@@ -220,7 +233,12 @@ async function createCourse(cfg: CourseConfig): Promise<any> {
220233
},
221234
};
222235

223-
courseDB.insert(secObj as nano.MaybeDocument, '_security');
236+
courseDB.insert(secObj as nano.MaybeDocument, '_security').catch((e) => {
237+
logger.error(
238+
`Error inserting security object for course ${courseID}:`,
239+
e
240+
);
241+
});
224242
}
225243
}
226244

@@ -238,7 +256,7 @@ async function createCourse(cfg: CourseConfig): Promise<any> {
238256
export type CreateCourseResp = CreateCourse['response'];
239257

240258
export const CourseCreationQueue = new AsyncProcessQueue<
241-
// @ts-ignore
259+
// @ts-expect-error [I do not know why this thinks is is broken or why it works.]
242260
CreateCourse['data'],
243261
CreateCourse['response']
244262
>(createCourse);

cypress.config.js renamed to packages/platform-ui/cypress.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { defineConfig } = require('cypress');
22

33
module.exports = defineConfig({
44
e2e: {
5-
baseUrl: 'http://localhost:5173', // package/vue vite dev server port
5+
baseUrl: 'http://localhost:5173', // package/platform-ui vite dev server port
66
supportFile: 'cypress/support/e2e.js',
77
specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
88
setupNodeEvents(on, config) {
File renamed without changes.

0 commit comments

Comments
 (0)