-
Notifications
You must be signed in to change notification settings - Fork 83
feat(astro): support lessons without parts or chapters #374
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
Changes from all commits
a5bf9d9
06bd4e7
e65eee1
5630f6b
0b2896a
523d749
dfd2547
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import tutorialkit from '@tutorialkit/astro'; | ||
import { defineConfig } from 'astro/config'; | ||
|
||
export default defineConfig({ | ||
devToolbar: { enabled: false }, | ||
server: { port: 4332 }, | ||
outDir: './dist-lessons-in-part', | ||
integrations: [tutorialkit()], | ||
srcDir: './src-custom/lessons-in-part', | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import tutorialkit from '@tutorialkit/astro'; | ||
import { defineConfig } from 'astro/config'; | ||
|
||
export default defineConfig({ | ||
devToolbar: { enabled: false }, | ||
server: { port: 4331 }, | ||
outDir: './dist-lessons-in-root', | ||
integrations: [tutorialkit()], | ||
srcDir: './src-custom/lessons-in-root', | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { contentSchema } from '@tutorialkit/types'; | ||
import { defineCollection } from 'astro:content'; | ||
|
||
const tutorial = defineCollection({ | ||
type: 'content', | ||
schema: contentSchema, | ||
}); | ||
|
||
export const collections = { tutorial }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
type: tutorial | ||
mainCommand: '' | ||
prepareCommands: [] | ||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
type: lesson | ||
title: Lesson one | ||
--- | ||
|
||
# Lessons in part test - Lesson one | ||
|
||
Lesson in part without chapter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
type: lesson | ||
title: Lesson two | ||
--- | ||
|
||
# Lessons in part test - Lesson two | ||
|
||
Lesson in part without chapter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
type: part | ||
title: 'Part one' | ||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
type: lesson | ||
title: Lesson three | ||
--- | ||
|
||
# Lessons in part test - Lesson three | ||
|
||
Lesson in chapter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
type: lesson | ||
title: Lesson four | ||
--- | ||
|
||
# Lessons in part test - Lesson four | ||
|
||
Lesson in chapter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
type: chapter | ||
title: 'Chapter one' | ||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
type: part | ||
title: 'Part two' | ||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="../../.astro/types.d.ts" /> | ||
/// <reference types="@tutorialkit/astro/types" /> | ||
/// <reference types="astro/client" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { contentSchema } from '@tutorialkit/types'; | ||
import { defineCollection } from 'astro:content'; | ||
|
||
const tutorial = defineCollection({ | ||
type: 'content', | ||
schema: contentSchema, | ||
}); | ||
|
||
export const collections = { tutorial }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
type: lesson | ||
title: Lesson one | ||
--- | ||
|
||
# Lessons in root test - Lesson one | ||
|
||
Lesson in root without part |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
type: lesson | ||
title: Lesson two | ||
--- | ||
|
||
# Lessons in root test - Lesson two | ||
|
||
Lesson in root without part |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
type: tutorial | ||
mainCommand: '' | ||
prepareCommands: [] | ||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="../../.astro/types.d.ts" /> | ||
/// <reference types="@tutorialkit/astro/types" /> | ||
/// <reference types="astro/client" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('user can navigate between lessons using breadcrumbs', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
await expect(page.getByRole('heading', { level: 1, name: 'Lessons in part test - Lesson one' })).toBeVisible(); | ||
await expect(page.getByText('Lesson in part without chapter')).toBeVisible(); | ||
|
||
// navigation select can take a while to hydrate on page load, click until responsive | ||
await expect(async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh interesting, what does this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The button can become visible before it has been hydrated. Clicking it doesn't do anything. So here if the last This hydration issue might be related to running |
||
const button = page.getByRole('button', { name: 'Part one / Lesson one' }); | ||
await button.click(); | ||
await expect(page.locator('[data-state="open"]', { has: button })).toBeVisible({ timeout: 50 }); | ||
}).toPass(); | ||
|
||
const navigation = page.getByRole('navigation'); | ||
await navigation.getByRole('region', { name: 'Part 1: Part one' }).getByRole('link', { name: 'Lesson two' }).click(); | ||
|
||
await expect(page.getByRole('heading', { level: 1, name: 'Lessons in part test - Lesson two' })).toBeVisible(); | ||
await expect(page.getByText('Lesson in part without chapter')).toBeVisible(); | ||
|
||
await expect(async () => { | ||
const button = page.getByRole('button', { name: 'Part one / Lesson two' }); | ||
await button.click(); | ||
await expect(page.locator('[data-state="open"]', { has: button })).toBeVisible({ timeout: 50 }); | ||
}).toPass(); | ||
|
||
// expand part | ||
await navigation.getByRole('button', { name: 'Part 2: Part two' }).click(); | ||
|
||
// expand chapter | ||
await navigation | ||
.getByRole('region', { name: 'Part 2: Part two' }) | ||
.getByRole('button', { name: 'Chapter one' }) | ||
.click(); | ||
|
||
// select lesson | ||
await navigation.getByRole('region', { name: 'Chapter one' }).getByRole('link', { name: 'Lesson three' }).click(); | ||
|
||
await expect(page.getByRole('heading', { level: 1, name: 'Lessons in part test - Lesson three' })).toBeVisible(); | ||
await expect(page.getByText('Lesson in chapter')).toBeVisible(); | ||
}); | ||
|
||
test('user can navigate between lessons using nav bar links', async ({ page }) => { | ||
await page.goto('/'); | ||
await expect(page.getByRole('heading', { level: 1, name: 'Lessons in part test - Lesson one' })).toBeVisible(); | ||
await expect(page.getByText('Lesson in part without chapter')).toBeVisible(); | ||
|
||
await navigateToPage('Lesson two'); | ||
await expect(page.getByText('Lesson in part without chapter')).toBeVisible(); | ||
|
||
await navigateToPage('Lesson three'); | ||
await expect(page.getByText('Lesson in chapter')).toBeVisible(); | ||
|
||
await navigateToPage('Lesson four'); | ||
await expect(page.getByText('Lesson in chapter')).toBeVisible(); | ||
|
||
async function navigateToPage(title: string) { | ||
await page.getByRole('link', { name: title }).click(); | ||
await expect(page.getByRole('heading', { level: 1, name: `Lessons in part test - ${title}` })).toBeVisible(); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('user can navigate between lessons using breadcrumbs', async ({ page }) => { | ||
await page.goto('/lesson-one'); | ||
|
||
await expect(page.getByRole('heading', { level: 1, name: 'Lessons in root test - Lesson one' })).toBeVisible(); | ||
await expect(page.getByText('Lesson in root without part')).toBeVisible(); | ||
|
||
// navigation select can take a while to hydrate on page load, click until responsive | ||
await expect(async () => { | ||
const button = page.getByRole('button', { name: 'Lesson one' }); | ||
await button.click(); | ||
await expect(page.locator('[data-state="open"]', { has: button })).toBeVisible({ timeout: 50 }); | ||
}).toPass(); | ||
|
||
await page.getByRole('navigation').getByRole('link', { name: 'Lesson two' }).click(); | ||
|
||
await expect(page.getByRole('heading', { level: 1, name: 'Lessons in root test - Lesson two' })).toBeVisible(); | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning to create
scripts/start.mjs
that can be called likenode scripts/start.mjs --dev lessons-in-root
to reduce these verbose scripts. But that will be added in follow-up PR.