Skip to content
Merged
Changes from all commits
Commits
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
27 changes: 24 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,26 @@ function validateStoriesFormat(config) {
if (testConfig.variables && typeof testConfig.variables !== 'object') {
throw new Error(`Invalid test-config: "variables" must be an object if provided. Found ${typeof testConfig.variables}.`);
}
if (testConfig.onPremiseBrowser && typeof testConfig.onPremiseBrowser !== 'boolean') {
throw new Error(`Invalid test-config: "onPremiseBrowser" must be a boolean if provided. Found ${typeof testConfig.onPremiseBrowser}.`);
}
}

if (config.pattern && typeof config.pattern !== 'string') {
throw new Error(`Invalid pattern: "pattern" must be a string if provided. Found ${typeof config.pattern}.`);
}

if (config.stories && !Array.isArray(config.stories)) {
throw new Error('Invalid stories: "stories" must be an array.');
}

const hasPattern = config.pattern !== undefined && config.pattern !== '';
const hasStories = config.stories && config.stories.length > 0;

if (hasPattern && hasStories) {
throw new Error('Cannot specify both pattern and stories array. Use either pattern or stories, not both.');
}

if (config.stories) {
config.stories.forEach(story => {
if (typeof story.slug !== 'string') {
Expand All @@ -161,6 +175,9 @@ function validateStoriesFormat(config) {
if (testConfig.variables && typeof testConfig.variables !== 'object') {
throw new Error(`Invalid test-config: "variables" must be an object if provided. Found ${typeof testConfig.variables}.`);
}
if (testConfig.onPremiseBrowser && typeof testConfig.onPremiseBrowser !== 'boolean') {
throw new Error(`Invalid test-config: "onPremiseBrowser" must be a boolean if provided. Found ${typeof testConfig.onPremiseBrowser}.`);
}
}

});
Expand Down Expand Up @@ -189,6 +206,7 @@ async function run() {
const payload = core.getInput('payload');
const stories = core.getInput('stories');
const testConfig = core.getInput('test-config');
const pattern = core.getInput('pattern');

if (suiteId && suite) {
core.setFailed('Please provide either suite-id or suite, not both.');
Expand All @@ -199,13 +217,13 @@ async function run() {
return;
}

if (suiteId && (stories || testConfig)) {
core.setFailed('When "suite-id" is provided, "stories" should come from "payload", not "stories" or "test-config".');
if (suiteId && (stories || testConfig || pattern)) {
core.setFailed('When "suite-id" is provided, "stories" or "pattern" should come from "payload", not "stories", "pattern" or "test-config".');
return;
}

if (suite && payload) {
core.setFailed('When "suite" is provided, "stories" should come from "stories", not "payload".');
core.setFailed('When "suite" is provided, "stories" or "pattern" should come from "stories"/"pattern", not "payload".');
return;
}

Expand Down Expand Up @@ -234,6 +252,9 @@ async function run() {
if (inputStories) {
validatedPayload.stories = JSON.parse(inputStories);
}
if (pattern) {
validatedPayload.pattern = pattern;
}
if (testConfig) {
validatedPayload["test-config"] = JSON.parse(testConfig);
}
Expand Down
Loading